Skip to content

Commit 2be6311

Browse files
defguard-communitygitbook-bot
authored andcommitted
GITBOOK-344: change request with no subject merged in GitBook
1 parent 931c641 commit 2be6311

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

SUMMARY.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,15 @@
101101

102102
* [Contributing](for-developers/contributing.md)
103103
* [Environment setup](for-developers/dev-env-setup.md)
104-
* [Translations ( web )](for-developers/translations-web/README.md)
104+
* [Translations (core/web)](for-developers/translations-web/README.md)
105105
* [Switching language](for-developers/translations-web/switching-language.md)
106106
* [Adding translations](for-developers/translations-web/adding-translations.md)
107107

108+
***
109+
110+
* [Translations (client)](translations-client/README.md)
111+
* [Adding translations](translations-client/adding-translations.md)
112+
108113
## Contact us
109114

110115
* [Community & Support](contact-us/support.md)

translations-client/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Translations (client)
2+
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Adding translations
2+
3+
All locale files can be found under `src/i18n` in the [client repository](https://github.com/DefGuard/client). In order to add a new translation, you will need to create an appropriate folder in this directory. You can refer to the `en` locale as an example.
4+
5+
If you'd like to add a new locale, e.g. French, create an `fr` folder in the `src/i18n` directory and copy the `index.ts` file from the base (`en`) locale folder into your newly created `fr` directory. After copying the file, open it and change the locale name from `en` to `fr` as below:
6+
7+
```typescript
8+
/* eslint-disable no-irregular-whitespace */
9+
/* eslint-disable max-len */
10+
import type { BaseTranslation } from '../i18n-types';
11+
12+
const en = { // <-- change it to fr or other language code of your choice
13+
[...]
14+
} satisfies BaseTranslation;
15+
16+
export default en; // <-- change it to fr or other language code of your choice
17+
```
18+
19+
Now you can edit your index.ts file and translate its strings into the chosen language.
20+
21+
### Generating types
22+
23+
After every change in your translation you will have to generate the locale types in order for the locale to load properly. To do this, you will need to install some client dependencies: at least `typesafe-i18n` but ideally you should setup the whole client development environment in order to preview your translations. You can find the client development prerequisites in the client's readme: [https://github.com/DefGuard/client?tab=readme-ov-file#development](https://github.com/DefGuard/client?tab=readme-ov-file#development). You will also need to have some node package manager, we use `pnpm`.
24+
25+
The types can be generated by executing one of the following commands in the client directory:
26+
27+
```
28+
pnpm typesafe-i18n
29+
```
30+
31+
or
32+
33+
```
34+
pnpm tauri dev
35+
```
36+
37+
The first command only generates the required locale types, the second one runs the client along with UI hot reload, so you can observe your locale changes in real-time.
38+
39+
### Switching language
40+
41+
Currently client picks the locale based on the operating system's settings. There is no straightforward way to switch the locale in the client by hand, other than to hardcode different `detectedLocale` in `src/components/App/App.tsx` or change your operating system's language. This is a temporary shortcoming and will be changed in the future.
42+
43+
44+

0 commit comments

Comments
 (0)