ExQuality.Stages.Gettext (ExQuality v0.13.0)
View SourceChecks translation completeness by reading the project's .po files.
Reports two kinds of finding, one per untranslated or fuzzy entry, each with
the file, the line of its msgid, and the app it belongs to:
- missing translations (an empty
msgstr) - fuzzy translations (marked
#, fuzzy)
This stage is automatically enabled only if :gettext is in deps.
What it reads
Translations live in priv/ under whichever project declares the backend, so
the files are found with a wildcard over the umbrella's child apps as well as
the root. An umbrella root has no priv/ of its own: a scan of one hardcoded
directory there finds nothing, and finding nothing is not the same as finding
no problems.
A run that examined no files reports itself as :skipped with the reason,
the way an uninstalled tool does. A stage that said nothing would otherwise
read as a stage that passed.
The source locale
A project's source locale is written in the source, so its .po files are
untranslated by definition and every entry in them would be reported. That
locale is "en" unless gettext: [source_locale: "..."] says otherwise, and
a project whose only locale is the source locale is reported as skipped
rather than green.
errors.po is excluded for the same reason - Phoenix generates it with empty
entries in every locale - and gettext: [exclude: [...]] replaces that list.
Extraction
mix gettext.extract --merge writes: it rewrites .pot and .po files, and
it compiles the project to do it. Both are surprises from a checker. A tool
that dirties the tree lands in every commit as noise, and a stage that
recompiles while the other stages are reading the same build can pull the
ground out from under them.
So it is off by default and this stage reads the committed files as they
stand. gettext: [extract: true] turns it back on, and the stage then
declares itself a writer (stage_kind/1) so the run serialises it rather
than running it alongside the stages that read the build.
Summary
Functions
Runs the gettext stage.
Says whether this stage writes to the project, so a run can keep it away from the stages that read the build.
Functions
@spec run(keyword()) :: ExQuality.Stage.result()
Runs the gettext stage.
Config options
gettext.source_locale- the locale the source is written in, whose files are not checked (default:"en")gettext.exclude- basenames to skip (default:["errors.po"])gettext.extract- runmix gettext.extract --mergefirst, writing to the project (default:false)
@spec stage_kind(keyword()) :: ExQuality.Stage.kind()
Says whether this stage writes to the project, so a run can keep it away from the stages that read the build.
Extraction compiles the project and rewrites translation files, so a stage
configured to extract is a :writer. Reading .po files is not, so the
default is :reader.
iex> ExQuality.Stages.Gettext.stage_kind([])
:reader
iex> ExQuality.Stages.Gettext.stage_kind(gettext: [extract: true])
:writer