Esempio n. 1
0
        private static void CreateVsctFiles(string sourceFile, string xlfDir)
        {
            if (string.IsNullOrEmpty(sourceFile))
            {
                throw new ArgumentNullException("file should be set.");
            }

            var targetDir = Path.GetDirectoryName(sourceFile);
            var rootName  = Utilities.VsctFileNameWithoutExtension(sourceFile);

            var vsctFile = new VsctFile(sourceFile);
            var xlfFiles = new XliffFile(xlfDir, rootName);

            foreach (var locale in Locales)
            {
                if (StringComparer.OrdinalIgnoreCase.Equals(locale, "en"))
                {
                    // for english just copy the file to a new file name
                    var destFileName = Path.Combine(targetDir, $"{rootName}.en{VsctFile.VsctExt}");
                    File.Copy(sourceFile, destFileName, overwrite: true);
                }
                else
                {
                    var translations = xlfFiles.LoadTranslatedElements(locale);
                    vsctFile.WriteTranslatedFile(translations, locale);
                }
            }
        }
Esempio n. 2
0
        private static void CreateXliffFiles(string sourceFile, string xlfDir)
        {
            if (string.IsNullOrEmpty(sourceFile) || string.IsNullOrEmpty(xlfDir))
            {
                throw new ArgumentNullException("file and targetDir should be set.");
            }

            var rootName = Utilities.VsctFileNameWithoutExtension(sourceFile);

            var reader = new VsctFile(sourceFile);
            var writer = new XliffFile(xlfDir, rootName);

            foreach (var locale in Locales)
            {
                writer.WriteTranslationFile(sourceFile, reader.ReadTranslatableUnits(), locale);
            }
        }