Home » Documentation » Developers Information » WPML’s tables

WPML’s tables

Language information and translations

WPML holds the language information in a separate table.

The table that holds the language and translation information is called icl_translations.

Each item (post, page, tag, category or comment) in the site needs to have an entry in this table. The entry specified the item’s language and the translation group it belongs to. Items that belong to the same translation group are translations of one another.

It has the following rows:

  • translation_id – serial number
  • element_type – the type of the element
  • element_id – the ID of the item
  • trid – the ID of the translation group
  • language_code – language code of the item
  • source_language_code – if translated, the language of the original item

For example, if we have an English post with ID=3, that is translated to Spanish and the Spanish translation has ID=7, the icl_translations table will look like this:

translation_id element_type element_id trid language_code source_language_code
1 post 3 2 en
2 post 7 2 es en

* Because the two entries have the same value for trid, they are translations of one another. The value itself is not important.

Country flags

WPML ships with a large collection of country flags. It’s a well known fact that associating languages with countries is problematic. Many languages are spoken (sometimes differently) in different countries. However, country flags are still a helpful visual cue and help visitor spot their language easily.

WPML’s country flags are stored in the res/flags directory and the icl_flags table indicates which flag to return for each country. The columns of the icl_flags table are:

  • id – serial number
  • lang_code – the language code
  • flag – the name of the flag file
  • from_template – “0″: take the flag from WPML’s res/flags folder, “1″: take the flag from the theme directory

If you want to use a different flag from WPML’s flags collection, change the flag column in the table. If you want to supply alternative language flags, change both the flag and from_template columns to indicate the flag name from your theme directory.

You should put your own flags in a special directory in your theme. Under the theme directory, create images/flags and store the flag files there. For example:

THEMEDIRECTORY/images/flags/myflag.png

Don’t overwrite the files in the plugin directory. Your changes will be lost every time WPML is updated.

String translation

Most WordPress sites include some strings that don’t belong to any item (post, page, tag, category), which still need to be translated – for example, the blog’s tagline.

WPML includes a mechanism, we called String Translation, to handle these strings.

The strings are kept in the icl_strings table with the following columns:

  • id – serial number
  • language – language
  • context – context (indicates what the string belongs to)
  • name – name of the string
  • value – the strings value (its contents)
  • status – translation status indicating if the string is fully translated to all languages

Translations to the string are kept in the icl_string_translations table:

  • id – serial number
  • string_id – the ID (serial number) of the string being translated
  • language – the language of the translation
  • status – the status of the translation (complete / not complete)
  • value – the translation itself

Viewing WPML’s tables

You can view the contents of WPML’s tables using the troublshoot page. To access it, go to WPML’s overview page, scroll down and click on Troubleshoot.

That page includes the contents of WPML’s tables in CSV (comma separated value) format. You can copy each of these entries and paste to a spreadsheet to view it in a nice table.

To best view the icl_translations table, you can sort the spreadsheet according to the trid column. This will list translations one after the other.

The troubleshoot page doesn’t allow writing to any of the tables. To do this, you should use a database editing tool such as PHPMyAdmin.