mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Some fixes for #1362
This commit is contained in:
parent
4400af04c7
commit
1a331dc3ba
1 changed files with 15 additions and 15 deletions
|
|
@ -4,8 +4,8 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
{
|
{
|
||||||
const
|
const
|
||||||
NAME = 'Nextcloud',
|
NAME = 'Nextcloud',
|
||||||
VERSION = '2.27',
|
VERSION = '2.28',
|
||||||
RELEASE = '2023-12-11',
|
RELEASE = '2023-12-17',
|
||||||
CATEGORY = 'Integrations',
|
CATEGORY = 'Integrations',
|
||||||
DESCRIPTION = 'Integrate with Nextcloud v20+',
|
DESCRIPTION = 'Integrate with Nextcloud v20+',
|
||||||
REQUIRED = '2.27.0';
|
REQUIRED = '2.27.0';
|
||||||
|
|
@ -248,9 +248,8 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
public function FilterLanguage(&$sLanguage, $bAdmin) : void
|
public function FilterLanguage(&$sLanguage, $bAdmin) : void
|
||||||
{
|
{
|
||||||
if (!\RainLoop\Api::Config()->Get('webmail', 'allow_languages_on_settings', true)) {
|
if (!\RainLoop\Api::Config()->Get('webmail', 'allow_languages_on_settings', true)) {
|
||||||
$aResultLang = \SnappyMail\L10n::getLanguages(false);
|
$aResultLang = \SnappyMail\L10n::getLanguages($bAdmin);
|
||||||
$user = \OC::$server->getUserSession()->getUser();
|
$userId = \OC::$server->getUserSession()->getUser()->getUID();
|
||||||
$userId = $user->getUID();
|
|
||||||
$userLang = \OC::$server->getConfig()->getUserValue($userId, 'core', 'lang', 'en');
|
$userLang = \OC::$server->getConfig()->getUserValue($userId, 'core', 'lang', 'en');
|
||||||
$sLanguage = $this->determineLocale($userLang, $aResultLang);
|
$sLanguage = $this->determineLocale($userLang, $aResultLang);
|
||||||
// Check if $sLanguage is null
|
// Check if $sLanguage is null
|
||||||
|
|
@ -268,21 +267,22 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
*
|
*
|
||||||
* @return string return locale
|
* @return string return locale
|
||||||
*/
|
*/
|
||||||
private function determineLocale (string $langCode, array $languagesArray) : string {
|
private function determineLocale(string $langCode, array $languagesArray) : ?string
|
||||||
|
{
|
||||||
// Direct check for the language code
|
// Direct check for the language code
|
||||||
if (in_array($langCode, $languagesArray)) {
|
if (\in_array($langCode, $languagesArray)) {
|
||||||
return $langCode;
|
return $langCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check with uppercase country code
|
// Check with uppercase country code
|
||||||
$langCodeWithUpperCase = $langCode . '-' . strtoupper($langCode);
|
$langCodeWithUpperCase = $langCode . '-' . \strtoupper($langCode);
|
||||||
if (in_array($langCodeWithUpperCase, $languagesArray)) {
|
if (\in_array($langCodeWithUpperCase, $languagesArray)) {
|
||||||
return $langCodeWithUpperCase;
|
return $langCodeWithUpperCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterating to find a match starting with langCode
|
// Iterating to find a match starting with langCode
|
||||||
foreach ($languagesArray as $localeValue) {
|
foreach ($languagesArray as $localeValue) {
|
||||||
if (strpos($localeValue, $langCode) === 0) {
|
if (\str_starts_with($localeValue, $langCode)) {
|
||||||
return $localeValue;
|
return $localeValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue