Skip to content

Commit 1f278e7

Browse files
authored
Consolidate localization import and export into same YML. Use LCL hosted by the Loc team. (#7479)
1 parent bcc256e commit 1f278e7

File tree

5 files changed

+52
-63
lines changed

5 files changed

+52
-63
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ browse*.db*
66
*.exe
77
*.ilk
88

9-
# ignore exported localization xlf directory
9+
# ignore exported localization xlf and LCL directories
10+
Build/loc/LCL
1011
vscode-extensions-localization-export
1112

1213
# ignore imported localization xlf directory

Build/loc/LocProject.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"LocItems": [
66
{
77
"SourceFile": "vscode-extensions-localization-export\\vscode-extensions\\vscode-cpptools.xlf",
8-
"Languages": "cs;de;es;fr;it;ja;ko;pl;pt-BR;ru;tr;zh-Hans;zh-Hant"
8+
"Languages": "cs;de;es;fr;it;ja;ko;pl;pt-BR;ru;tr;zh-Hans;zh-Hant",
9+
"LclFile": "Build\\loc\\LCL\\{Lang}\\vscode-cpptools.xlf.lcl"
910
}
1011
]
1112
}
1213
]
13-
}
14+
}

Build/loc/TranslationsImport.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

Build/loc/TranslationsExport.yml renamed to Build/loc/TranslationsImportExport.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,26 @@ resources:
1010

1111
trigger: none
1212
pr: none
13+
schedules:
14+
- cron: "0 7 * * *"
15+
displayName: Daily 7 AM
16+
branches:
17+
include:
18+
- main
1319

1420
pool:
1521
vmImage: 'windows-latest'
1622

1723
steps:
24+
- task: CmdLine@2
25+
inputs:
26+
script: 'cd Extension && yarn install'
27+
1828
- task: CmdLine@2
1929
inputs:
2030
script: 'cd ./Extension && yarn run translations-export && cd ..'
2131

22-
- task: OneLocBuild@1
32+
- task: OneLocBuild@2
2333
env:
2434
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
2535
inputs:
@@ -29,6 +39,12 @@ steps:
2939
prSourceBranchPrefix: 'locfiles'
3040
packageSourceAuth: 'patAuth'
3141
patVariable: '$(OneLocBuildPat)'
42+
LclSource: lclFilesfromPackage
43+
LclPackageId: 'LCL-JUNO-PROD-VCPP'
44+
45+
- task: CmdLine@2
46+
inputs:
47+
script: 'cd Extension && node ./translations_auto_pr.js microsoft vscode-cpptools csigs $(csigsPat) csigs [email protected] "$(Build.ArtifactStagingDirectory)/loc" vscode-extensions-localization-export/vscode-extensions && cd ..'
3248

3349
- task: PublishBuildArtifacts@1
3450
inputs:

Extension/translations_auto_pr.js

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,33 @@ const pullRequestTitle = '[Auto] Localization - Translated Strings';
1313

