Dottoro Theme Documentation
Tutorial to get your theme to work
26. Localization
Dottoro Theme is translation ready, meaning it comes with english po languages files.
There are one language file for admin and one for front-end pages.
So, for example, if you only want to translate public pages, you only need to translate the front-end po file.
How to translate:
It is strongly advised to use a
child theme for localization, otherwise your changes will be lost when you update the Dottoro Theme.
Steps:
- Create a new directory called languages in the root folder of your child theme
- Create the following two directories under the newly created languages directory: admin and public
-
Copy the po files from Dottoro theme to your child theme:
Source file: dottoro/admin/languages/default.po
Destination file: dottoro_child/languages/admin/default.po
Source file: dottoro/common/languages/default.po
Destination file: dottoro_child/languages/public/default.po
- Rename the po files under your child theme to your locale (e.g. en_US.po). More on WordPress Locale Setting.
- Translate the content of the po files under your child theme, then compile .mo files from your .po files.
-
The next step is to tell the theme where your language files are located.
Insert the following lines into the functions.php file of your child theme:
add_filter ('dottoro_locale_settings', 'custom_local_settings');
function custom_local_settings ($settings) {
$settings['admin_folder'] = FOLDER_CHILD_THEME . '/languages/admin';
$settings['content_folder'] = FOLDER_CHILD_THEME . '/languages/public';
$settings['admin_url'] = URL_CHILD_THEME . '/languages/admin';
$settings['content_url'] = URL_CHILD_THEME . '/languages/public';
$settings['auto_versioning'] = true;
return $settings;
}
The admin_folder and content_folder properties specify the paths to language folders on your server while the admin_url and content_url properties specify the URLs of language folders.
Finally, the auto_versioning options means the URL pointing to the JavaScript language files (see the next step) should end with the last modified timestamp of the file or not. If the auto_versioning is on, you don't need to worry about browser caching issues.
The admin_url, content_url and auto_versioning properties are supported from version 1.32.
-
The last step is the translation of JavaScript files. Fortunately, the po files contain all localizable strings that are located in JavaScript files so you don't need to do anything else just download the JavaScript language file and copy it into the right place.
To do that, just click on the "Download Admin JavaScript Language File" button under Theme Options » General » Translate and copy the downloaded javascript file to the languages/admin/ directory under your child theme.
Then click on the "Download Frontend JavaScript Language File" button and copy the downloaded javascript file to the languages/public/ directory under your child theme.
Since the frontend JavaScript language file was only needed for the Tweets widget and the Tweet widget has been removed from the theme in version 1.40 so the "Download Frontend JavaScript Language File" button has also been removed in version 1.40.
The name of JavaScript language files must be in the following format: locale.js. Please remove the unnecessary characters from the file names. For example, "en_US(2).js" must be renamed to "en_US.js".
You are done.
The translation of JavaScript files is supported from version 1.32.
Read more about language files on
Translating WordPress.