aTranslations[$sTranslation][$sLang] = $sTranslationKey; } public function i18nJS() { $sOut = ''; $sOut .= "\n"; return $sOut; } public function i18nJSON() { return json_encode($this->aTranslations); } public function getTranslation($sKey, $sLang) { if(array_key_exists($sKey, $this->aTranslations[$sLang])) { return $this->aTranslations[$sLang][$sKey]; } else { return $sKey; } } } $i18n = new i18n(); $i18n->add('STR_GREETING', 'Hallo meneer {$1}. Of mag ik u {$2} noemen?', 'nl'); $i18n->add('STR_BOAT' , 'boot', 'nl'); $i18n->add('STR_HORSE' , 'paard', 'nl'); $i18n->add('STR_DOG' , 'hond', 'nl'); $i18n->add('STR_GREETING', 'Hello mister {$1}. Or can I call you {$2}?', 'en'); $i18n->add('STR_BOAT' , 'boat', 'en'); $i18n->add('STR_HORSE' , 'horse','en'); $i18n->add('STR_DOG' , 'dog','en'); echo $i18n->i18nJS(); ?>