mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
class i18nActions extends Actions
|
|
{
|
|
public static function setCulture()
|
|
{
|
|
$culture = Request::getPostParam('culture');
|
|
|
|
// Validate
|
|
if ($culture && !in_array($culture, i18n::getAllCultures())) {
|
|
$culture = null;
|
|
}
|
|
|
|
if ($culture) {
|
|
Session::set(Session::KEY_USER_CULTURE, $culture);
|
|
} else {
|
|
Session::unsetKey(Session::KEY_USER_CULTURE);
|
|
}
|
|
|
|
//if session changes update domain
|
|
//english language = www
|
|
|
|
return Controller::redirect(Request::getReferrer());
|
|
}
|
|
|
|
public static function executeServeTranslationFile(string $project, string $resource, string $language)
|
|
{
|
|
if (!Transifex::isConfigured()) {
|
|
throw new Exception('Please set Config::TRANSIFEX_API_KEY in your configuration.');
|
|
}
|
|
|
|
$json = Transifex::getTranslationResourceFile($project, $resource, $language);
|
|
|
|
if (!$json) {
|
|
return NavActions::execute404();
|
|
}
|
|
|
|
Response::setHeader(Response::HEADER_CROSS_ORIGIN, "*");
|
|
Response::enablePublicMutableCache(md5(json_encode($json)));
|
|
|
|
return View::renderJson($json);
|
|
}
|
|
}
|