Translating project lifecycle state labels
Project lifecycle states (Planning, Request funding, Running, etc.) are stored as rows in project_states with a stable code (e.g. planning, running) and a label (default display text). The UI translates the text part by using the code as the i18n key, so you can add locale-specific labels without changing the database.
For general UI translation (navigation, messages, etc.), see Translating the UI.
How it works
- Stable key:
project_state.<code>(e.g.project_state.planning,project_state.running). - Templates use the
translate_project_stateJinja filter; the app callstranslate_project_state_label()which uses Flask-Babelgettext(key). If there is no translation for the key, the DB label (or code) is shown. - Default (English) labels come from the database (seeded by migrations from
LIFECYCLE_STATESinapp.models.project_state).
Adding translations
-
Extract messages (if not already):
pybabel extract -F babel.cfg -o messages.pot app/ -
Create or update a locale:
pybabel init -i messages.pot -d locales -l fi(orpybabel update -i messages.pot -d locales). -
In
locales/<lang>/LC_MESSAGES/messages.po, add or edit entries for the project state keys:msgid "project_state.planning" msgstr "Suunnittelu" msgid "project_state.request_funding" msgstr "Rahoituksen anomus" ...All keys are referenced in
app.utils.locale(PROJECT_STATE_MSGIDSand_babel_project_state_msgids()) so they appear in the .pot after extract. -
Compile:
pybabel compile -d locales
The codes (and thus msgids) are: planning, request_funding, waiting_for_launch, running, closed, terminated, not_funded.