[katello-devel] How to format strings
Miroslav Suchý
msuchy at redhat.com
Fri Sep 21 07:20:18 UTC 2012
In our code base we use very frequently:
_("Couldn't find changeset '#{params[:changeset_id]}'")
and later:
_("Couldn't find changeset '#{params[:id]}'")
But this notation means that the name of variable is part of string to
be translated. And that results in two strings, which needs to be
translated:
msgid "\"Couldn't find changeset '#{params[:changeset_id]}'\""
msgstr ""
msgid "\"Couldn't find changeset '#{params[:id]}'\""
msgstr ""
Please if you are writing string, which you are passing to gettext
function (aka _()), then user rather this notation:
_("Couldn't find changeset '%s'") % params[:id]
or
_("Couldn't find changeset '%s' and '%s'") % [params[:id], foo]
If we will follow this, we will significantly reduce number of strings
to be translated.
Thank you.
P.S. I'm preparing pull request, which will unify these duplicities.
I'm doing that in my spare time, so it will take some time.
--
Miroslav Suchy
Red Hat Systems Management Engineering
More information about the katello-devel
mailing list