Add language customization flag (#7374)

This allows you to customize any string (that has a translation) or add your own translations.
This commit is contained in:
Alex Strick van Linschoten
2025-07-15 22:38:27 +02:00
committed by GitHub
parent 8b3d9b9e0a
commit 92fca0dcc3
8 changed files with 471 additions and 23 deletions

View File

@ -22,6 +22,9 @@
- [Proxying to a Svelte app](#proxying-to-a-svelte-app)
- [Prefixing `/absproxy/<port>` with a path](#prefixing-absproxyport-with-a-path)
- [Preflight requests](#preflight-requests)
- [Internationalization and customization](#internationalization-and-customization)
- [Available keys and placeholders](#available-keys-and-placeholders)
- [Legacy flag](#legacy-flag)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
<!-- prettier-ignore-end -->
@ -458,3 +461,45 @@ By default, if you have auth enabled, code-server will authenticate all proxied
requests including preflight requests. This can cause issues because preflight
requests do not typically include credentials. To allow all preflight requests
through the proxy without authentication, use `--skip-auth-preflight`.
## Internationalization and customization
code-server allows you to provide a JSON file to configure certain strings. This can be used for both internationalization and customization.
Create a JSON file with your custom strings:
```json
{
"WELCOME": "Welcome to {{app}}",
"LOGIN_TITLE": "{{app}} Access Portal",
"LOGIN_BELOW": "Please log in to continue",
"PASSWORD_PLACEHOLDER": "Enter Password"
}
```
Then reference the file:
```shell
code-server --i18n /path/to/custom-strings.json
```
Or this can be done in the config file:
```yaml
i18n: /path/to/custom-strings.json
```
You can combine this with the `--locale` flag to configure language support for both code-server and VS Code in cases where code-server has no support but VS Code does. If you are using this for internationalization, please consider sending us a pull request to contribute it to `src/node/i18n/locales`.
### Available keys and placeholders
Refer to [../src/node/i18n/locales/en.json](../src/node/i18n/locales/en.json) for a full list of the available keys for translations. Note that the only placeholders supported for each key are the ones used in the default string.
The `--app-name` flag controls the `{{app}}` placeholder in templates. If you want to change the name, you can either:
1. Set `--app-name` (potentially alongside `--i18n`)
2. Use `--i18n` and hardcode the name in your strings
### Legacy flag
The `--welcome-text` flag is now deprecated. Use the `WELCOME` key instead.