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

docs: Add new language guide. #158

Merged
merged 5 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
74 changes: 74 additions & 0 deletions docs/add-new-language.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Add a new language

## 1) Add locale

Only Unicode CLDR supported locales can be used. See the entire list here:
https://github.com/unicode-org/cldr/tree/main/common/annotations

Once you have a locale, add the locale in kebab-case to the following files:

- `packages/core/src/types.ts` (to `Locale` type)
- `packages/core/src/constants.ts` (to `SUPPORTED_LOCALES` constant)
- `website/src/components/Filters.tsx` (to `LOCALES` constant)
- `.github/workflows/build.yml` (to `locale` matrix)

And then re-build packages:

```shell
yarn run build
```

## 2) Create translation files

Translations are powered by `.po` (and `.pot`) files. If you're unfamiliar with PO, view the
official documentation here: https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html

Begin by copying the `po/base` folder to `po/<locale>`.

The `messages.po` file is required, and all messages must be translated before moving onto the next
step. We suggest using [Poedit](https://poedit.net/) for translating `.po` files.

The `shortcodes.po` file is optional and can be skipped. This file can be used to provide custom
shortcodes for the emojibase preset.

## 3) Generate data files

Once translations have been made, we can generate the data files. This may take a while, so be sure
to let the command keep running until completion.

```
yarn run generate
```

> A lot of information will be logged to the console, this is normal. However, please scan all logs
> for any warnings and errors. If easily fixable, feel free to fix, otherwise report an issue!

If generation completed successfully, you should see the `packages/data/<locale>` directory with a
handful of files.

## 4) Verify data files

Although data files were generated, we should manually verify that the data is correct.

- Ensure that there's no empty strings in every `*.raw.json` file.
- This is as simple as searching for `""` in the file.
- The `emoji` and `text` fields in `data.raw.json` can be empty.
- Ensure that `label` in `compact.raw.json` and `data.raw.json` align with your locale.
- These translations are provided by CLDR and cannot be changed.
- If there are missing labels, then this language/locale _will not be supported_ until CLDR is
complete.
- Ensure that `message` in `messages.raw.json` align with the translations from
`po/<locale>/messages.po`.
- Optional: Ensure that shortcodes in `shortcodes/emojibase.raw.json` align with the translations
from `po/<locale>/shortcodes.po`.

## 5) Create pull request

Once verified, add the following files to git:

- `po/<locale>/*.po`
- `packages/data/<locale>/**/*.raw.json`

And then create a pull request!

> Please limit 1 locale per PR, otherwise we will not accept it.
Loading