[Plugin: Polylang] How to internationalize a theme ?
-
There are still a lot of themes which are not internationalized by their author ??
Here is the procedure to do it… It is quite long but it could be worth it if you really like your (not yet internationalized) theme.
First step : declare the domain
Open the file functions.php and add these lines:
add_action( 'after_setup_theme', 'setup' ); function setup() { load_theme_textdomain('your_theme', get_template_directory()); }
Replace
your_theme
by whatever you want (no space)Second step : make your strings translatable
Edit all your php files and look for all strings, for example
'Read the rest of this entry »'
strings are either found between single quotes or double quotes. Take care that not everything between quotes is a string that will be display.
Then replace the string by :
__('Read the rest of this entry »'), 'your_theme'
Take care : there are 2 undescores. Replace ‘your_theme’ by the name you chose in functions.phpOnce you have edited all your strings, your theme is ready for translation !
More information can be found in the codex
Third step : Translate your strings using either poedit or the plugin codestyling localization.
The .po and .mo have to be placed in your theme directory and must be called locale.po and locale.mo in which locale is to be replaced by the WordPress locale in which you are translating your theme (for example : fr_FR, es_ES or lv)
Hope it will help !
- The topic ‘[Plugin: Polylang] How to internationalize a theme ?’ is closed to new replies.