Skip to content

Commit

Permalink
fix: create Translation instance
Browse files Browse the repository at this point in the history
  • Loading branch information
modelrailroader authored May 22, 2024
1 parent b1827cf commit 892a8f8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions phpmyfaq/sitemap.xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
use phpMyFAQ\Date;
use phpMyFAQ\Faq;
use phpMyFAQ\Filter;
use phpMyFAQ\Language;
use phpMyFAQ\Link;
use phpMyFAQ\Strings;
use phpMyFAQ\Translation;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

Expand Down Expand Up @@ -56,6 +58,30 @@
exit();
}

//
// Get language (default: english)
//
$Language = new Language($faqConfig);
$faqLangCode = $Language->setLanguage($faqConfig->get('main.languageDetection'), $faqConfig->get('main.language'));
$faqConfig->setLanguage($Language);

if (!Language::isASupportedLanguage($faqLangCode)) {
$faqLangCode = 'en';
}

//
// Set translation class
//
try {
Translation::create()
->setLanguagesDir(PMF_LANGUAGE_DIR)
->setDefaultLanguage('en')
->setCurrentLanguage($faqLangCode)
->setMultiByteLanguage();
} catch (Exception $e) {
echo '<strong>Error:</strong> ' . $e->getMessage();
}

/**
* @param string|null $lastModified
*/
Expand Down

0 comments on commit 892a8f8

Please sign in to comment.