Cpanel::Locale system.
Cpanel::Locale system.
$Cpanel::Lang::LANG{$lang}{$key}
Cpanel::Lang
Cpanel::TieLang
Whostmgr::Lang
'charset' key (more information below)
Cpanel::Template templates as the variable locale. The legacy system sometimes had a lang variable available which worked like this:
This would now be:[% lang.arbitrary_legacy_style_tag_here %]
[% locale.maketext('arbitrary_legacy_style_tag_here') %]
perl -pi -e 's{lang\.(\w+)}{locale.maketext(\"$1\")}g;' path/to/file
[% locale.maketext('Hello World') %]
locale available is that you have all the methods available for free:
<meta http-equiv="Content-Type" content="text/html;charset=[% locale.encoding() %]" />
maketext() to the template, but that will take control away from the template. (For example, if you add, edit, or delete what it is saying, you'd have to update the caller to pass different arguments. This would defeat the purpose of a template.)
There should be little overhead to template processing, as it is only passing an object (essentially, a hashref), the object is a singleton, and the constructor is only called if it has not been called yet inside the Cpanel::Template package.
'charset'. That key should be avoided now, and in fact won't work. It was used to fetch the character encoding like so:
<cpanel langprint="charset"> or some version like $LANG{$lang}{'charset'}
The locale object has a method called encoding() that returns the current locale's character set (usually utf-8). An API2 call exists for it, which is formatted like so:
<?cp Locale::get_encoding(%,encoding) ?>
<?cp Locale::get_locale_name(%,name) ?>
dir attribute in the <html> tag. (This is recommended over using the <body> tag).
Using Template Toolkit markup, this would look like:
Using cPanel API2 tags, this would look like:<html dir="[% locale.get_html_dir_attr() %]">
<html dir="<?cp Locale::get_html_dir_attr(%,dir) ?>">
<bdo dir="[% locale.get_html_dir_attr(tag) %]">text in 'tag's language</bdo> <option value="[% tag %]" dir="[% locale.get_html_dir_attr(tag) %]">
Copyright © cPanel 2000-2009.