|
1 |
| -# Transalation |
| 1 | +# Translation |
2 | 2 |
|
3 |
| -## How to update exists translation |
| 3 | +## Firmware |
4 | 4 |
|
5 |
| -1. Edit fw/data/i18n.csv with your favorite text editor. For vscode, extension "Edit csv" is recommended. |
6 |
| -2. Run `fw/scripts/i18n_gen.py` to generate new language files. |
7 |
| -3. Optional: Run `fw/scripts/font_data_gen.sh` to generate new font data if you add new charaters in i18n.csv |
8 |
| -4. Run `make full` rebuild firmware |
| 5 | +## How to update existing translation |
| 6 | + |
| 7 | +When editing CSV files with VSCode, the extension [Edit CSV](https://marketplace.visualstudio.com/items?itemName=janisdd.vscode-edit-csv) is recommended. |
| 8 | + |
| 9 | +**Windows** requires you to have [Python](https://www.python.org/downloads/) and [Git](https://git-scm.com/download/windows) installed and within your `$PATH` |
| 10 | +For **Linux**, most distributions come with `python` and `git` by default and **macOS** comes bundled with `python`, but to use `git` you either need to install the Command Line tools via `xcode-select –-install`, or download [Git](https://git-scm.com/download/mac) separately. |
| 11 | + |
| 12 | +### Windows |
9 | 13 |
|
10 |
| -note: <br /> |
11 |
| -The script `font_data_gen.sh` only can be run in Git Bash windows in Windows. |
| 14 | +1. Clone this repository |
| 15 | + `git clone https://github.com/solosky/pixl.js.git; cd pixl.js` |
| 16 | +2. Edit `fw/data/i18n.csv` |
| 17 | +3. Run `py.exe fw/scripts/i18n_gen.py` to generate new language files. |
| 18 | +4. _Optional:_ Run `py.exe fw/scripts/font_data_gen.py` to generate new font data if you add new characters in `i18n.csv` |
| 19 | +5. [Build the Firmware](03-Build-Firmware.md) |
| 20 | + |
| 21 | +### Linux and macOS |
| 22 | + |
| 23 | +1. Clone this repository |
| 24 | + `git clone https://github.com/solosky/pixl.js.git; cd pixl.js` |
| 25 | +2. Edit `fw/data/i18n.csv` |
| 26 | +3. Run `python3 fw/scripts/i18n_gen.py` to generate new language files. |
| 27 | +4. Optional: Run `python fw/scripts/font_data_gen.py` to generate new font data if you add new characters in `i18n.csv` |
| 28 | +5. [Build the Firmware](03-Build-Firmware.md) |
12 | 29 |
|
13 | 30 | ## How to add new language translation
|
14 | 31 |
|
15 |
| -1. Add new column in fw/data/i18n.csv, for example "ja_JP" |
| 32 | +The process is similar to updating an existing translation, and has the same requirements depending on your Operating System. |
| 33 | + |
| 34 | +1. Add new column in `fw/data/i18n.csv`, for example "ja_JP" |
16 | 35 | 2. Run `fw/scripts/i18n_gen.py` to generate new language files.
|
17 |
| -3. Optional: Run `fw/scripts/font_data_gen.sh` to generate new font data if you add new charaters in i18n.csv |
| 36 | +3. Optional: Run `fw/scripts/font_data_gen.py` to generate new font data if you add new characters in `i18n.csv` |
18 | 37 | 4. Edit `fw/application/src/i18n/language.h` and `fw/application/src/i18n/language.c` to adopt new language
|
19 | 38 | 5. Edit Makefile to include `$(PROJ_DIR)/i18n/ja_JP.c` as C source files
|
20 |
| -6. Run `make full` rebuild firmware |
| 39 | +6. [Build the Firmware](03-Build-Firmware.md) |
| 40 | + |
| 41 | +## Font notes |
| 42 | + |
| 43 | +For release builds (RELEASE=1), the firmware uses wenquanyi_9pt_u8g2.bdf to display unicode characters. |
| 44 | +Please check if the new language character codepoint is included in wenquanyi_9pt_u8g2.bdf or not. |
| 45 | +If not, it's not recommended supporting the new language due to the MCU internal flash restrictions. |
| 46 | + |
| 47 | +## Web App |
| 48 | + |
| 49 | +### How to update existing translation |
| 50 | + |
| 51 | +The language file can be found under `web/src/i18n' |
| 52 | + |
| 53 | +## How to add new language translation |
| 54 | + |
| 55 | +In this example, we will add a Japanese (ja_JP) translation: |
| 56 | + |
| 57 | +1. Copy the `en_US.js` file and name it `ja_JP.js` |
| 58 | +2. Translate the string within `ja_JP.js` including the `changeok` message. |
| 59 | + |
| 60 | + Don't translate the other language names. |
| 61 | + |
| 62 | + Add your language at the bottom of the `lang {` section: |
| 63 | + |
| 64 | + `ja: '日本語',` |
| 65 | + |
| 66 | +3. Edit `web/src/i18n/index.js` while keeping its current structure, adding: |
| 67 | + |
| 68 | + ```js |
| 69 | + import elementJaLocale from 'element-ui/lib/locale/lang/ja' // element-ui |
| 70 | + lang import jaLocale from './ja_JP' elementJpLocale |
| 71 | + ``` |
| 72 | + |
| 73 | + And extending `messages`: |
| 74 | + |
| 75 | + ```js |
| 76 | + ja_JP: { |
| 77 | + ...jaLocale, |
| 78 | + ...elementJaLocale, |
| 79 | + }, |
| 80 | + ``` |
| 81 | + |
| 82 | +4. Add your language to the other `.js` files (within the `lang: {` section): |
| 83 | + |
| 84 | + `vueja: '日本語',` |
21 | 85 |
|
22 |
| -## Font notes |
| 86 | +5. Add your language to the `web/src/App.vue` file: |
23 | 87 |
|
24 |
| -For release build (RELEASE=1), the firmware use wenquanyi_9pt_u8g2.bdf to display unicode characters. <br /> |
25 |
| -Please check new language charater codepoint is included in wenquanyi_9pt_u8g2.bdf or not.<br /> |
26 |
| -If not, I am not recommended to support the new language due to the MCU internal flash restrction. |
| 88 | +```js |
| 89 | +<el-dropdown-item Enabled="language==='ja'" command="ja" divided> |
| 90 | + {{ $t('lang.ja') }} |
| 91 | + </el-dropdown-item> |
| 92 | +``` |
0 commit comments