Skip to content

Commit

Permalink
Exclude language selector from translations
Browse files Browse the repository at this point in the history
  • Loading branch information
jorikfon committed Sep 16, 2024
1 parent ab926b8 commit 704199d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/Common/Messages/languages.php

This file was deleted.

47 changes: 40 additions & 7 deletions src/Common/Providers/MessagesProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,8 @@ function () use ($di, $coreConfig) {
}

// Load language static array
$langFile = appPath("/src/Common/Messages/languages.php");
if (file_exists($langFile)) {
$langArr = self::includeLanguageFile($langFile);
if (!empty($langArr)) {
$translates = array_merge($translates, $langArr);
}
}
$translates = array_merge($translates, self::getAvailableLanguages());

if ($cacheKey) {
$di->get(ManagedCacheProvider::SERVICE_NAME)->set($cacheKey, $translates);
}
Expand Down Expand Up @@ -146,4 +141,42 @@ private static function includeLanguageFile(string $path): array
// Return an empty array if there was an error or $langArr is not an array.
return [];
}

/**
* Retrieve the list of available languages for system selectors.
* Each language is represented in its own native language.
*
* @return array An associative array where keys are language codes and values are language names in their native form.
*/
public static function getAvailableLanguages():array
{
return [
'ex_Russian' => 'Русский',
'ex_English' => 'English',
'ex_EnglishUK' => 'English (UK)',
'ex_Japanese' => '日本語',
'ex_Deutsch' => 'Deutsch',
'ex_Danish' => 'Dansk',
'ex_Spanish' => 'Español',
'ex_Greek' => 'Ελληνικά',
'ex_French' => 'Français',
'ex_Italian' => 'Italiano',
'ex_Portuguese' => 'Português',
'ex_PortugueseBrazil' => 'Português (Brasil)',
'ex_Ukrainian' => 'Українська',
'ex_Vietnamese' => 'Tiếng Việt',
'ex_Chinese' => '中文',
'ex_Polish' => 'Polski',
'ex_Dutch' => 'Nederlands',
'ex_Swedish' => 'Svenska',
'ex_Czech' => 'Čeština',
'ex_Turkish' => 'Türkçe',
'ex_Georgian' => 'ქართული',
'ex_Azerbaijan' => 'Azərbaycan',
'ex_Romanian' => 'Română',
'ex_Thai' => 'ไทย',
'ex_Finnish' => 'Suomi',
'ex_Hungarian' => 'Magyar',
];
}
}

0 comments on commit 704199d

Please sign in to comment.