get_handle(), rather than new().
get_handle() is an argument-based singleton. get_handle() does not require you to pass arguments to it, because it determines the appropriate information based on the user calling the function.
Generally, in modules and large scripts that may or may not need a locale object, you should use:my $locale = Cpanel::Locale->get_handle();
package XYZ;
my $locale;
sub something_that_needs_to_say_seomthing_to_the_end_user {
$locale ||= Cpanel::Locale->get_handle();
print $locale->maketext('All your base are belong to us');
}
maketext() function is the main method for constructing locales. The function takes the phrase, or lexicon key, as its first argument. Any other arguments are used for the string's bracket notation.
print $locale->maketext('Hello World');
print $locale->maketext('My name is [_1]',$name);
encoding() — This function returns the character set of the locale's lexicon data.
datetime() — This function returns a string that contains localized date and time data.
Copyright © cPanel 2000-2009.