Internationalisation perl gotcha
By Darryl Gove-Oracle on May 28, 2008
One of the issues to look out for when applying
gettext to perl programs is variable substitution. For example:
print "My name is $name\\n"
Should not be internationalised as:
print gettext("My name is $name\\n");
Because the variable substitution for
$name occurs before the call to
gettext - hence
gettext would get the text including the value of the variable
$name, and would require a separate translation for every value of
There are number of alternatives to this,
printf or string concatenation. These work for many situations, but can present a problem when there are multiple variables being substituted and the order of the variables is different in different locales.