1414
let repoOwner = process.argv[2];
1515
let repoName = process.argv[3];
16-
let locProjectName = process.argv[4];
17-
let authUser = process.argv[5];
18-
let authToken = process.argv[6];
19-
let userFullName = process.argv[7];
20-
let userEmail = process.argv[8];
21-
let locRepoPath = process.argv[9];
22-
23-
if (!repoOwner || !repoName || !locProjectName || !authUser || !authToken || !userFullName || !userEmail || !locRepoPath) {
24-
console.error(`ERROR: Usage: ${path.parse(process.argv[0]).base} ${path.parse(process.argv[1]).base} repo_owner repo_name loc_project_name auth_user auth_token user_full_name user_email loc_repo_path`);
16+
let authUser = process.argv[4];
17+
let authToken = process.argv[5];
18+
let userFullName = process.argv[6];
19+
let userEmail = process.argv[7];
20+
let locRootPath = process.argv[8];
21+
let locSubPath = process.argv[9];
22+
23+
if (!repoOwner || !repoName || !authUser || !authToken || !userFullName || !userEmail || !locRootPath || !locSubPath) {
24+
console.error(`ERROR: Usage: ${path.parse(process.argv[0]).base} ${path.parse(process.argv[1]).base} repo_owner repo_name auth_token user_full_name user_email loc_root_path loc_sub_path`);
25+
console.error(` repo_owner - The owner of the repo on GitHub. i.e. microsoft`);
26+
console.error(` repo_name - The name of the repo on GitHub. i.e. vscode-cpptools`);
27+
console.error(` auth_user - User account wiith permission to post a pull request against the GitHub repo.`);
28+
console.error(` auth_token - A PAT associated with auth_user.`);
29+
console.error(` user_full_name - A full name to associate with a git commit. (This is replaced by the PR account if commit is squashed.)`);
30+
console.error(` user_email - An email to associate with a git commit. (This is replaced by the PR account if commit is squashed.)`);
31+
console.error(` loc_root_path - The path to the folder with language-specific directories (containing localized xlf files).`);
32+
console.error(` loc_sub_path - A sub-path after the language-specific directory, where the xlf to import is located. This should not include the name of the xlf file to import.)`);
2533
return;
2634
}
2735

2836
console.log(`repoOwner=${repoOwner}`);
2937
console.log(`repoName=${repoName}`);
30-
console.log(`locProjectName=${locProjectName}`);
3138
console.log(`authUser=${authUser}`);
32-
console.log(`authToken=${authToken}`);
33-
console.log(`locRepoPath=${locRepoPath}`);
39+
console.log(`userFullName=${userFullName}`);
40+
console.log(`userEmail=${userEmail}`);
41+
console.log(`locRootPath=${locRootPath}`);
42+
console.log(`locSubPath=${locSubPath}`);
3443

3544
function hasBranch(branchName) {
3645
console.log(`Checking for existance of branch "${branchName}" (git branch --list ${branchName})`);
@@ -50,7 +59,10 @@ function hasAnyChanges() {
5059
let lines = output.toString().split("\n");
5160
let anyChanges = false;
5261
lines.forEach(line => {
53-
anyChanges = anyChanges || (line != '');
62+
if (line != '') {
63+
console.log("Change detected: " + line);
64+
anyChanges = true;
65+
}
5466
});
5567

5668
return anyChanges;
@@ -71,11 +83,10 @@ function sleep(ms) {
7183
console.log("This script is potentially DESTRUCTIVE! Cancel now, or it will proceed in 10 seconds.");
7284
sleep(10000);
7385

74-
let rootSourcePath = `${locRepoPath}\\Src\\VSCodeExt`;
75-
let directories = fs.readdirSync(rootSourcePath, { withFileTypes: true }).filter(dirent => dirent.isDirectory()).map(dirent => dirent.name);
76-
directories.forEach(folderName => {
77-
let sourcePath = `${rootSourcePath}\\${folderName}\\vscode-cpptools.xlf`;
78-
let destinationPath = `../vscode-translations-import/${folderName}/vscode-extensions/vscode-${locProjectName}.xlf`;
86+
let directories = [ "cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-BR", "ru", "tr", "zh-Hans", "zh-Hant" ];
87+
directories.forEach(languageId => {
88+
let sourcePath = `${locRootPath}\\${languageId}\\${locSubPath}\\${repoName}.${languageId}.xlf`;
89+
let destinationPath = `../vscode-translations-import/${languageId}/vscode-extensions/${repoName}.xlf`;
7990
console.log(`Copying "${sourcePath}" to "${destinationPath}"`);
8091
fs.copySync(sourcePath, destinationPath);
8192
});
@@ -172,10 +183,7 @@ console.log(`pushing to remove branch (git push -f origin ${branchName})`);
172183
cp.execSync(`git push -f origin ${branchName}`);
173184

174185
console.log("Checking if there is already a pull request...");
175-
const octokit = new Octokit({auth: {
176-
username: authUser,
177-
password: authToken}
178-
});
186+
const octokit = new Octokit.Octokit({auth: authToken});
179187
octokit.pulls.list({ owner: repoOwner, repo: repoName }).then(({data}) => {
180188
let alreadyHasPullRequest = false;
181189
if (data) {

0 commit comments

Comments
 (0)