-
Notifications
You must be signed in to change notification settings - Fork 0
Translation & l18n
Thank you for helping translate HA Menstruation Cycle! This guide explains how to contribute a translation for Swedish (sv), French (fr), Spanish (es), or any other language.
| Language | Frontend (www/translations/) |
Backend (translations/) |
Status |
|---|---|---|---|
| π¬π§ English | β
en.json
|
β
en.json
|
100% |
| π©πͺ German | β
de.json
|
β
de.json
|
100% |
| πΈπͺ Swedish | β
sv.json (template) |
β
sv.json (template) |
100% |
| π«π· French | π‘ fr.json (template) |
π‘ fr.json (template) |
0% β Volunteers welcome! |
| πͺπΈ Spanish | π‘ es.json (template) |
π‘ es.json (template) |
0% β Volunteers welcome! |
git clone https://github.com/<your-username>/HA-menstrual-cycle.git
cd HA-menstrual-cycle
git checkout -b translation/sv # or fr / es / your-languageThere are two sets of files to translate:
Card UI strings (most important for end users):
custom_components/menstruation_cycle/www/translations/sv.json
This file contains ~428 keys used in the Lovelace dashboard cards. It is already populated with English text as a reference. Replace each English value with the translated text.
Backend strings (config flow, options, services):
custom_components/menstruation_cycle/translations/sv.json
This file contains the strings shown in the Home Assistant UI when setting up or configuring the integration. It has fewer keys (~40) and is lower priority if you want to start small.
Open the file in any text editor. Each line looks like:
"save": "Save",Replace the value on the right side with your translation:
"save": "Spara",Leave the key (left side) unchanged. Only change the value (right side, inside the second pair of quotes).
Some strings contain placeholders that are replaced at runtime. Do not translate or remove these.
| Placeholder | Meaning | Example |
|---|---|---|
{n} |
A number | "Last {n} days" |
{count} |
A count value | "{count} cycles" |
{value} |
A calculated value | "based on ~{value}/day" |
{days} |
A number of days | "for a {days}-day wash routine" |
Correct:
"last_n_days": "Senaste {n} dagarna",
"last_cycles": "{count} cykler"Incorrect (placeholder removed):
"last_n_days": "Senaste dagarna",
"last_cycles": "cykler"Make sure the file is valid JSON before submitting. You can use any of these methods:
# Python (built-in)
python3 -c "import json; json.load(open('custom_components/menstruation_cycle/www/translations/sv.json')); print('OK')"
# Node.js
node -e "require('./custom_components/menstruation_cycle/www/translations/sv.json'); console.log('OK')"
# Online validator
# https://jsonlint.com/Common mistakes to avoid:
- Trailing commas after the last key in an object
- Unescaped quotes inside strings (use
\"if a translation needs a literal quote) - Accidentally deleting a key or a brace
To see your translation in Home Assistant:
- Copy your translated
sv.json(orfr.json/es.json) into the running Home Assistant instance:custom_components/menstruation_cycle/www/translations/sv.json - Set your Home Assistant language to the matching locale (e.g.
svfor Swedish) under Profile β Language. - Clear your browser cache and reload the dashboard.
- The cards should now display your translated strings.
For backend strings, restart Home Assistant after copying the file to translations/sv.json.
- Commit your changes:
git add custom_components/menstruation_cycle/www/translations/sv.json git add custom_components/menstruation_cycle/translations/sv.json # if applicable git commit -m "feat(i18n): add Swedish (sv) translation" git push origin translation/sv
- Open a pull request against the
mainbranch on GitHub. - In the PR description, mention which language you translated and approximately what percentage is complete.
The www/translations/*.json file is divided into logical groups. You can focus on the most visible ones first:
| Key prefix / group | What it controls | Priority |
|---|---|---|
card_name, card_description
|
Card titles | High |
save, cancel, close, yes, no, β¦ |
Common UI actions | High |
pregnancy, period, fertile, ovulation, pms, β¦ |
Phase labels | High |
opt_* |
Symptom option labels (e.g. opt_light, opt_cramps) |
High |
cat_* |
Symptom category labels (e.g. cat_pain, cat_mood) |
High |
tab_* |
Statistics tab names | Medium |
nfp_* |
NFP analysis strings | Medium |
col_* |
Table column headers | Medium |
doctor_report_*, export_*
|
Doctor report UI | Low |
last_n_days, last_cycles, β¦ |
Template strings with {n} / {count}
|
High (keep placeholders!) |
If you want to add a language other than sv, fr, or es:
- Copy
www/translations/en.jsontowww/translations/<code>.json(use the two-letter ISO 639-1 code). - Copy
translations/en.jsontotranslations/<code>.json. - Follow the steps above to translate both files.
- Add the new language to the table at the top of this file.
If you are unsure about context, terminology, or how a string is used in the UI, open an issue or ask in the pull request. Screenshots or videos showing the string in context are always helpful.