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()
|
public static function setCulture()
|
||||||
{
|
{
|
||||||
$culture = isset($_POST['culture']) ? $_POST['culture'] : null;
|
$culture = $_POST['culture'] ?? null;
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
if ($culture && !($culture == 'en_US' || $culture == 'pt_PT'))
|
if ($culture && !in_array($culture, i18n::getAllCultures()))
|
||||||
{
|
{
|
||||||
$culture = null;
|
$culture = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,8 @@ class i18n
|
||||||
protected static
|
protected static
|
||||||
$language = null,
|
$language = null,
|
||||||
$translations = [],
|
$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*/
|
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;
|
return static::$country;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getAllCultures()
|
||||||
|
{
|
||||||
|
return static::$cultures;
|
||||||
|
}
|
||||||
|
|
||||||
public static function formatCurrency($amount, $currency = 'USD')
|
public static function formatCurrency($amount, $currency = 'USD')
|
||||||
{
|
{
|
||||||
return '<span class="formatted-currency">' . money_format('%.2n', $amount) . '</span>';
|
return '<span class="formatted-currency">' . money_format('%.2n', $amount) . '</span>';
|
||||||
|
|
|
@ -25,8 +25,12 @@
|
||||||
<div class="control-item no-label-desktop">
|
<div class="control-item no-label-desktop">
|
||||||
<form id="language-form" action="/set-culture" method="POST">
|
<form id="language-form" action="/set-culture" method="POST">
|
||||||
<select id="language-dropdown" name="culture">
|
<select id="language-dropdown" name="culture">
|
||||||
<option>en_US</option>
|
<?php
|
||||||
<option>pt_PT</option>
|
foreach (i18n::getAllCultures() as $culture)
|
||||||
|
{
|
||||||
|
echo "<option>$culture</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue