From 2a7bf7fb5b5b893e78e5564029782b27b6265c6f Mon Sep 17 00:00:00 2001 From: Arjun Balgovind <32061677+arjunbalgovind@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:10:15 -0700 Subject: [PATCH] [Localization] Add localization step to pipeline and enable localization on C# projects with resx/resw resource files (#6033) * Added localization code to pipeline and created one LocProject json for Settings * Fixed typo * Reordered nuget source * Moved nuget install to restore step * Added FZ.rc file to LocProj * Added FZ resx file and modified rc file * Fixed file names * Changed to check folder for LocProject files * Updated folder * Changed directory * Changed to src directory * Changed language set and name format, removed rc file localization * Added all projects with resx/resw files * Added newline to end of file * Removed nuget source as it is not used * Updated comments * Fixed formatting of json file * Move loc step to end --- .pipelines/build-localization.cmd | 28 ++++++++++++++++ .pipelines/pipeline.user.windows.yml | 13 ++++++++ .pipelines/restore-localization.cmd | 32 +++++++++++++++++++ .../LocProject.json | 14 ++++++++ .../colorPicker/ColorPickerUI/LocProject.json | 14 ++++++++ .../editor/FancyZonesEditor/LocProject.json | 14 ++++++++ src/modules/imageresizer/ui/LocProject.json | 14 ++++++++ .../launcher/PowerLauncher/LocProject.json | 14 ++++++++ .../MarkdownPreviewHandler/LocProject.json | 14 ++++++++ .../SvgPreviewHandler/LocProject.json | 14 ++++++++ 10 files changed, 171 insertions(+) create mode 100644 .pipelines/build-localization.cmd create mode 100644 .pipelines/restore-localization.cmd create mode 100644 src/core/Microsoft.PowerToys.Settings.UI/LocProject.json create mode 100644 src/modules/colorPicker/ColorPickerUI/LocProject.json create mode 100644 src/modules/fancyzones/editor/FancyZonesEditor/LocProject.json create mode 100644 src/modules/imageresizer/ui/LocProject.json create mode 100644 src/modules/launcher/PowerLauncher/LocProject.json create mode 100644 src/modules/previewpane/MarkdownPreviewHandler/LocProject.json create mode 100644 src/modules/previewpane/SvgPreviewHandler/LocProject.json diff --git a/.pipelines/build-localization.cmd b/.pipelines/build-localization.cmd new file mode 100644 index 0000000000..318735382e --- /dev/null +++ b/.pipelines/build-localization.cmd @@ -0,0 +1,28 @@ +@echo off +rem This script will fail to run unless you have the appropriate permissions + +cd /D "%~dp0" + +echo Preparing localization build... + +setlocal + +rem In this sample, the repo root is identical to the script directory path. Adjust the value of the RepoRoot variable accordingly based on your environment. +rem Again, ensure the RepoRoot variable is set to the real repo root location, otherwise the localization toolset wouldn't work as intended. +rem Note that the resolved %~dp0 ends with \. +set RepoRoot=%~dp0..\ +set OutDir=%RepoRoot%out +set NUGET_PACKAGES=%RepoRoot%packages +set LocalizationXLocPkgVer=2.0.0 + +echo Running localization build... + +set XLocPath=%NUGET_PACKAGES%\Localization.XLoc.%LocalizationXLocPkgVer% +set LocProjectDirectory=%RepoRoot%src + +rem Run the localization tool on all LocProject.json files in the src directory and it's subdirectories +dotnet "%XLocPath%\tools\netcore\Microsoft.Localization.XLoc.dll" /f "%LocProjectDirectory%" + +echo Localization build finished with exit code '%errorlevel%'. + +exit /b %errorlevel% diff --git a/.pipelines/pipeline.user.windows.yml b/.pipelines/pipeline.user.windows.yml index 0ee9147d52..c851d2f1aa 100644 --- a/.pipelines/pipeline.user.windows.yml +++ b/.pipelines/pipeline.user.windows.yml @@ -20,6 +20,7 @@ package_sources: nuget: feeds: 'Nuget': 'https://api.nuget.org/v3/index.json' + 'Toolset': 'https://msazure.pkgs.visualstudio.com/_packaging/Toolset/nuget/v3/index.json' 'PipelineBuildSupplement': 'https://msazure.pkgs.visualstudio.com/_packaging/PipelineBuildSupplement/nuget/v3/index.json' restore: @@ -33,6 +34,9 @@ restore: - !!defaultcommand name: 'Restore Installer' command: '.pipelines\restore-installer.cmd' + - !!defaultcommand + name: 'Restore Localization packages' + command: '.pipelines\restore-localization.cmd' build: @@ -145,6 +149,15 @@ build: - 'PowerToysSetup-*.exe' signing_options: sign_inline: true # This does signing a soon as this command completes + # Localize the files after the build procedure to avoid existing localized files from getting overwritten. To be moved before the Build PowerToys step once the lcl files have been checked in. Tracked at https://github.com/microsoft/PowerToys/issues/6046 + - !!buildcommand + name: 'Localize Power Toys' + command: '.pipelines\build-localization.cmd' + artifacts: + - from: 'out\loc' + to: 'loc' + include: + - '**/*' #package: diff --git a/.pipelines/restore-localization.cmd b/.pipelines/restore-localization.cmd new file mode 100644 index 0000000000..fdc8fa5e24 --- /dev/null +++ b/.pipelines/restore-localization.cmd @@ -0,0 +1,32 @@ +@echo off + +cd /D "%~dp0" + +echo Installing nuget packages + +setlocal + +rem In this sample, the repo root is identical to the script directory path. Adjust the value of the RepoRoot variable accordingly based on your environment. +rem Again, ensure the RepoRoot variable is set to the real repo root location, otherwise the localization toolset wouldn't work as intended. +rem Note that the resolved %~dp0 ends with \. +set RepoRoot=%~dp0..\ +set OutDir=%RepoRoot%out +set NUGET_PACKAGES=%RepoRoot%packages +set LocalizationXLocPkgVer=2.0.0 + +nuget install Localization.XLoc -Version %LocalizationXLocPkgVer% -OutputDirectory "%NUGET_PACKAGES%" -NonInteractive -Verbosity detailed +if "%errorlevel%" neq "0" ( + exit /b %errorlevel% +) + +nuget install LSBuild.XLoc -OutputDirectory "%NUGET_PACKAGES%" -NonInteractive -Verbosity detailed +if "%errorlevel%" neq "0" ( + exit /b %errorlevel% +) + +nuget install Localization.Languages -OutputDirectory "%NUGET_PACKAGES%" -NonInteractive -Verbosity detailed +if "%errorlevel%" neq "0" ( + exit /b %errorlevel% +) + +exit /b %errorlevel% diff --git a/src/core/Microsoft.PowerToys.Settings.UI/LocProject.json b/src/core/Microsoft.PowerToys.Settings.UI/LocProject.json new file mode 100644 index 0000000000..2c4de4da57 --- /dev/null +++ b/src/core/Microsoft.PowerToys.Settings.UI/LocProject.json @@ -0,0 +1,14 @@ +{ + "Projects": [ + { + "LanguageSet": "Azure_Languages", + "LocItems": [ + { + "SourceFile": "src\\core\\Microsoft.PowerToys.Settings.UI\\Strings\\en-us\\Resources.resw", + "CopyOption": "LangIDOnName", + "OutputPath": "src\\core\\Microsoft.PowerToys.Settings.UI\\Strings" + } + ] + } + ] +} diff --git a/src/modules/colorPicker/ColorPickerUI/LocProject.json b/src/modules/colorPicker/ColorPickerUI/LocProject.json new file mode 100644 index 0000000000..c60c98a308 --- /dev/null +++ b/src/modules/colorPicker/ColorPickerUI/LocProject.json @@ -0,0 +1,14 @@ +{ + "Projects": [ + { + "LanguageSet": "Azure_Languages", + "LocItems": [ + { + "SourceFile": "src\\modules\\colorPicker\\ColorPickerUI\\Properties\\Resources.resx", + "CopyOption": "LangIDOnName", + "OutputPath": "src\\modules\\colorPicker\\ColorPickerUI\\Properties" + } + ] + } + ] +} diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/LocProject.json b/src/modules/fancyzones/editor/FancyZonesEditor/LocProject.json new file mode 100644 index 0000000000..ae72642516 --- /dev/null +++ b/src/modules/fancyzones/editor/FancyZonesEditor/LocProject.json @@ -0,0 +1,14 @@ +{ + "Projects": [ + { + "LanguageSet": "Azure_Languages", + "LocItems": [ + { + "SourceFile": "src\\modules\\fancyzones\\editor\\FancyZonesEditor\\Properties\\Resources.resx", + "CopyOption": "LangIDOnName", + "OutputPath": "src\\modules\\fancyzones\\editor\\FancyZonesEditor\\Properties" + } + ] + } + ] +} diff --git a/src/modules/imageresizer/ui/LocProject.json b/src/modules/imageresizer/ui/LocProject.json new file mode 100644 index 0000000000..22fd8a320f --- /dev/null +++ b/src/modules/imageresizer/ui/LocProject.json @@ -0,0 +1,14 @@ +{ + "Projects": [ + { + "LanguageSet": "Azure_Languages", + "LocItems": [ + { + "SourceFile": "src\\modules\\imageresizer\\ui\\Properties\\Resources.resx", + "CopyOption": "LangIDOnName", + "OutputPath": "src\\modules\\imageresizer\\ui\\Properties" + } + ] + } + ] +} diff --git a/src/modules/launcher/PowerLauncher/LocProject.json b/src/modules/launcher/PowerLauncher/LocProject.json new file mode 100644 index 0000000000..b195cbc41c --- /dev/null +++ b/src/modules/launcher/PowerLauncher/LocProject.json @@ -0,0 +1,14 @@ +{ + "Projects": [ + { + "LanguageSet": "Azure_Languages", + "LocItems": [ + { + "SourceFile": "src\\modules\\launcher\\PowerLauncher\\Properties\\Resources.resx", + "CopyOption": "LangIDOnName", + "OutputPath": "src\\modules\\launcher\\PowerLauncher\\Properties" + } + ] + } + ] +} diff --git a/src/modules/previewpane/MarkdownPreviewHandler/LocProject.json b/src/modules/previewpane/MarkdownPreviewHandler/LocProject.json new file mode 100644 index 0000000000..1a74680f2a --- /dev/null +++ b/src/modules/previewpane/MarkdownPreviewHandler/LocProject.json @@ -0,0 +1,14 @@ +{ + "Projects": [ + { + "LanguageSet": "Azure_Languages", + "LocItems": [ + { + "SourceFile": "src\\modules\\previewpane\\MarkDownPreviewHandler\\Properties\\Resources.resx", + "CopyOption": "LangIDOnName", + "OutputPath": "src\\modules\\previewpane\\MarkDownPreviewHandler\\Properties" + } + ] + } + ] +} diff --git a/src/modules/previewpane/SvgPreviewHandler/LocProject.json b/src/modules/previewpane/SvgPreviewHandler/LocProject.json new file mode 100644 index 0000000000..539653476e --- /dev/null +++ b/src/modules/previewpane/SvgPreviewHandler/LocProject.json @@ -0,0 +1,14 @@ +{ + "Projects": [ + { + "LanguageSet": "Azure_Languages", + "LocItems": [ + { + "SourceFile": "src\\modules\\previewpane\\SvgPreviewHandler\\Resource.resx", + "CopyOption": "LangIDOnName", + "OutputPath": "src\\modules\\previewpane\\SvgPreviewHandler" + } + ] + } + ] +}