Skip to content

Commit

Permalink
Merge pull request #215 from CodinGame/l10n
Browse files Browse the repository at this point in the history
Localization
  • Loading branch information
CGNonofr authored Oct 20, 2023
2 parents 6c07e16 + 8eef44a commit 275778b
Show file tree
Hide file tree
Showing 37 changed files with 1,004 additions and 117 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
vscode/
vscode-loc/
vscode-default-extensions/
dist/
monaco-editor-treemending.patch
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,27 @@ plugins: [
import './extension.vsix'
```

### Localization

This library also offers the possibility to localize vscode and the extensions in the supported languages. To do so, import one of the following packages before anything else:
- `@codingame/monaco-vscode-language-pack-cs`
- `@codingame/monaco-vscode-language-pack-de`
- `@codingame/monaco-vscode-language-pack-es`
- `@codingame/monaco-vscode-language-pack-fr`
- `@codingame/monaco-vscode-language-pack-it`
- `@codingame/monaco-vscode-language-pack-ja`
- `@codingame/monaco-vscode-language-pack-ko`
- `@codingame/monaco-vscode-language-pack-pl`
- `@codingame/monaco-vscode-language-pack-pt-br`
- `@codingame/monaco-vscode-language-pack-qps-ploc`
- `@codingame/monaco-vscode-language-pack-ru`
- `@codingame/monaco-vscode-language-pack-tr`
- `@codingame/monaco-vscode-language-pack-zh-hans`
- `@codingame/monaco-vscode-language-pack-zh-hant`

⚠️ The language pack should be imported and loaded BEFORE anything else from monaco-editor or this library is loaded. Otherwise, some translations would be missing. ⚠️


### Demo

Try it out on https://codingame.github.io/monaco-vscode-api/
Expand Down
21 changes: 20 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ <h1>Editor</h1>
<br />
<button id="togglePanel">Toggle Panel</button>
<button id="toggleAuxiliary">Toggle Secondary Panel</button>
<br />
<label for="localeSelect">Language:</label>
<select id="localeSelect">
<option value="">English</option>
<option value="cs">Czech</option>
<option value="de">German</option>
<option value="es">Spanish</option>
<option value="fr">French</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
<option value="ko">Korean</option>
<option value="pl">Polish</option>
<option value="pt-br">Portuguese (Brazil)</option>
<option value="qps-ploc">Pseudo Language</option>
<option value="ru">Russian</option>
<option value="tr">Turkish</option>
<option value="zh-hans">Chinese (Simplified)</option>
<option value="zh-hant">Chinese (Traditional)</option>
</select>
</div>
<div style="border: 1px solid var(--vscode-editorWidget-border); width: 300px; height: 800px" id="auxiliaryBar"></div>
</div>
Expand All @@ -41,6 +60,6 @@ <h1>Keybindings</h1>
<button id="keybindingsui">Open keybindings UI</button>
<div id="keybindings-editor" class="standalone-editor"></div>
</div>
<script type="module" src="/src/main.ts"></script>
<script type="module" src="/src/loader.ts"></script>
</body>
</html>
187 changes: 185 additions & 2 deletions demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@
"@codingame/monaco-vscode-julia-default-extension": "file:../dist/default-extension-julia",
"@codingame/monaco-vscode-keybindings-service-override": "file:../dist/service-override-keybindings",
"@codingame/monaco-vscode-language-detection-worker-service-override": "file:../dist/service-override-language-detection-worker",
"@codingame/monaco-vscode-language-pack-cs": "file:../dist/vscode-language-pack-cs",
"@codingame/monaco-vscode-language-pack-de": "file:../dist/vscode-language-pack-de",
"@codingame/monaco-vscode-language-pack-es": "file:../dist/vscode-language-pack-es",
"@codingame/monaco-vscode-language-pack-fr": "file:../dist/vscode-language-pack-fr",
"@codingame/monaco-vscode-language-pack-it": "file:../dist/vscode-language-pack-it",
"@codingame/monaco-vscode-language-pack-ja": "file:../dist/vscode-language-pack-ja",
"@codingame/monaco-vscode-language-pack-ko": "file:../dist/vscode-language-pack-ko",
"@codingame/monaco-vscode-language-pack-pl": "file:../dist/vscode-language-pack-pl",
"@codingame/monaco-vscode-language-pack-pt-br": "file:../dist/vscode-language-pack-pt-BR",
"@codingame/monaco-vscode-language-pack-qps-ploc": "file:../dist/vscode-language-pack-qps-ploc",
"@codingame/monaco-vscode-language-pack-ru": "file:../dist/vscode-language-pack-ru",
"@codingame/monaco-vscode-language-pack-tr": "file:../dist/vscode-language-pack-tr",
"@codingame/monaco-vscode-language-pack-zh-hans": "file:../dist/vscode-language-pack-zh-hans",
"@codingame/monaco-vscode-language-pack-zh-hant": "file:../dist/vscode-language-pack-zh-hant",
"@codingame/monaco-vscode-languages-service-override": "file:../dist/service-override-languages",
"@codingame/monaco-vscode-latex-default-extension": "file:../dist/default-extension-latex",
"@codingame/monaco-vscode-layout-service-override": "file:../dist/service-override-layout",
Expand Down Expand Up @@ -162,4 +176,4 @@
"node": "18.18.0",
"npm": "9.8.1"
}
}
}
7 changes: 2 additions & 5 deletions demo/src/features/remoteExtension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ExtensionHostKind, registerExtension } from 'vscode/extensions'
import manifest from './remoteExtensionExample/package.json'
import { registerRemoteExtension } from 'vscode/extensions'

declare global {
interface Window {
Expand All @@ -8,7 +7,5 @@ declare global {
}

if (window.rootDirectory != null) {
registerExtension(manifest, ExtensionHostKind.Remote, {
path: `${window.rootDirectory}/src/features/remoteExtensionExample/`
})
registerRemoteExtension(`${window.rootDirectory}/src/features/remoteExtensionExample/`)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Hello from remote extension running from {0}!": "Hallo von der entfernten Nebenstelle, die auf {0} läuft!"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Hello from remote extension running from {0}!": "Bonjour depuis l'extension distante tournant sur {0}!"
}
11 changes: 7 additions & 4 deletions demo/src/features/remoteExtensionExample/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const vscode = require('vscode')
const os = require("os")
const os = require('os')

void vscode.window.showInformationMessage('Hello', {
detail: `Hello from remote extension running from ${os.hostname()}`,
modal: true
vscode.commands.registerCommand('prompt-hello', () => {
void vscode.window.showInformationMessage('Hello', {
detail: vscode.l10n.t('Hello from remote extension running from {0}!', os.hostname()),
modal: true
})
})

vscode.commands.executeCommand('prompt-hello')
11 changes: 10 additions & 1 deletion demo/src/features/remoteExtensionExample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,14 @@
"engines": {
"vscode": "*"
},
"main": "./main.js"
"l10n": "./l10n",
"main": "./main.js",
"browser": "./main.js",
"contributes": {
"commands": [{
"command": "prompt-hello",
"title": "%prompt-hello%",
"category": "Custom"
}]
}
}
3 changes: 3 additions & 0 deletions demo/src/features/remoteExtensionExample/package.nls.de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"prompt-hello": "Hallo sagen von der entfernten Nebenstelle"
}
3 changes: 3 additions & 0 deletions demo/src/features/remoteExtensionExample/package.nls.fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"prompt-hello": "Dire bonjour depuis l'extension distante"
}
3 changes: 3 additions & 0 deletions demo/src/features/remoteExtensionExample/package.nls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"prompt-hello": "Prompt hello from remote extension"
}
Loading

0 comments on commit 275778b

Please sign in to comment.