Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f04d870
Consolidate loc build configs into a single build config
Colengms May 4, 2021
8cedaab
Fix typos
Colengms May 4, 2021
2c43ce7
Put auth_user back in
Colengms May 4, 2021
3fd2102
Update yml
Colengms May 4, 2021
b1f1994
Fix typos
Colengms May 4, 2021
6b9bb37
Skip english when importing
Colengms May 4, 2021
3a98a0a
Use hard-coded list of loc language directories
Colengms May 4, 2021
541185b
Fix array initialization
Colengms May 4, 2021
9f7d506
Add LCL files to our repo
Colengms May 4, 2021
fcc2817
Add missing comma
Colengms May 4, 2021
7359e06
Pass csigsPat to OneLocBuild
Colengms May 4, 2021
b0a367e
Revert pat change
Colengms May 4, 2021
6ea47e0
Switch to LCL files hosted by the loc team
Colengms May 5, 2021
258683f
Log detected changes preventing PR generation
Colengms May 5, 2021
d5ff732
Merge branch 'main' of https://github.com/microsoft/vscode-cpptools i…
Colengms May 5, 2021
a1c2296
Merge branch 'main' of https://github.com/microsoft/vscode-cpptools i…
Colengms May 6, 2021
75f0c25
Update OneLocBuild version to 2
Colengms May 6, 2021
c375c0a
Merge branch 'main' of https://github.com/microsoft/vscode-cpptools i…
Colengms May 6, 2021
a2ea15e
Set daily schedule
Colengms May 6, 2021
d452ba0
Remove logging of authToken
Colengms May 7, 2021
e22e409
Merge branch 'main' into coleng/new_loc_part2
Colengms May 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ browse*.db*
*.exe
*.ilk

# ignore exported localization xlf directory
# ignore exported localization xlf and LCL directories
Build/loc/LCL
vscode-extensions-localization-export

# ignore imported localization xlf directory
Expand Down
5 changes: 3 additions & 2 deletions Build/loc/LocProject.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"LocItems": [
{
"SourceFile": "vscode-extensions-localization-export\\vscode-extensions\\vscode-cpptools.xlf",
"Languages": "cs;de;es;fr;it;ja;ko;pl;pt-BR;ru;tr;zh-Hans;zh-Hant"
"Languages": "cs;de;es;fr;it;ja;ko;pl;pt-BR;ru;tr;zh-Hans;zh-Hant",
"LclFile": "Build\\loc\\LCL\\{Lang}\\vscode-cpptools.xlf.lcl"
}
]
}
]
}
}
37 changes: 0 additions & 37 deletions Build/loc/TranslationsImport.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,26 @@ resources:

trigger: none
pr: none
schedules:
- cron: "0 7 * * *"
displayName: Daily 7 AM
branches:
include:
- main

pool:
vmImage: 'windows-latest'

steps:
- task: CmdLine@2
inputs:
script: 'cd Extension && yarn install'

- task: CmdLine@2
inputs:
script: 'cd ./Extension && yarn run translations-export && cd ..'

- task: OneLocBuild@1
- task: OneLocBuild@2
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
Expand All @@ -29,6 +39,12 @@ steps:
prSourceBranchPrefix: 'locfiles'
packageSourceAuth: 'patAuth'
patVariable: '$(OneLocBuildPat)'
LclSource: lclFilesfromPackage
LclPackageId: 'LCL-JUNO-PROD-VCPP'

- task: CmdLine@2
inputs:
script: 'cd Extension && node ./translations_auto_pr.js microsoft vscode-cpptools csigs $(csigsPat) csigs csigs@users.noreply.github.com "$(Build.ArtifactStagingDirectory)/loc" vscode-extensions-localization-export/vscode-extensions && cd ..'

- task: PublishBuildArtifacts@1
inputs:
Expand Down
52 changes: 30 additions & 22 deletions Extension/translations_auto_pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,33 @@ const pullRequestTitle = '[Auto] Localization - Translated Strings';

let repoOwner = process.argv[2];
let repoName = process.argv[3];
let locProjectName = process.argv[4];
let authUser = process.argv[5];
let authToken = process.argv[6];
let userFullName = process.argv[7];
let userEmail = process.argv[8];
let locRepoPath = process.argv[9];

if (!repoOwner || !repoName || !locProjectName || !authUser || !authToken || !userFullName || !userEmail || !locRepoPath) {
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`);
let authUser = process.argv[4];
let authToken = process.argv[5];
let userFullName = process.argv[6];
let userEmail = process.argv[7];
let locRootPath = process.argv[8];
let locSubPath = process.argv[9];

if (!repoOwner || !repoName || !authUser || !authToken || !userFullName || !userEmail || !locRootPath || !locSubPath) {
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`);
console.error(` repo_owner - The owner of the repo on GitHub. i.e. microsoft`);
console.error(` repo_name - The name of the repo on GitHub. i.e. vscode-cpptools`);
console.error(` auth_user - User account wiith permission to post a pull request against the GitHub repo.`);
console.error(` auth_token - A PAT associated with auth_user.`);
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.)`);
console.error(` user_email - An email to associate with a git commit. (This is replaced by the PR account if commit is squashed.)`);
console.error(` loc_root_path - The path to the folder with language-specific directories (containing localized xlf files).`);
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.)`);
return;
}

console.log(`repoOwner=${repoOwner}`);
console.log(`repoName=${repoName}`);
console.log(`locProjectName=${locProjectName}`);
console.log(`authUser=${authUser}`);
console.log(`authToken=${authToken}`);
console.log(`locRepoPath=${locRepoPath}`);
console.log(`userFullName=${userFullName}`);
console.log(`userEmail=${userEmail}`);
console.log(`locRootPath=${locRootPath}`);
console.log(`locSubPath=${locSubPath}`);

function hasBranch(branchName) {
console.log(`Checking for existance of branch "${branchName}" (git branch --list ${branchName})`);
Expand All @@ -50,7 +59,10 @@ function hasAnyChanges() {
let lines = output.toString().split("\n");
let anyChanges = false;
lines.forEach(line => {
anyChanges = anyChanges || (line != '');
if (line != '') {
console.log("Change detected: " + line);
anyChanges = true;
}
});

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

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

console.log("Checking if there is already a pull request...");
const octokit = new Octokit({auth: {
username: authUser,
password: authToken}
});
const octokit = new Octokit.Octokit({auth: authToken});
octokit.pulls.list({ owner: repoOwner, repo: repoName }).then(({data}) => {
let alreadyHasPullRequest = false;
if (data) {
Expand Down