WordPress Themes
Documentation
Search for articles about the Audio Player and WordPress Theme

How to create a multilingual website and translate the theme

The best tool to translate your site in your own language is by using the WeGlot plugin. WeGlot is a new plugin that revolutionize the translation of a WordPress site. We strongly recommend it as it’s the best translation tool for WordPress. To learn more, check our blog post.

If you don’t want to use WeGlot and translate your site in a old-fashion way, read below:

Step 1 – Download and Install PoEdit software: https://poedit.net/

Step 2 – Unzip sonaar.zip WordPress theme on your computer.

Step 3 – Open Poedit and click on File -> New from POT/Po file in the main menu and select the POT file in your theme’s languages folder. The .POT file should be located in your /sonaar/languages/

Step 4 – A properties box will open up. Select the language name you want to translate to.

Step 5 – Now you can start translating the theme via the String Translation mechanism. This provides direct like-for-like translations. Go through each line one-by-one, adding the translation to your native language as you go. If you think there’s some text that won’t require translation or you’re not sure what to translate it to you can just leave them as they are in the original language; you can always come back and translate them later if need be. You don’t have to translate everything. Remember that strings that you have not translated will appear in english in your site. The string you have translated will show the corresponding translations.

Step 6 – Go to File -> Save. You’ll be asked to what filename you want to save your .po file. Each language and country has a specific code you will need to use when saving translation files; for instance, if you’re going to translate into Spanish you’ll name your file “sonaar-es_ES.po”, whereas if you’re translating into German you’ll name the file “sonaar-de_DE.po”, french from France will be “sonaar-fr_FR.po”, french from Canada will be “sonaar-fr_CA.po”. To break it down; the first lower-case letters defines the language, whereas the second upper-case letter defines the country. In many cases the language and country will be the same, hence “de_DE” for Germany, but what about languages like English or Portuguese, that are spoken in several countries natively? In these cases there will be a difference in the first and second letter pairs; for the UK, the code would be en_GB, whereas for the USA it will be en_US. If you’re not familiar with the codes for your native language and country you can head over to the GNU website, where they have all the codes for Language and Country. Remember, if you use the wrong naming convention WordPress won’t be able to use your translation, so double-check if necessary.

Step 7 – Save your new language file in the wp-content/languages/themes/sonaar-fr_CA.mo. See screenshot: http://d.pr/i/iVUn

Setup WordPress to read your translation #

OPTION 1. IF YOU ARE USING 2 LANGUAGES ON YOUR SITE

Step 1 – Make sure the language value you are translating is set in your translation WordPress plugin. In this case, we are using WPML plugin.

Step 2 – Go to WP-admin > WPML > Language. Add/Edit the language you want to translate (http://d.pr/i/ssZZjo) and click “Edit languages”

Step 3 – Make sure that the default locale is corresponding to your .mo file you previously saved. In this case, it will be fr_CA since my .mo file has been named: sonaar-fr_CA.mo (where sonaar is the name of my theme and fr_CA is my default locale, separated by a dash) See screenshot: http://d.pr/i/wNxvu7

You are done!

OPTION 2: IF YOU ARE USING ONLY 1 LANGUAGE ON YOUR SITE

You’ll need to make sure your wp-config.php file settings match your language files. Edit the file wp-config.php which is located in your root folder (See screenshot: http://d.pr/i/1fQmH) You’ll need to open the wp-config.php file and set your language accordingly, like this:

/*
* WordPress Localized Language, defaults to English.
* Change this to localize WordPress. A corresponding MO file for the chosen
* language must be installed to wp-content/languages. For example, install es_ES.mo to wp-content/languages and set WPLANG to 'es-ES' to enable Spanish language support.
*/

define('WPLANG', 'fr-CA');

Share your language files with others #

If you’ve already translated a theme then many of our users would be delighted if you could share your translation files with the community. Just get in contact with us via our Helpdesk ticket system and we will include the translation files in the next theme update if possible.

Translation tips: Character Encoding #

If you’re used to working in HTML or through the WordPress editors then there are a few areas which might catch you out when creating the translations; here’s a few tips to help you get things done: First of all, any localizations should use UTF-8 encoding. This is one of the reasons we recommend Poedit; this kind of seemingly minor issue is already accounted for in a dedicated program. If you were to edit the files via a standard, simple editor like notepad, then the default settings will usually use different encoding. You won’t actually notice this when working on the file, but once you save it you’ll notice that all your translated elements are displaying the identifying string rather than the original or new language. You can just open and resave the file with the proper encoding, but using a dedicated program will prevent this happening in the first place, so it’s probably the safer solution! When writing your translations you should write your translations plainly; that is, avoid escaping accented and special characters with HTML character entities, save for a select group that are expected to be escaped to avoid conflict with XHTML markup: angle brackets (< & >), and ampersands (&). In addition, there are a few other characters that function better when escaped, such as non-breaking spaces ( ), angle quotes (« and »), curly apostrophes (’) and curly quotes. When we create multilingual sites, we need to remember that translation is not everything; localization goes beyond just translating words and expands to include adapting the site to a different language, country and conventions. Some words simply don’t mean the same thing or carry the same implications as other languages, so don’t translate literally; translate organically; try to get a feel for the meaning behind the original text, and capture that spirit in your translation.

Updated on February 13, 2023
Was this article helpful?
Still Stuck?
How can we help?