Home » Documentation » Developers Information » Editing WPML’s Languages Table

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);


10 Responses to “Editing WPML’s Languages Table”

  1. Lemmon says:

    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?

  2. Mihai says:

    Just go at the “Site languages” section, click “Add / Remove languages” and then “Apply”.

  3. Lemmon says:

    Thanks very much! Working perfectly!

  4. Solomiya says:

    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!

  5. Solomiya says:

    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/

  6. anirudh says:

    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

Leave a Reply

Please leave here comments about this page only.
For technical support and feature suggestions, head to our forum. We are waiting there!

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>