Allow pulling in external extension translations from somewhere else (#176090)

allow pulling in external extension translations from somewhere else

This will allow js-debug to push its strings to the extension localization repo and then we will grab the translated strings from there.
This commit is contained in:
Tyler James Leonhardt 2023-03-03 13:15:28 -08:00 committed by GitHub
parent 529fa01576
commit 8ddd3bcf39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 9 deletions

File diff suppressed because one or more lines are too long

View file

@ -644,7 +644,7 @@ function createL10nBundleForExtension(extensionFolderName: string, prefixWithBui
}));
}
const EXTERNAL_EXTENSIONS = [
export const EXTERNAL_EXTENSIONS = [
'ms-vscode.js-debug',
'ms-vscode.js-debug-companion',
'ms-vscode.vscode-js-profile-table',
@ -844,7 +844,8 @@ export function prepareI18nPackFiles(resultingTranslationPaths: TranslationPath[
const errors: any[] = [];
return through(function (this: ThroughStream, xlf: File) {
const project = path.basename(path.dirname(path.dirname(xlf.relative)));
const resource = path.basename(xlf.relative, '.xlf');
// strip `-new` since vscode-extensions-loc uses the `-new` suffix to indicate that it's from the new loc pipeline
const resource = path.basename(path.basename(xlf.relative, '.xlf'), '-new');
const contents = xlf.contents.toString();
log(`Found ${project}: ${resource}`);
const parsePromise = getL10nFilesFromXlf(contents);

View file

@ -23,6 +23,10 @@ function update(options) {
if (location !== undefined && !fs.existsSync(location)) {
throw new Error(`${location} doesn't exist.`);
}
let externalExtensionsLocation = options.externalExtensionsLocation;
if (externalExtensionsLocation !== undefined && !fs.existsSync(location)) {
throw new Error(`${externalExtensionsLocation} doesn't exist.`);
}
let locExtFolder = idOrPath;
if (/^\w{2,3}(-\w+)?$/.test(idOrPath)) {
locExtFolder = path.join('..', 'vscode-loc', 'i18n', `vscode-language-pack-${idOrPath}`);
@ -67,7 +71,10 @@ function update(options) {
console.log(`Importing translations for ${languageId} form '${location}' to '${translationDataFolder}' ...`);
let translationPaths = [];
gulp.src(path.join(location, '**', languageId, '*.xlf'), { silent: false })
gulp.src([
path.join(location, '**', languageId, '*.xlf'),
...i18n.EXTERNAL_EXTENSIONS.map(extensionId => path.join(externalExtensionsLocation, extensionId, languageId, '*-new.xlf'))
], { silent: false })
.pipe(i18n.prepareI18nPackFiles(translationPaths))
.on('error', (error) => {
console.log(`Error occurred while importing translations:`);
@ -94,7 +101,7 @@ function update(options) {
}
if (path.basename(process.argv[1]) === 'update-localization-extension.js') {
var options = minimist(process.argv.slice(2), {
string: 'location'
string: ['location', 'externalExtensionsLocation']
});
update(options);
}