Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onboard Localization pipeline #5990

Merged
merged 107 commits into from
Aug 4, 2023
Merged

Onboard Localization pipeline #5990

merged 107 commits into from
Aug 4, 2023

Conversation

Cosifne
Copy link
Member

@Cosifne Cosifne commented Aug 2, 2023

Sample run #5987
https://dev.azure.com/dnceng/internal/_build/results?buildId=2234885&view=results

This PR contains two localization file changes. One in code and one in package.json as the test sample.
In code, it uses vs-l10n to do localization.

The pipeline works like this:

  1. Extract localization strings to bundle.l10n.json. (l10n-dev)
  2. Convert them into .xlf file. (l10-dev)
  3. Use OneLocBulid task to generate translated .xlf file (OneLocBuild)
  4. Import all the translated file back to json under l10n folder. (l10n-dev)
  5. Use dotnet-bot to submit a PR back to main on GitHub.

I feel it is enough to always translate our main branch here. If there is any problem we can address it in the future.

After this, two more things are needed.

  1. Ask the LOC team to onboard our repo to their list, so that all things are get translated.
  2. Extract all the strings, and package.json to use l10n, this might be in another PR.

@@ -1322,7 +1329,7 @@
"properties": {
"dotnet.defaultSolution": {
"type": "string",
"description": "The path of the default solution to be opened in the workspace, or set to 'disable' to skip it.",
"description": "%configuration.dotnet.defaultSolution.description%",
Copy link
Member Author

Choose a reason for hiding this comment

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

The sample used in this PR

@@ -494,7 +494,7 @@ export class RoslynLanguageServer {
return;
}

const title = 'Restart Language Server';
const title = vscode.l10n.t('Restart Language Server');
Copy link
Member Author

Choose a reason for hiding this comment

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

The other sample used in this PR

"LanguageSet": "VS_Main_Languages",
"LocItems": [
{
"SourceFile": "./loc/vscode-csharp.xlf",
Copy link
Member Author

Choose a reason for hiding this comment

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

vscode-csharp.xlf is a generated file from l10nDevGenerateXlf task in package.json.
It is passed to the localization build.

./loc folder is used to stage all the generated files.

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
tasks/localizationTasks.ts Outdated Show resolved Hide resolved
tasks/localizationTasks.ts Show resolved Hide resolved
tasks/localizationTasks.ts Outdated Show resolved Hide resolved
const lsRemote = await git(['ls-remote', remoteRepoAlias, 'refs/head/' + newBranchName]);
if (lsRemote.trim() !== '') {
// If the localization branch of this commit already exists, don't try to create another one.
console.log(`${newBranchName} already exists in ${parsedArgs.targetRemoteRepo}. Skip pushing.`);
Copy link
Member

Choose a reason for hiding this comment

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

is this expected to happen? Should it throw?

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 suppose this might happen, in case the pipeline run is canceled when branch is pushed but no PR is created

Copy link
Member

Choose a reason for hiding this comment

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

.filter((fileName) => fileName.length !== 0);
}

async function git(args: string[], printCommand = true): Promise<string> {
Copy link
Member

Choose a reason for hiding this comment

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

It seems like we always print the command, so maybe removable?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, when we call git add remote url, PAT is encoded like this
https://${parsedArgs.userName}:${pat}@github.com/${parsedArgs.owner}/${parsedArgs.targetRemoteRepo}.git
I don't want to reveal the PAT in this case

tasks/localizationTasks.ts Outdated Show resolved Hide resolved
@Cosifne Cosifne mentioned this pull request Aug 2, 2023
@Cosifne Cosifne requested a review from a team as a code owner August 2, 2023 23:31
@Cosifne
Copy link
Member Author

Cosifne commented Aug 2, 2023

Because Phil merged this #5962 so there are more strings need localization : )

Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

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

Mostly good now - I think still just pending if we can avoid the diff reset in https://github.com/dotnet/vscode-csharp/pull/5990/files#r1282385281

Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

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

1 minor comment

const lsRemote = await git(['ls-remote', remoteRepoAlias, 'refs/head/' + newBranchName]);
if (lsRemote.trim() !== '') {
// If the localization branch of this commit already exists, don't try to create another one.
console.log(`${newBranchName} already exists in ${parsedArgs.targetRemoteRepo}. Skip pushing.`);
Copy link
Member

Choose a reason for hiding this comment

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

@Cosifne Cosifne enabled auto-merge (squash) August 3, 2023 22:26
@Cosifne Cosifne merged commit 301f9b3 into dotnet:main Aug 4, 2023
4 checks passed
@@ -0,0 +1,85 @@
{
"Cannot load Razor language server because the directory was not found: '{0}'": "Cannot load Razor language server because the directory was not found: '{0}'",
Copy link
Contributor

@WardenGnaw WardenGnaw Aug 7, 2023

Choose a reason for hiding this comment

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

@Cosifne The keys of this file can be used to help organize who owns the strings / help what the usage should be. I would reccomend changing it to be something similar so its easier to use rather than having to change they key and value in multiple places.

See https://github.com/microsoft/vscode-cpptools/blob/ae904ec3306d563db44445dac90728ec706424d3/Extension/package.nls.json

Copy link
Member Author

Choose a reason for hiding this comment

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

This key is auto-generated by the l10n tool, let me see if this can be optimized or not

Copy link
Contributor

Choose a reason for hiding this comment

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

@Cosifne Sorry I'm incorrect here. I think this is correct for the l10n.json file. I got this confused with the nls.json file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants