Example #1
0
        public async Task Can_parse()
        {
            var i18NFile = new XliffFile
            {
                Tag         = "Desktop",
                CultureInfo = new CultureInfo("es-ES"),
                Name        = "messages.es.xlf"
            };
            var file = _parserService.GetTranslations(i18NFile);

            Check.That(file.Translations.Count).Equals(552);

            Check.That(file.Translations.Single(t => t.Key == "informationSecurity_header").Translation).Equals("Seguridad");
        }
        public static void Main()
        {
            // Load configuration file (appSettings.json)
            var configuration = new ConfigurationFacade();

            // instantiate XliffParserService
            var xliffParserService = new XliffParserService(configuration.XlfFilesRootPath);

            // read all the xlf files to get a list of the i18n keys and their texts
            var i18NTranslations = configuration.XlfFiles.Select(f => xliffParserService.GetTranslations(f)).ToList();
            var translations     = I18NAggregateService.Aggregate(i18NTranslations);

            // parse the angular html templates to migrate ngx-translate
            MigrateTemplates(translations, configuration);

            // create the json files
            JsonTranslationFileCreatorService.CreateFiles(translations, configuration.JsonTargetPath);

            // flag as obsolete the migrated i18n keys
            foreach (var xliffFile in configuration.XlfFiles)
            {
                XliffUpdaterService.FlagAsObsoleteMigratedKey(translations.Where(t => t.MigrationDone).Select(t => t.I18NKey).ToList(), xliffFile, configuration.XlfFilesRootPath);
            }

            // create a csv report of the migration
            ReportService.CreateReport(translations, configuration.ReportFilePath, i18NTranslations);
        }