public function ParseLanguageText(Templator &$tpl) { // Parses a template, resolving all language specific placeholders // Parses in the current language first, then the default language after if (!$tpl->IsTemplateLoaded()) { throw new Exception('YamsLangMgr: A template must be loaded in before parsing the language text'); } $parseCurrent = true; if ($this->itsDefaultLang == $this->itsCurrentLang) { $parseCurrent = false; } else { $currentLangFile = $this->itsCurrentLang . '.inc.php'; $currentLangPath = $this->itsLangDir . $currentLangFile; if (!is_file($currentLangPath)) { if (!is_file($currentLangPath)) { throw new Exception('YamsLangMgr: Could not load current language file: ' . $currentLangPath); } } } $defaultLangFile = $this->itsDefaultLang . '.inc.php'; $defaultLangPath = $this->itsLangDir . $defaultLangFile; if (!is_file($defaultLangPath)) { throw new Exception('YamsLangMgr: Could not load default language file: ' . $defaultLangPath); } $removeUnrecognisedPlaceholders = $tpl->IsRemoveUnrecognisedPlaceHolders(); $tpl->SetRemoveUnrecognisedPlaceHolders(false); // Register the placeholders if ($parseCurrent) { require $currentLangPath; $tpl->Parse(NULL, true); } require $defaultLangPath; $tpl->Parse(NULL, true); // restore the placeholder removal mode $tpl->SetRemoveUnrecognisedPlaceHolders($removeUnrecognisedPlaceholders); }