Skip to content

Conversation

@rokonec
Copy link
Member

@rokonec rokonec commented Jan 27, 2022

Background:

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 VS.

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

What to expect after merging

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

  • The dev making the change should build (at the very least) 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.

<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>63715256cc94963d608ef3d683d2529332c5140c</Sha>
</Dependency>
<Dependency Name="Microsoft.TemplateEngine.Tasks" Version="7.0.100-alpha.1.21601.1">
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to add a Maestro subscription for this? Can it be a dependency of dotnet/installer, so when we get updates for dotnet/installer this number follows along?

See an example here on how ILLink updates along with dotnet/installer: #6670

Copy link
Member

Choose a reason for hiding this comment

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

Adding dependency is possible, but updates will be coming quite frequently - in templating all the packages are produced on any change (even unrelated to package).

Alternative is to add the task via Arcade SDK, I see the repo has already reference to it https://github.com/xamarin/xamarin-android/blob/71e6ecd67b08394482317c94db9ff35dc051ffbc/global.json#L7 and dependency https://github.com/xamarin/xamarin-android/blob/71e6ecd67b08394482317c94db9ff35dc051ffbc/eng/Version.Details.xml#L21-L24

But this version is very old, we need to update it. Also template localization task is only available from arcade SDK 7, if you need to stay on 6 - we might need to backport it.

Copy link
Member

Choose a reason for hiding this comment

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

yeah need to know for us too.

Copy link
Member

Choose a reason for hiding this comment

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

@pjcollins should we setup a weekly subscription for dotnet/arcade?

We might also need to configure a few things so the version number is used throughout our build.

Copy link
Member

Choose a reason for hiding this comment

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

I vaguely remember maestro updates failing for arcade in the past. I think we'll need to bring more of the arcade sdk into the eng/ folder to get arcade updates to flow through maestro, but I am not positive. I can try to look at that this week, but for now maybe we can manually bump this version for this PR?

@vlada-shubina
Copy link
Member

@jonathanpeppers @pjcollins another problem to solve is how to handoff/handback generated json files to OneLocBuild.
does this repo has already an pipeline to do that? I couldn't find one.
arcade has yaml / script for this which already handles template localization, but since this repo is not on arcade, we need custom steps here.

@rokonec rokonec marked this pull request as ready for review March 21, 2022 14:11
@rokonec rokonec requested a review from jonpryor as a code owner March 21, 2022 14:11
@vlada-shubina
Copy link
Member

@jonathanpeppers @pjcollins another problem to solve is how to handoff/handback generated json files to OneLocBuild. does this repo has already an pipeline to do that? I couldn't find one. arcade has yaml / script for this which already handles template localization, but since this repo is not on arcade, we need custom steps here.

To finalize the effort, we need to include also similar script here dotnet/macios@477757f.
At the build time the templatestrings.en.json should be renamed to templatestrings.json and added to localization project JSON. Could you please advise at which step it would be best to do it? Thanks

@jonathanpeppers
Copy link
Member

@vlada-shubina
Copy link
Member

@vlada-shubina could we do this in MSBuild in this project?

https://github.com/xamarin/xamarin-android/blob/main/src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj

And make a target that runs before Build or Pack?

Yes, that's also possible. It should be done after Build as the translation files won't be generated before that.
Also it should be only applied to CI build - templatestrings.json should not be included to repo. Is there any property that allows to distinguish CI build from others?

@jonathanpeppers
Copy link
Member

@vlada-shubina you should be able to check if $(RunningOnCI) is true in MSBuild.

@pjcollins
Copy link
Member

@vlada-shubina @rokonec we've started running OneLocBuild as of fa9629d. However, the repo is still pending onboarding via https://ceapex.visualstudio.com/CEINTL/_workitems/edit/663104. Do we need to wait for that process to complete before picking this work up again, or is the OneLocBuild job addition enough to unblock this?

@vlada-shubina
Copy link
Member

@pjcollins

it should be enough to have the job added to start it, however during onboarding you should mention that you'll be localizing templates as well, afaik this needs additional setup on their side as well.

Are you using arcade scripts for localization or do you have your own?
If you have your own scripts, you might need to add extra steps to them similar to dotnet/macios@af30c26

Basically the following steps are needed:

  • templatestrings.en.json files should be renamed to templatestrings.json
  • templatestrings.json files should be included to LocProject.json that is being handed over to translations.

On localization hand back you need to ensure that translated files are put to localize folder in .template.config folder.

If you use arcade scripts, they already do all steps above.

@pjcollins
Copy link
Member

I've pulled these changes into #7248, I think we'll be able to close this in favor of that new one.

@jonpryor
Copy link
Contributor

Superseded by PR #7248, which has been merged.

Thanks!

@jonpryor jonpryor closed this Aug 12, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
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.

6 participants