Ejemplo n.º 1
0
        private static IEnumerable<CharacterRegion> CreateCharacterRegionsFromSourceFile(FontGenerationParameters parameters)
        {
            var culture = parameters.SourceCulture ?? CultureInfo.CurrentCulture.ToString();
            var files = parameters.SourceFile.Split(',');
            var filesText = new StringBuilder();

            foreach (var file in files)
            {
                try
                {
                    var ext = Path.GetExtension(file)?.ToLowerInvariant();
                    if (ext == ".xml" || ext == ".json")
                    {
                        var db = new LocalizationDatabase();
                        db.LoadFromFile(file);

                        Console.Write("Reading source file '{0}'... ", Path.GetFileName(file));
                        var count = 0;

                        foreach (var lstring in db.EnumerateCultureStrings(culture))
                        {
                            foreach (var variant in lstring.Value)
                            {
                                filesText.Append(variant.Value);
                                count++;
                            }
                        }
                        Console.WriteLine("(found {0} string variants)", count);
                    }
                    else
                    {
                        Console.WriteLine("Reading source file '{0}'...", Path.GetFileName(file));
                        filesText.Append(File.ReadAllText(file));
                    }
                }
                catch (FileNotFoundException)
                {
                    Console.WriteLine("Unable to read file '{0}'.", file);
                }
                catch (DirectoryNotFoundException)
                {
                    Console.WriteLine("Unable to read file '{0}'.", file);
                }
            }

            filesText.Append(parameters.SubstitutionCharacter);
            return CharacterRegion.CreateFromSourceText(filesText.ToString());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StringResource"/> class.
 /// </summary>
 /// <param name="database">The localization database that contains the string resource.</param>
 /// <param name="key">The string's localization key.</param>
 public StringResource(LocalizationDatabase database, String key)
 {
     this.database = database ?? Localization.Strings;
     this.key = key;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StringResource"/> class.
 /// </summary>
 /// <param name="database">The localization database that contains the string resource.</param>
 /// <param name="key">The string's localization key.</param>
 public StringResource(LocalizationDatabase database, String key)
 {
     this.database = database ?? Localization.Strings;
     this.key      = key;
 }