Editing WPML’s Languages Table
WPML comes built-in with a list of languages that you can use.
Sometimes, this list isn’t enough and you may want to edit WPML’s languages. This is useful for adding language/country variants and simply including languages that WPML doesn’t list.
WPML’s language information is kept in two tables:
- wp_icl_languages – lists languages
- wp_icl_languages_translations – lists language name translations
Make sure that the code of the language you are adding to the database is not already used in these tables.
wp_icl_languages
the columns are pretty much self-explanatory:
- code – will be the language key (used in the URLs and everything else)
- major – means that the language will be displayed at the top in the language selection panel
- active – means that the language is selected as an active language or not
- default_locale – locale name to be used in case the user doesn’t specify one explicitly
Each row represents a language.
wp_icl_languages_translations
This table includes language name translations, so that WPML can display the language name, in the language switcher, in the correct language.
- language_code – the language we’re referencing
- display_language_code – language that the name of the ‘language_code’ is in
- name – name for ‘language_code’ in the ‘display_language_code’ language
There should be a row for each combination of language_code / display_language_code for the active languages (including translations of every language to itself).
So – for every new language added translations of the respective language into the active languages, translations of the active languages into the newly added language and a translation of the new language into the new language need to be added to wp_icl_languages_translations.
wp_icl_flags
Indicates which image to return for the language flag.
- lang_code – language for which the flag is
- flag – name of the flag image file
- from_template – set to 1 means that the file will be loaded from the images/flags folder in the theme folder (otherwise loaded from the plugin flags folder).
There should be one entry per language.
Note 1: after adding records in these tables saving the languages list would be recommended.
Note 2: clearing the WPML’s internal cache for languages is also recommended. To do this you need to delete the record from wp_options corresponding to option_name=’_icl_cache’ .
To keep these customizations upon upgrading the plugin add the following piece of code to either wp-config.php or to your functions.php file in the theme folder:
define('ICL_PRESERVE_LANGUAGES_TRANSLATIONS', true);
Thanks for the tutorial. Could you please write me how do I save the language list as mentioned in the Note at the end of the tutorial?
Just go at the “Site languages” section, click “Add / Remove languages” and then “Apply”.
Thanks very much! Working perfectly!
Hi,
I’m wondering, if there are an ability to remove language names from the language selector but keep flags there?
I tried to remove the language name from the wr_icl_language_translator table leaving that cell empty, but it didn’t solve the problem – language names keeps to appear.
I’ll be thankfull for your help!
I’ve already solved my problem with labguage names. Here’s good explanation:
http://wpml.org/documentation/getting-started-guide/language-setup/custom-language-switcher/
Hi,
i am having trouble to selecting language, after clicking languages i select a language German and then i clicked next button but language couldn’t be selected, Just page refreshed.
After that i make German language active by updating table wp_icl_languages, also i have inserted language code de for element type post_post in wp_icl_translations.
I make same changes for German language as English in database, but nothing working.
i cant use German language..
If anyone knows the what problem i m having…… plz replay
thanks
Can you please start a thread about this in our technical forum?
http://forum.wpml.org
I regularly change the locale value with WPML>Languages>Modify languages.
I change french and english from fr_FR to fr_CA, and en_US to en_CA.
But, I believe the original values get stuck in the database. wp_icl_locale_map doesn’t get changed. And _icl_cache in wp_option either.
I know things can be done to repair this. For now, I’ll need to continue to manually modify the database.
I’m not sure that this is a very good idea. The language codes are used as keys in several tables and it’s not easy to change them. If you want to have a different code, it would be better to create a NEW language with that code. I got your other comment about _icl_cache, but there might be other places to edit, which are not immediately obvious right now. These would affect translation history.
As a matter of fact, I just changed the value in _icl_cache, and it worked. Can you simply add a cache rebuild on Save the Modify languages.