mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Localization updates (#310)
* adding template files * adding templates to build.cake * removing files we don't need * fixing whitespace
This commit is contained in:
23
build.cake
23
build.cake
@@ -520,10 +520,11 @@ Task("SRGen")
|
||||
.Does(() =>
|
||||
{
|
||||
var projects = System.IO.Directory.GetFiles(sourceFolder, "project.json", SearchOption.AllDirectories).ToList();
|
||||
var locTemplateDir = System.IO.Path.Combine(sourceFolder, "../localization");
|
||||
|
||||
foreach(var project in projects) {
|
||||
var projectDir = System.IO.Path.GetDirectoryName(project);
|
||||
var localizationDir = System.IO.Path.Combine(projectDir, "Localization");
|
||||
var localizationDir = System.IO.Path.Combine(projectDir, "Localization");
|
||||
var projectName = (new System.IO.DirectoryInfo(projectDir)).Name;
|
||||
var projectNameSpace = projectName + ".Localization";
|
||||
var projectStrings = System.IO.Path.Combine(localizationDir, "sr.strings");
|
||||
@@ -566,9 +567,27 @@ Task("SRGen")
|
||||
var xlfDocNames = System.IO.Directory.GetFiles(inputXliff, "*.xlf", SearchOption.AllDirectories).ToList();
|
||||
foreach(var docName in xlfDocNames)
|
||||
{
|
||||
// load our language XLIFF
|
||||
var xlfDoc = new XliffParser.XlfDocument(docName);
|
||||
var xlfFile = xlfDoc.Files.Single();
|
||||
|
||||
// load a language template
|
||||
var templateFileLocation = System.IO.Path.Combine(locTemplateDir, System.IO.Path.GetFileName(docName) + ".template");
|
||||
var templateDoc = new XliffParser.XlfDocument(templateFileLocation);
|
||||
var templateFile = templateDoc.Files.Single();
|
||||
|
||||
// iterate through our tranlation units and prune invalid units
|
||||
foreach (var unit in xlfFile.TransUnits)
|
||||
{
|
||||
// if a unit does not have a target it is invalid
|
||||
if (unit.Target != null) {
|
||||
templateFile.AddTransUnit(unit.Id, unit.Source, unit.Target, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// export modified template to RESX
|
||||
var newPath = System.IO.Path.Combine(localizationDir, System.IO.Path.GetFileName(docName));
|
||||
xlfDoc.SaveAsResX(newPath.Replace("xlf","resx"));
|
||||
templateDoc.SaveAsResX(newPath.Replace("xlf","resx"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user