ente/web/docs/translations.md

47 lines
1.8 KiB
Markdown
Raw Normal View History

2024-03-11 09:50:52 +00:00
# Translations
We use Crowdin for translations, and the `i18next` library to load these at
runtime.
Within our project we have the _source_ strings - these are the key value pairs
2024-04-06 06:00:31 +00:00
in the `packages/next/locales/en-US/translation.json` file.
2024-03-11 09:50:52 +00:00
Volunteers can add a new _translation_ in their language corresponding to each
2024-04-03 08:03:42 +00:00
such source key-value to our
[Crowdin project](https://crowdin.com/project/ente-photos-web).
2024-03-11 09:50:52 +00:00
Everyday, we run a [GitHub workflow](../../.github/workflows/web-crowdin.yml)
that
2024-04-03 08:03:42 +00:00
- Uploads sources to Crowdin - So any new key value pair we add in the source
`translation.json` becomes available to translators to translate.
2024-03-11 09:50:52 +00:00
2024-04-03 08:03:42 +00:00
- Downloads translations from Crowdin - So any new translations that
translators have made on the Crowdin dashboard (for existing sources) will
be added to the corresponding `lang/translation.json`.
2024-03-11 09:50:52 +00:00
The workflow also uploads existing translations and also downloads new sources
from Crowdin, but these two should be no-ops.
## Adding a new string
2024-04-06 06:00:31 +00:00
- Add a new entry in `packages/next/locales/en-US/translation.json` (the
**source `translation.json`**).
2024-04-03 08:03:42 +00:00
- Use the new key in code with the `t` function
(`import { t } from "i18next"`).
- During the next sync, the workflow will upload this source item to Crowdin's
dashboard, allowing translators to translate it.
2024-03-11 09:50:52 +00:00
## Updating an existing string
2024-04-03 08:03:42 +00:00
- Update the existing value for the key in the source `translation.json`.
- During the next sync, the workflow will clear out all the existing
translations so that they can be translated afresh.
2024-03-11 09:50:52 +00:00
## Deleting an existing string
2024-04-03 08:03:42 +00:00
- Remove the key value pair from the source `translation.json`.
- During the next sync, the workflow will delete that source item from all
existing translations (both in the Crowdin project and also from the he
other `lang/translation.json` files in the repository).