mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
Nav: Add a (temporary) dropdown to allow user to change language
This commit is contained in:
parent
e0b3d0921a
commit
b30a7c0708
4 changed files with 56 additions and 2 deletions
|
@ -94,6 +94,8 @@ class Controller
|
||||||
$router->any('/list/subscribe', 'MailActions::executeSubscribe');
|
$router->any('/list/subscribe', 'MailActions::executeSubscribe');
|
||||||
$router->get('/list/confirm/{hash}', 'MailActions::executeConfirm');
|
$router->get('/list/confirm/{hash}', 'MailActions::executeConfirm');
|
||||||
|
|
||||||
|
$router->post('/language', 'i18nActions::setCulture');
|
||||||
|
|
||||||
$permanentRedirects = [
|
$permanentRedirects = [
|
||||||
'/lbry-osx-latest.dmg' => '/get',
|
'/lbry-osx-latest.dmg' => '/get',
|
||||||
'/lbry-linux-latest.deb' => '/get',
|
'/lbry-linux-latest.deb' => '/get',
|
||||||
|
|
33
controller/action/i18nActions.class.php
Normal file
33
controller/action/i18nActions.class.php
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of i18nActions
|
||||||
|
*
|
||||||
|
* @author Nacib Neme
|
||||||
|
*/
|
||||||
|
|
||||||
|
class i18nActions extends Actions
|
||||||
|
{
|
||||||
|
public static function setCulture()
|
||||||
|
{
|
||||||
|
$culture = isset($_POST['culture']) ? $_POST['culture'] : null;
|
||||||
|
|
||||||
|
// Validate
|
||||||
|
if ($culture && !($culture == 'en_US' || $culture == 'pt_PT'))
|
||||||
|
{
|
||||||
|
$culture = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($culture)
|
||||||
|
{
|
||||||
|
Session::set(Session::KEY_USER_CULTURE, $culture);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::unsetKey(Session::KEY_USER_CULTURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [null, null];
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,3 +22,13 @@
|
||||||
<div class="control-item no-label-desktop">
|
<div class="control-item no-label-desktop">
|
||||||
<a href="https://github.com/lbryio"><span class="btn-label">GitHub</span><span class="icon-github icon-fw"></span></a>
|
<a href="https://github.com/lbryio"><span class="btn-label">GitHub</span><span class="icon-github icon-fw"></span></a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-item no-label-desktop">
|
||||||
|
<select id="language-dropdown">
|
||||||
|
<option>en_US</option>
|
||||||
|
<option>pt_PT</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var _currentLang = '<?php echo i18n::getLanguage()."_".i18n::getCountry() ?>';
|
||||||
|
</script>
|
||||||
|
|
|
@ -162,4 +162,13 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var langDropdown = $('#language-dropdown');
|
||||||
|
langDropdown.val(_currentLang);
|
||||||
|
langDropdown.on('change', function(x) {
|
||||||
|
$.ajax({type: 'POST', url: '/language', data: {'culture': this.value},
|
||||||
|
success: function (d) {
|
||||||
|
window.location.reload();
|
||||||
|
}});
|
||||||
|
});
|
||||||
});
|
});
|
Loading…
Add table
Reference in a new issue