Skip to content

Support extension specific default language#178

Open
wdhongtw wants to merge 1 commit intomicrosoft:mainfrom
wdhongtw:feat-ext-l10n-default
Open

Support extension specific default language#178
wdhongtw wants to merge 1 commit intomicrosoft:mainfrom
wdhongtw:feat-ext-l10n-default

Conversation

@wdhongtw
Copy link

Allow extension owner to choose the language of untranslated string when using the builtin l10n API.
Update CLI tool to support additional schema for l10n in package.json.

For motivation of this PR, please refer to microsoft/vscode#168127.

Proposed Solution

To support additional format, a format that specify default-lang and l10n string bundle path
at the same time, that is:

{
    "l10n": {
        "location": "./l10n",
        "defaultLocale": "en"
    }
}

We introduce two change

  1. Adjust the logic for deciding the l10n bundle path, (in @vscode/l10n-dev export command)
  2. Introduce default-lang concept and related logic, (in @vscode/l10n-dev generate-xlf command)

And to be backward compatible the change still cover the original format.

The --language flag for generate-xlf still have a default value en, but the semantic now
becomes the fallback language when there is no default-lang in package.json.

How to Verify

Prepare Extension

Write a extension that

  1. use vscode.l10n.t to translate a string.
  2. specify l10n.defaultLocale other than en

(I prepare a sample extension at https://github.com/wdhongtw/try-plugin, where the default-lang is ja Japanese.)

Verify CLI Tool

Compile and run the tool (installed or not) in the root folder of sample extension.

<tool> export: The command do success, and a file l10n/bundle.l10n.json be generated.
<tool> generate-xlf: The command do success, the source-language in xlf file be consistent with the setting in package.json.

Allow extension owner to choose the language of untranslated string
when using the builtin l10n API.

Update CLI tool to support additional schema for l10n in package.json.
@wdhongtw wdhongtw changed the title Support extension specific default language (microsoft#168127) Support extension specific default language Jan 22, 2025
@wdhongtw wdhongtw force-pushed the feat-ext-l10n-default branch from 62fc2d1 to 70ba035 Compare January 22, 2025 18:23
@wdhongtw
Copy link
Author

I'm afraid that I can not came out a good sentence for the argument description in

		yargs.option('language', {
			alias: 'l',
			string: true,
			default: 'en',
			describe: 'The source language that will be written to the XLF file.'
		});

The description should be changed, but need some suggestion from people with fluent English. :(

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.

1 participant