Skip to content

Commit

Permalink
Revert "Fix incorrect locale value in argv.json (#171750)"
Browse files Browse the repository at this point in the history
This reverts commit 71a7c90.
  • Loading branch information
sandy081 committed Jan 23, 2023
1 parent 3b4727c commit 923e4cf
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo

private checkAndInstall(): void {
const language = platform.language;
let locale = platform.locale ?? '';
const locale = platform.locale ?? '';
const languagePackSuggestionIgnoreList = <string[]>JSON.parse(this.storageService.get(LANGUAGEPACK_SUGGESTION_IGNORE_STORAGE_KEY, StorageScope.APPLICATION, '[]'));

if (!this.galleryService.isEnabled()) {
Expand All @@ -108,12 +108,12 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo
return;
}

const fullLocale = locale;
let tagResult = await this.galleryService.query({ text: `tag:lp-${locale}` }, CancellationToken.None);
let searchLocale = locale;
let tagResult = await this.galleryService.query({ text: `tag:lp-${searchLocale}` }, CancellationToken.None);
if (tagResult.total === 0) {
// Trim the locale and try again.
locale = locale.split('-')[0];
tagResult = await this.galleryService.query({ text: `tag:lp-${locale}` }, CancellationToken.None);
searchLocale = locale.split('-')[0];
tagResult = await this.galleryService.query({ text: `tag:lp-${searchLocale}` }, CancellationToken.None);
if (tagResult.total === 0) {
return;
}
Expand All @@ -126,9 +126,9 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo
return;
}

Promise.all([this.galleryService.getManifest(extensionToFetchTranslationsFrom, CancellationToken.None), this.galleryService.getCoreTranslation(extensionToFetchTranslationsFrom, locale)])
Promise.all([this.galleryService.getManifest(extensionToFetchTranslationsFrom, CancellationToken.None), this.galleryService.getCoreTranslation(extensionToFetchTranslationsFrom, searchLocale)])
.then(([manifest, translation]) => {
const loc = manifest?.contributes?.localizations?.find(x => locale.startsWith(x.languageId.toLowerCase()));
const loc = manifest && manifest.contributes && manifest.contributes.localizations && manifest.contributes.localizations.find(x => locale.startsWith(x.languageId.toLowerCase()));
const languageName = loc ? (loc.languageName || locale) : locale;
const languageDisplayName = loc ? (loc.localizedLanguageName || loc.languageName || locale) : locale;
const translationsFromPack: { [key: string]: string } = translation?.contents?.['vs/workbench/contrib/localization/electron-sandbox/minimalTranslations'] ?? {};
Expand Down Expand Up @@ -162,7 +162,7 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo
this.paneCompositeService.openPaneComposite(EXTENSIONS_VIEWLET_ID, ViewContainerLocation.Sidebar, true)
.then(viewlet => viewlet?.getViewPaneContainer() as IExtensionsViewPaneContainer)
.then(viewlet => {
viewlet.search(`tag:lp-${locale}`);
viewlet.search(`tag:lp-${searchLocale}`);
viewlet.focus();
});
}
Expand All @@ -188,7 +188,7 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo
label: localize('neverAgain', "Don't Show Again"),
isSecondary: true,
run: () => {
languagePackSuggestionIgnoreList.push(fullLocale);
languagePackSuggestionIgnoreList.push(locale);
this.storageService.store(
LANGUAGEPACK_SUGGESTION_IGNORE_STORAGE_KEY,
JSON.stringify(languagePackSuggestionIgnoreList),
Expand All @@ -210,8 +210,11 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo

private async isLocaleInstalled(locale: string): Promise<boolean> {
const installed = await this.extensionManagementService.getInstalled();
return installed.some(i => !!i.manifest.contributes?.localizations?.length
&& i.manifest.contributes.localizations.some(l => locale.startsWith(l.languageId.toLowerCase())));
return installed.some(i => !!(i.manifest
&& i.manifest.contributes
&& i.manifest.contributes.localizations
&& i.manifest.contributes.localizations.length
&& i.manifest.contributes.localizations.some(l => locale.startsWith(l.languageId.toLowerCase()))));
}

private installExtension(extension: IGalleryExtension): Promise<void> {
Expand Down

0 comments on commit 923e4cf

Please sign in to comment.