VerifiedTranslations.Credo.PreferSigil (verified_translations v0.1.1)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of normal and works with any version of Elixir.

Explanation

Prefer the ~t sigil and tn/2 over Gettext's macros.

# not preferred
gettext("Welcome back, %{name}!", name: @user.name)
ngettext("1 file", "%{count} files", length(files))

# preferred
~t"Welcome back, #{@user.name}!"
tn(length(files), one: "1 file", other: "%{count} files")

Both are verified at compile time by verified_translations, but ~t keeps the bindings next to the text. Fix all of them automatically with:

mix verified_translations.migrate

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.