Skip to content

Conversation

@pjcollins
Copy link
Member

@pjcollins pjcollins commented Aug 10, 2022

Context: #6677

The Microsoft.Android.Templates project has been onboarded to the new
template localization system. Local template builds will now use
Microsoft.TemplateEngine.Tasks to generate templatestrings.*.json
files used for localization.

The new update-locproject.ps1 script runs as part of the OneLocBuild
job in CI. This script will copy each english templatestrings.en.json
file to templatestrings.json, and add it as a new translation source
file entry to LocProject.json. This update to LocProject.json will
tell the OneLocBuild task to process our templates.

This script borrows heavily from the generate-locproject.ps1 script
found in dotnet/arcade.


Description from PR 6677:

Template engine (dotnet new) added support for template localizations in
.NET 6.0. This new system replaces the old way of localizing templates
that only worked on Visual Studio and works on both .NET CLI as well as
Visual Studio.

This PR introduces changes to switch to the new template localization system.

Summary of the changes:

  • Adds <LocalizeTemplates>true</> to project containing templates.
  • Include PackageReference for Microsoft.TemplateEngine.Tasks to project containing templates.
  • Generates localization files to be translated by loc team

Every time there is a change to one of the templates:

  • The dev making the change should build the modified template project. This will update the loc files on the local working copy,
  • Push the loc files together with the template modifications. Review & merge.
  • OneLocBuild integration will automatically pick up the changes and will send them for translation.
  • You will receive a PR containing the translated template loc files when they are ready. Review & merge.

Context: #6677

The `Microsoft.Android.Templates` project has been onboarded to the new
template localization system.  Local template builds will now use
`Microsoft.TemplateEngine.Tasks` to generate `templatestrings.*.json`
files used for localization.

The new `update-locproject.ps1` script runs as part of the `OneLocBuild`
job in CI.  This script will copy each english `templatestrings.en.json`
file to `templatestrings.json`, and add it as a new translation source
file entry to `LocProject.json`.  This update to `LocProject.json` will
tell the `OneLocBuild` task to process our templates.

This script borrows heavily from the [generate-locproject.ps1][0] script
found in dotnet/arcade.

Description from PR 6677:

Template engine (dotnet new) added support for template localizations in
.NET 6.0. This new system replaces the old way of localizing templates
that only worked on Visual Studio and works on both .NET CLI as well as
Visual Studio.

This PR introduces changes to switch to the new template localization system.

Summary of the changes:

 * Adds `<LocalizeTemplates>true</>` to project containing templates.
 * Include PackageReference for `Microsoft.TemplateEngine.Tasks` to project containing templates.
 * Generates localization files to be translated by loc team

Every time there is a change to one of the templates:

 * The dev making the change should build the modified template project. This will update the loc files on the local working copy,
 * Push the loc files together with the template modifications. Review & merge.
 * OneLocBuild integration will automatically pick up the changes and will send them for translation.
 * You will receive a PR containing the translated template loc files when they are ready. Review & merge.

[0]: https://github.com/dotnet/arcade/blob/e771d68edea1cfcd4a49e160093a4f32df8a6288/eng/common/generate-locproject.ps1
@pjcollins
Copy link
Member Author

Tested this with https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=6540194&view=logs&j=b0d940c4-07db-5357-83ba-1a4207a17644&t=f6fbc6c3-6cd9-5e85-c68a-d9367c5fa9a7&l=170. The updated LocProject and OneLocBuild task output look good as far as I can tell, we'll now need to wait for translations for these:

OneLocBuildClient.exe Information: 0 : [src\Microsoft.Android.Templates\android\.template.config\localize\templatestrings.json] 0% localized for 13 languages.
OneLocBuildClient.exe Information: 0 : [src\Microsoft.Android.Templates\android-activity\.template.config\localize\templatestrings.json] 0% localized for 13 languages.
OneLocBuildClient.exe Information: 0 : [src\Microsoft.Android.Templates\android-bindinglib\.template.config\localize\templatestrings.json] 0% localized for 13 languages.
OneLocBuildClient.exe Information: 0 : [src\Microsoft.Android.Templates\android-layout\.template.config\localize\templatestrings.json] 0% localized for 13 languages.
OneLocBuildClient.exe Information: 0 : [src\Microsoft.Android.Templates\android-wear\.template.config\localize\templatestrings.json] 0% localized for 13 languages.
OneLocBuildClient.exe Information: 0 : [src\Microsoft.Android.Templates\androidlib\.template.config\localize\templatestrings.json] 0% localized for 13 languages.

@pjcollins pjcollins marked this pull request as ready for review August 10, 2022 18:03
@@ -0,0 +1,28 @@
param ($SourcesDirectory, $LocProjectPath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Should this use a shebang and be +x on Unix?
  2. If we do use a shebang, then this file needs to be Unix formatted.
  3. If this file needs to be Unix formatted, then we should update .gitattributes accordingly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would lean towards no as I don't anticipate us needing to invoke this script much (if ever) outside of CI, and running the script with a pwsh prefix in those cases doesn't feel like too much overhead. I will make these changes if you would prefer though?

@jonpryor
Copy link
Contributor

jonpryor commented Aug 12, 2022

Context: https://github.com/dotnet/templating/blob/6ecea73aad1ce3444dbf28fc340e5f464f6278df/docs/Localization.md

The `dotnet new` template engine supports localization as of .NET 6.

Update the `Microsoft.Android.Templates` project to use the new
localization system.  Local template builds now use
`Microsoft.TemplateEngine.Tasks` teo generate the
`templatestrings.*.json` files used for localization.

The new `update-locproject.ps1` script runs as part of the
`OneLocBuild` job in CI (fa9629db).  This script will copy each
english `templatestrings.en.json` file to `templatestrings.json`, and
add it as a new translation source file entry to `LocProject.json`.
This update to `LocProject.json` will tell the `OneLocBuild` task to
process our templates.

This script borrows heavily from the [generate-locproject.ps1][0]
script found in dotnet/arcade.

Every time there is a change to one of the templates:

 1. The dev making the change should build the modified template
    project. This will update the loc files on the local working copy,

        dotnet build src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj
        # -or-
        dotnet build Xamarin.Android.sln

 2. Push the loc files together with the template modifications.
    Review & merge.

 3. OneLocBuild integration will automatically pick up the changes
    and will send them for translation.

 4. You will receive a PR containing the translated template loc
    files when they are ready. Review & merge.

[0]: https://github.com/dotnet/arcade/blob/e771d68edea1cfcd4a49e160093a4f32df8a6288/eng/common/generate-locproject.ps1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants