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_state Jinja filter; the app calls translate_project_state_label() which uses Flask-Babel gettext(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_STATES in app.models.project_state).

Adding translations

  1. Extract messages (if not already):
    pybabel extract -F babel.cfg -o messages.pot app/

  2. Create or update a locale:
    pybabel init -i messages.pot -d locales -l fi (or pybabel update -i messages.pot -d locales).

  3. 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_MSGIDS and _babel_project_state_msgids()) so they appear in the .pot after extract.

  4. Compile:
    pybabel compile -d locales

The codes (and thus msgids) are: planning, request_funding, waiting_for_launch, running, closed, terminated, not_funded.