mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
i18n: Implement getAllCultures
This commit is contained in:
parent
5539860a0a
commit
0c9e7724af
3 changed files with 15 additions and 5 deletions
|
@ -10,10 +10,10 @@ class i18nActions extends Actions
|
|||
{
|
||||
public static function setCulture()
|
||||
{
|
||||
$culture = isset($_POST['culture']) ? $_POST['culture'] : null;
|
||||
$culture = $_POST['culture'] ?? null;
|
||||
|
||||
// Validate
|
||||
if ($culture && !($culture == 'en_US' || $culture == 'pt_PT'))
|
||||
if ($culture && !in_array($culture, i18n::getAllCultures()))
|
||||
{
|
||||
$culture = null;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ class i18n
|
|||
protected static
|
||||
$language = null,
|
||||
$translations = [],
|
||||
$country = null;
|
||||
$country = null,
|
||||
$cultures = ['pt_PT', 'en_US'];
|
||||
|
||||
public static function register($culture = null) /*needed to trigger class include, presumably setup would happen here*/
|
||||
{
|
||||
|
@ -56,6 +57,11 @@ class i18n
|
|||
return static::$country;
|
||||
}
|
||||
|
||||
public static function getAllCultures()
|
||||
{
|
||||
return static::$cultures;
|
||||
}
|
||||
|
||||
public static function formatCurrency($amount, $currency = 'USD')
|
||||
{
|
||||
return '<span class="formatted-currency">' . money_format('%.2n', $amount) . '</span>';
|
||||
|
|
|
@ -25,8 +25,12 @@
|
|||
<div class="control-item no-label-desktop">
|
||||
<form id="language-form" action="/set-culture" method="POST">
|
||||
<select id="language-dropdown" name="culture">
|
||||
<option>en_US</option>
|
||||
<option>pt_PT</option>
|
||||
<?php
|
||||
foreach (i18n::getAllCultures() as $culture)
|
||||
{
|
||||
echo "<option>$culture</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue