[Development Guides Home](/guides) >> [Guide to Locales](/guides/guide-to-locales) # Guide to Locales - Basic Usage ## Introduction You can display locale system strings in custom code. This document includes examples for the use of the locale system in custom scripts or applications, or in custom interfaces. * For additional examples of localization in Template Toolkit files, read our [Guide to Template Toolkit in cPanel & WHM](/guides/guide-to-template-toolkit) documentation. * For in-depth documentation about the `Locale::Maketext` module's methods and additional options, read [CPAN's `Locale::Maketest::Utils`](https://go.cpanel.net/CPANLocaleUtils) documentation. ## Basic usage The following example code uses the locale system to localize the string `This is a phrase.` in the application's output: ### Perl ```perl #!/usr/bin/perl # Load the Cpanel::Locale module. use Cpanel::Locale (); # Declare the $locale variable. my $locale = Cpanel::Locale->get_handle(); # Print a localized message. print $locale->maketext('This is a phrase.'); ``` #### Load the Cpanel::Locale module ```perl # Load the Cpanel::Locale module. use Cpanel::Locale (); ``` Loading the `Cpanel::Locale` module ensures that the script or application can access the locale system. For more information read the [pearldoc.perl.org perlobj documentation](http://perldoc.perl.org/perlobj.html). #### Get the user's locale setting ```perl # Declare the $locale variable. my $locale = Cpanel::Locale->get_handle(); ``` This section of the code uses the `maketext()` method to print the string `This is a phrase.` in the authenticated user's locale. * For example, when an authenticated user with the `en` locale runs this subroutine, the system prints `This is a phrase.` * If the authenticated user used the `es` locale and this phrase was present in the locale's lexicon, the sytem would print the same phrase in Spanish (`Esta es una frase.`). * If the authenticated user's locale does not contain this phrase, the phrase will display in the default locale (English). ### Template Toolkit files ```perl
[% locale.maketext('This is a phrase.') %]
``` Template Toolkit templates automatically access the authenticated user's locale. For more information, read our [Guide to Template Toolkit in cPanel & WHM](/guides/guide-to-template-toolkit) documentation. ### JavaScript ```javascript LOCALE.maketext("This is a phrase."); ``` As long as the `CJT locale.js` file loads properly, JavaScript applications will automatically access the authenticated user's locale settings and the locale system.