-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bring in localization into the API #158213
Comments
Is it possible to see which language is currently being used via the API? Does anything need to be changed in an extension based on Left to Right languages (e.g. English) verses Right to Left languages (e.g. Arabic)? The main case I tend to see is layout, for example if there is a custom rendered view. |
VS Code doesn't support RTL: #11770 and I suspect that idea of LTR vs RTL would come in as an API separate to this proposal. |
I see:
With |
Yes.
Yes. This is what happens today and will continue to happen.
Not at this time. We are aligning to what
Yes but I think there's enough value here:
|
Updates from UX sync:
|
Ok I have been playing with this a lot today… and here’s what I’d like to run:
|
Moving to Oct and marking finalization. This has 2 TPIs associated with it: |
api-notes
|
This isn't so simple. What does the change to the API proposal look like to support this?
Some scenarios:
I think that: |
I agree with that. Could we be more strict and spec the var-args to not be |
I adopted this in GHPRI, ran into an issue, and discussed with @TylerLeonhardt. Posting here for API discussion: const pr: PullRequestModel | undefined = await this.manager.getMatchingPullRequestMetadataFromGitHub(branch.upstream?.remote, branch.upstream?.name);
if (pr && (pr.model.state !== GithubItemStateEnum.Open)) {
const mergedMessage = vscode.l10n.t('The pull request for {0} has been merged. Do you want to create a new branch?', branch.name); I ended up with the following compile error:
I assumed this was just a breaking API change so updated my loc API usage to this: const mergedMessage = vscode.l10n.t('The pull request for {0} has been merged. Do you want to create a new branch?', [branch.name]); @TylerLeonhardt saw this and commented that it's not the usual pattern for templates with a variable number of arguments. |
|
vscode-nls
and it's build time companionvscode-nls-dev
has existed for quite a while now... and in its original design it was very filepath driven. We felt this pain when bundling extensions became the norm and introduced a webpack loader and bundler that baked filepaths into source code...That mitigation of rewriting JS code worked... but this all became more complicated when talking about the web because the web has no "nice" way of loading strings synchronously. And even if there was such a nice thing, we wouldn't want synchronous loading from the internet... so instead we are moving in a direction where Core is responsible for loading the bundle of strings for an extension, asynchronously, before an extension is loaded and then those strings are provided to the extension via an API.
In addition to this, we will have an additional field in the package.json:
nlsBundleLocation
which is at the root next tomain
andbrowser
. This is useful for:Important definitions:
message
: themessage
parameter is the English string. This is used for a few things:options
: This follows the same format we have when you wanna add a comment in a package.nls.json. Thecomment
array will be an array of comments that will be included in the exported XLF files (the files sent to translators). Themessage
is the same as defined above.i18n.contents
: This will contain the key-value pairs of the strings that VS Code loaded. This is useful if you want to pass a subprocess, a web worker, or a webview the contents of the bundle so that that environment can have all the translations that are currently being usedi18n.uri
: This will contain theUri
to the bundle that was loaded. This is useful if you want to pass a subprocess, a web worker, or a webview the Uri of the bundle so that that environment can load the translations that are currently being used.Along side of this work, we will ship a very small helper package called
@vscode/nls
or something like that that can be given thecontents
oruri
value and load the bundle and handle string interpolation. This library will really only be used for subprocesses/workers/webviews that can't depend on thevscode
API directly.@vscode/nls
Current API proposal:
@vscode/nls-dev
This is a CLI & library for managing the usages of
vscode.env.nls
. It has two main usecases:package.nls.*.json
andbundle.nls.*.json
filesIt currently has three commands:
The text was updated successfully, but these errors were encountered: