feature:translate

Introduction

feature:translate extracts, creates and compiles a feature’s translations with pybabel. They live in the feature’s own translations/ folder, so they travel with it to every product. Run it after you wrap new strings in _().

splent feature:translate notes --extract --init es --compile
  splent_feature_notes: extracted to messages.pot
  splent_feature_notes: es initialized
  splent_feature_notes: compiled

--extract collects the strings of the Python files and templates into messages.pot. --init es creates translations/es/LC_MESSAGES/messages.po, which you translate. --compile turns it into the .mo Flask-Babel reads. The three always run in that order.


Adding new strings to a locale

splent feature:translate notes --extract --init es

When the locale exists, --init merges the new strings into its .po and keeps your translations.


Translating every feature of the product

splent feature:translate --compile

Without a feature, it works on every feature the selected product declares for the current SPLENT_ENV. Pinned features are read-only, so they are skipped.


Translating a feature no product uses yet

notes, splent_feature_notes and splent-io/splent_feature_notes name the same feature, and the match is exact. A feature the product does not declare is taken from its working copy at the workspace root, with no product selected at all.


Reference

Argument or option Description
FEATURE_REF Optional. One feature. An @<version> suffix is ignored
--extract Extract the strings into translations/messages.pot
--init LOCALE Create the locale’s .po, or merge new strings into it
--compile Compile every .po of the feature into .mo

Strings are extracted from **.py and **/templates/**.html, wrapped in _, gettext, ngettext, _l, lazy_gettext or _n.

Message What to do
No product selected. Run: splent product:select <name>, or name a feature. Select a product, or name one feature
Feature '<ref>' is not declared in <product>, and has no working copy at the workspace root. Check the name
<name>: no editable source in the workspace, skipped. The feature is only pinned
<name>: no .pot file Run --extract before --init
<N> step(s) failed. Read the pybabel error above it

Each of these exits 1. Without any flag, the command prints a hint and does nothing.


Requirements

  • A selected product (SPLENT_APP), unless you name a feature.
  • Babel, as installed in the CLI container.

See also


Back to top

splent. Distributed by an LGPL license v3. Contact us: drorganvidez@us.es