Skip to content

Commit

Permalink
Added entry to .env to configure the default / fallback language
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterZydra committed Feb 18, 2024
1 parent c8ea6db commit f81955b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
APP_URL="http://localhost"
APP_ENV="prod"

APP_LANG="en"

DB_CONNECTION="mariadb"
DB_HOST="127.0.0.1"
DB_PORT=3306
Expand Down
2 changes: 2 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ You can use the file `.env.example` as template.
APP_URL="http://localhost" # URL the application is listening on
APP_ENV="dev" # 'dev' or 'prod'

APP_LANG="en" # Default/fallback language

DB_CONNECTION="mariadb"
DB_HOST="127.0.0.1"
DB_PORT=3306
Expand Down
4 changes: 2 additions & 2 deletions framework/i18n/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Framework\i18n;

use Framework\Config\Config;
use Framework\Facades\File;
use Framework\Facades\Path;

Expand Down Expand Up @@ -44,8 +45,7 @@ public static function translate(string $label): string
{
$lang = Language::getLanguage();
if (!array_key_exists($lang, self::$labels)) {
// TODO Fallback language en -> later as setting?
$lang = 'en';
$lang = Config::env('APP_LANG');
}

if (!array_key_exists($lang, self::$labels) || !(array_key_exists($label, self::$labels[$lang]))) {
Expand Down
1 change: 0 additions & 1 deletion resources/Views/entities/user/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
<?= __('ForcePasswordChange') ?>
</label><br><br>

<?= 'lang' . $user->getLanguageId() ?>
<?= component('languageSelect', ['selected' => $user->getLanguageId()]) ?>

<strong><?= __('Permissions') ?></strong><br>
Expand Down

0 comments on commit f81955b

Please sign in to comment.