Internationalisation (i18n)

Google code r302:

Internationalisation (i18n) for phpwcms parser:

All single line @@My Text@@ will be automatically translated and new values will be stored to special language files under /template/template_lang/xx.php. By default browser language is used to name/load language file - but can be overwritten setting $phpwcms['i18_lang'].

Render @@Text@@ based on browser language and store in related language file which allows easy translation at later time and when needed. The Text between @@Default@@ will be taken as default text if no translation exists.

Technics: Dr.-Ing. Tobias Schittkowski (

“I want to present a way in which it is possible to have multiple language versions of a php application ….”


  • Strings, which should be translated, have @@-tags
  • The translation files are separate and can easily be adapted
  • The translation function can also be called internally by php

The content of a language file could be:


$i18n_tokens['Benutzer bearbeiten']='Edit user';
$i18n_tokens['Benutzergruppe']='User group';
$i18n_tokens['Benutzergruppen']='User groups';
$i18n_tokens['Benutzerverwaltung']='User management';

<note warning>Never close the language file using PHP tag ?>. This will break the file. </note>

Little test


$phpwcms['i18n_parse'] = 1; 
// enable|disable browser based language parser - all @@Text@@ will be parsed and checked for translation/var based replacement

Input into any text CP the following test strings:

@@Benutzer@@ der @@Benutzer bearbeiten@@ kann gehört zu einer @@Benutzergruppe@@ bzw. in eine der @@Benutzergruppen@@ die durch die @@Benutzerverwaltung@@ gesteuert werden - das ist Schwachsinn.
→ save → Frontend call of this site

Output in FE:

Benutzer der Benutzer bearbeiten kann gehört zu einer Benutzergruppe bzw. in eine der Benutzergruppen die durch die Benutzerverwaltung gesteuert werden - das ist Schwachsinn.

→ now have a look into the folder /template/template_lang/*
You will find a file like this e.g.


// phpwcms template language file "de" (2009-02-06 16:52:05)
// ATTENTION! Never add the closing PHP tag "? >" at the end of this file!
$i18n_tokens['Benutzer'] = 'Benutzer'; // NEW 2009-02-06 16:52:05
$i18n_tokens['Benutzer bearbeiten'] = 'Benutzer bearbeiten'; // NEW 2009-02-06 17:01:15
$i18n_tokens['Benutzergruppe'] = 'Benutzergruppe'; // NEW 2009-02-06 17:01:15
$i18n_tokens['Benutzergruppen'] = 'Benutzergruppen'; // NEW 2009-02-06 17:01:15
$i18n_tokens['Benutzerverwaltung'] = 'Benutzerverwaltung'; // NEW 2009-02-06 17:01:15

Translate it e.g. into [en]


// phpwcms template language file "de" (2009-02-06 16:52:05)
// ATTENTION! Never add the closing PHP tag "? >" at the end of this file!
$i18n_tokens['Benutzer'] = 'User'; // NEW 2009-02-06 16:52:05
$i18n_tokens['Benutzer bearbeiten'] = 'Edit user'; // NEW 2009-02-06 17:01:15
$i18n_tokens['Benutzergruppe'] = 'User group'; // NEW 2009-02-06 17:01:15
$i18n_tokens['Benutzergruppen'] = 'User groups'; // NEW 2009-02-06 17:01:15
$i18n_tokens['Benutzerverwaltung'] = 'User management'; // NEW 2009-02-06 17:01:15

And please have a new recall of this site:

Output of this site:

User der Edit user kann gehört zu einer User group bzw. in eine der User groups die durch die User management gesteuert werden - das ist Schwachsinn.

hurray! we have a translation.

<note> This file should be called in the true life surely not de.php but rather en.php for the English language, since the side is visited by user with an English located browser. (That was made only for a fast test, because everyone will not be able to switch its browser language → FF: Quick Locale Switcher). </note>

<note tip>In this way also a paragraph can be treated.</note>

<note warning>Take care to escape any single quotation mark like so: “Hell\'s Angels” (this isn't correct in any case- with the actually running test and utf-8 it is working without the aforementioned encodings. We'll dig into it deeper)
Otherwise the system will spit an error upon you 8-o</note> <note warning>this is even more important: Always save your edited lang-files utf-8- encoded, otherwise you will end up with a totally scrambled file version 8-o 8-o 8-o</note>

Locales returned from browser:

Have a look:

PHP: mehrsprachige Seiten bauen [DE]

W3C: Language tags in HTML and XML



Afrikaans = af

Albanian = sq

Arabic (Algeria) = ar-dz
Arabic (Bahrain) = ar-bh
Arabic (Egypt) = ar-eg
Arabic (Iraq) = ar-iq
Arabic (Jordan) = ar-jo
Arabic (Kuwait) = ar-kw
Arabic (Lebanon) = ar-lb
Arabic (libya) = ar-ly
Arabic (Morocco) = ar-ma
Arabic (Oman) = ar-om
Arabic (Qatar) = ar-qa
Arabic (Saudi Arabia) = ar-sa
Arabic (Syria) = ar-sy
Arabic (Tunisia) = ar-tn
Arabic (U.A.E.) = ar-ae
Arabic (Yemen) = ar-ye
Arabic = ar

Armenian = hy

Assamese = as

Azeri (Cyrillic) = az
Azeri (Latin) = az

Basque = eu

Belarusian = be

Bengali = bn

Bulgarian = bg

Catalan = ca

Chinese (China) = zh-cn
Chinese (Hong Kong SAR) = zh-hk
Chinese (Macau SAR) = zh-mo
Chinese (Singapore) = zh-sg
Chinese (Taiwan) = zh-tw
Chinese = zh

Croatian = hr

Czech = cs

Danish = da

Divehi = div

Dutch (Belgium) = nl-be
Dutch (Netherlands) = nl

English (Australia) = en-au
English (Belize) = en-bz
English (Canada) = en-ca
English (Caribbean) = en
English (Ireland) = en-ie
English (Jamaica) = en-jm
English (New Zealand) = en-nz
English (Philippines) = en-ph
English (South Africa) = en-za
English (Trinidad) = en-tt
English (United Kingdom) = en-gb
English (United States) = en-us
English (Zimbabwe) = en-zw
English = en

Estonian = et

Faeroese = fo

Farsi = fa

Finnish = fi

French (Belgium) = fr-be
French (Canada) = fr-ca
French (France) = fr
French (Luxembourg) = fr-lu
French (Monaco) = fr-mc
French (Switzerland) = fr-ch

FYRO Macedonian = mk

Gaelic = gd

Georgian = ka

German (Austria) = de-at
German (Germany) = de
German (Liechtenstein) = de-li
German (lexumbourg) = de-lu
German (Switzerland) = de-ch

Greek = el

Gujarati = gu

Hebrew = he

Hindi = hi

Hungarian = hu

Icelandic = is

Indonesian = id

Italian (Italy) = it
Italian (Switzerland) = it-ch

Japanese = ja

Kannada = kn

Kazakh = kk

Konkani = kok

Korean = ko

Kyrgyz = kz

Latvian = lv

Lithuanian = lt

Malay (Brunei) = ms
Malay (Malaysia) = ms

Malayalam = ml

Maltese = mt

Marathi = mr

Mongolian (Cyrillic) = mn

Nepali (India) = ne

Norwegian (Bokmal) = nb-no
Norwegian (Bokmal) = no
Norwegian (Nynorsk) = nn-no

Oriya = or

Polish = pl

Portuguese (Brazil) = pt-BR
Portuguese (Portugal) = pt

Punjabi = pa

Rhaeto-Romanic = rm

Romanian (Moldova) = ro-md

Romanian = ro

Russian (Moldova) = ru-md
Russian = ru

Sanskrit = sa

Serbian (Cyrillic) = sr
Serbian (Latin) = sr

Slovak = sk

Slovenian = ls

Sorbian = sb

Spanish (Argentina) = es-ar
Spanish (Bolivia) = es-bo
Spanish (Chile) = es-cl
Spanish (Colombia) = es-co
Spanish (Costa Rica) = es-cr
Spanish (Dominican Republic) = es-do
Spanish (Ecuador) = es-ec
Spanish (El Salvador) = es-sv
Spanish (Guatemala) = es-gt
Spanish (Honduras) = es-hn
Spanish (International Sort) = es
Spanish (Mexico) = es-mx
Spanish (Nicaragua) = es-ni
Spanish (Panama) = es-pa
Spanish (Paraguay) = es-py
Spanish (Peru) = es-pe
Spanish (Puerto Rico) = es-pr
Spanish (Spain) = es-es
Spanish (Traditional Sort) = es
Spanish (United States) = es-us
Spanish (Uruguay) = es-uy
Spanish (Venezuela) = es-ve

Sutu = sx

Swahili = sw

Swedish (Finland) = sv-fi
Swedish = sv

Syriac = syr

Tamil = ta

Tatar = tt

Telugu = te

Thai = th

Tsonga = ts

Tswana = tn

Turkish = tr

Ukrainian = uk

Urdu = ur

Uzbek (Cyrillic) = uz
Uzbek (Latin) = uz

Vietnamese = vi

Xhosa = xh

Yiddish = yi

Zulu = zu

How to make some use of it:

With this method it is possible to render not only text within your Content Parts, but you can have your titles and / or subtitles nicely replaced too.
This is offering some possibilities:

  • multilingual shop with one centralized instance
  • same goes for google maps
  • or forms

Why would I like to do it with forms?
Imagine a site with 10 language trees, every tree having it's own form. Horrible to maintain, if an email address is changing? Terrible!
So you go ahead, create some hidden structure level, create an article with your form, enhanced by @@ these tags @@ and just reference this single instance of your form with this lovely {SHOW_CONTENT:CP,IDxx}

How to make some use of it II:

Some words of wisdom ;-)
When making use of this very handy feature you'll be best off if you start your text in english and do a quick roaming through all of your pages with your preferred browser language (= mostly your mother tongue) to catch all of your @@text@@ items.
Now you can do a little translation into the pages main language and step by step you can translate the main preferred visitor languages.
Result: every new foreign visitors will always have an english text at least.
Otherwise you'll end up with translating a real bunch of files (just wait some days and you'll have 50+++ new lang files LOL

A little additional tip: Install that ”Quick Locale Switcher” addon for FF to empower yourself to generate your first and needed language files on purpose ;)

english/phpwcms_replacer_rts/integrated-tags/language-tags/i18n.txt · Last modified: 2018/06/03 18:09 (external edit) Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0