Created
April 26, 2019 00:13
-
-
Save sh1ch/4285321e8c85008131946e37402b33dd to your computer and use it in GitHub Desktop.
Visual Studio Code 拡張機能のローカライズ設定
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project | |
|-package.json | |
|-package.nls.json | |
|-package.nls.ja.json | |
|-tsconfig.json | |
|-src | |
| |-extension.ts | |
| |-lang | |
| |-localization.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// サンプルコード部 | |
import * as vscode from 'vscode'; | |
import { localeText } from './lang/localization'; | |
import { replaceText } from './core/text'; | |
export function activate(context: vscode.ExtensionContext) | |
{ | |
console.log(localeText("menu-title")); | |
context.subscriptions.push(disposable); | |
} | |
export function deactivate() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import localeEn from "../../package.nls.json"; | |
import localeJa from "../../package.nls.ja.json"; | |
interface ILocaleEntry | |
{ | |
[key : string] : string; | |
} | |
const localeTableKey = <string>JSON.parse(<string>process.env.VSCODE_NLS_CONFIG).locale; | |
const localeTable = Object.assign(localeEn, ((<{[key : string] : ILocaleEntry}> | |
{ | |
ja : localeJa | |
})[localeTableKey] || { })); | |
export const localeText = (key : string) : string => localeTable[key] || key; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
... | |
"main": "./out/src/extension.js", | |
"contributes": { | |
// サンプル部分 | |
"commands": [ | |
{ | |
"command": "extension.sample", | |
"title": "%menu-title%" | |
} | |
] | |
}, | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"menu-title": "サンプル名", | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"menu-title": "sample name", | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"resolveJsonModule": true, | |
"esModuleInterop": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment