vscode-nls

npm module to support externalization and localization of VSCode extensions.

  • 所有者: microsoft/vscode-nls
  • 平台:
  • 許可證: Other
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

vscode-nls

CommonJS module to support externalization and localization. The module only depends on Node.js however its
primary use case is for VSCode extensions.

Build Status
NPM Version
NPM Downloads

Usage

import * as nls from 'vscode-nls';

let localize = nls.config({ locale: 'de-DE' })();

console.log(localize('keyOne', "Hello World"));
console.log(localize('keyTwo', "Current Date {0}", Date.now()));

The config call configures the nls module and should only be called once in the applications entry point. You pass in the locale you want to use and whether the resolved locale should be cached for all further calls. The config call returns a function which is used to load a message bundle. During development time the argument should stay empty. There is another tool that helps extracting the message from your sources and it creates the message bundles autmatically for you. The tool is available here.

In secondary modules loaded from the 'main' module no configuration is necessary. However you still need to load the nls module and load the message bundle. This looks like this:

import * as nls from 'vscode-nls';

let localize = nls.loadMessageBundle();

console.log(localize('keyOne', "Hello World"));

During development time the strings in the code are presented to the user. If the locale is set to 'pseudo' the messages are modified in the following form:

  • vowels are doubled
  • the string is prefixed with '\uFF3B' (Unicode zenkaku representation for [) and postfixed with '\uFF3D' (Unicode zenkaku representation for ])

History

4.1.1

4.1.0

  • support language and locale when resolving options from VSCODE_NLS_CONFIG setting.

4.0.0

  • make vscode-nls webpack friendly (removal of require calls)
  • narrow type for var args in localize function to string, number, boolean, null, undefined

3.0.0:

  • added support to bundle the strings into a single nls.bundle(.${locale})?.json file.
  • added support for VS Code language packs.

2.0.2:

  • moved to TypeScript 2.1.5. Adapted to @types d.ts files instead of including typings directly into the repository.

2.0.1:

  • based on TypeScritp 2.0. Since TS changed the shape of the d.ts files for 2.0.x a major version number got introduce to not
    break existing clients using TypeScript 1.8.x.

LICENSE

MIT

主要指標

概覽
名稱與所有者microsoft/vscode-nls
主編程語言TypeScript
編程語言TypeScript (語言數: 2)
平台
許可證Other
所有者活动
創建於2016-02-02 11:47:44
推送於2023-08-21 10:14:19
最后一次提交
發布數6
最新版本名稱release/5.0.0-next.1 (發布於 )
第一版名稱release/3.2.2 (發布於 2018-03-12 10:05:46)
用户参与
星數94
關注者數48
派生數31
提交數95
已啟用問題?
問題數28
打開的問題數9
拉請求數12
打開的拉請求數4
關閉的拉請求數7
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?