Skip to content
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

Localization #215

Merged
merged 28 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7fe2e0a
refactor: compute location sooner
Oct 19, 2023
41da985
fix: properly use variable
Oct 19, 2023
fc2cbcc
fix: make sure to not keep monaco deleted files
Oct 19, 2023
4037bf4
fix: handle deleted files in treemending script
Oct 19, 2023
d518512
feat: download vscode-loc as well
Oct 19, 2023
d225608
feat: add setLocale method in monaco nls
Oct 19, 2023
4c117a0
feat: replace localize calls to localizeWithPath
Oct 19, 2023
9455c5f
fix: do not encode URL
Oct 19, 2023
2ee7b08
feat: stop removing some stuff from vscode
Oct 19, 2023
ad53b82
feat: add l20n entrypoint to register a localization
Oct 19, 2023
422317f
feat: add some tools
Oct 19, 2023
e4f38c3
feat: update rollup plugin to stop translating manifest at build time…
Oct 19, 2023
755321f
fix: fix extension sometime not registered
Oct 19, 2023
11794fa
feat: translate extension manifests as in vscode
Oct 19, 2023
36797b5
feat: build language packs
Oct 19, 2023
9a68c40
fix(demo): prevent webview background from being white on system dark…
Oct 19, 2023
3c85754
fix(demo): disable remote extension if there is no remote authority
Oct 19, 2023
0d1f9b0
feat(demo): install language packs
Oct 19, 2023
01046d0
feat(demo): load language pack from url param
Oct 19, 2023
614581d
feat(demo): add locale selector
Oct 19, 2023
81c856f
feat: take bundle file into account
Oct 19, 2023
62761f5
feat: add a simpler way to register remote extension
Oct 19, 2023
9ca9686
feat(demo): use new way to register remote extension
Oct 19, 2023
657d37d
feat(demo): demonstrate extension localization
Oct 19, 2023
3dfbc6f
chore: update documentation
Oct 19, 2023
ca51bbc
fix(demo): update package-lock
Oct 20, 2023
6add271
fix: fix treemending script for other timezones
Oct 20, 2023
8eef44a
fix(demo): fix vite not liking that await for some reasons
Oct 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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