fix: default plugin language to Polish
This commit is contained in:
@@ -48,7 +48,7 @@ final class Settings
|
||||
public static function defaults(): array
|
||||
{
|
||||
return [
|
||||
'DEFAULT_PLUGIN_LANGUAGE' => 'en',
|
||||
'DEFAULT_PLUGIN_LANGUAGE' => 'pl',
|
||||
'DEFAULT_ENABLE' => 'true',
|
||||
'GLOBAL_AUTORESPONDER_TIMEZONE' => 'Europe/Warsaw',
|
||||
'GLOBAL_AUTORESPONDER_BACKEND' => 'da',
|
||||
@@ -79,8 +79,8 @@ final class Settings
|
||||
|
||||
public function defaultLanguage(): string
|
||||
{
|
||||
$lang = strtolower($this->getString('DEFAULT_PLUGIN_LANGUAGE', 'en'));
|
||||
return preg_match('/^[a-z]{2}$/', $lang) ? $lang : 'en';
|
||||
$lang = strtolower($this->getString('DEFAULT_PLUGIN_LANGUAGE', 'pl'));
|
||||
return preg_match('/^[a-z]{2}$/', $lang) ? $lang : 'pl';
|
||||
}
|
||||
|
||||
public function defaultEnable(): bool
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Domyślny język pluginu, gdy język użytkownika DirectAdmin nie jest obsługiwany.
|
||||
DEFAULT_PLUGIN_LANGUAGE=en
|
||||
DEFAULT_PLUGIN_LANGUAGE=pl
|
||||
|
||||
# Czy plugin jest domyślnie dostępny dla wszystkich użytkowników.
|
||||
# true = dostępny dla każdego użytkownika, false = wymaga indywidualnego włączenia.
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@ name=global-autoresponder
|
||||
id=global-autoresponder
|
||||
type=user
|
||||
author=HITME.PL
|
||||
version=1.0.3
|
||||
version=1.0.4
|
||||
active=no
|
||||
installed=no
|
||||
|
||||
@@ -18,3 +18,17 @@ test('language falls back to default language then English', function (): void {
|
||||
$lang = Lang::load('fr', $settings);
|
||||
assert_same('en', $lang->code());
|
||||
});
|
||||
|
||||
test('user language has priority and default language is only fallback', function (): void {
|
||||
$settingsPath = TEST_TMP . '/lang-priority-settings.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
|
||||
$lang = Lang::load('en', $settings);
|
||||
assert_same('en', $lang->code());
|
||||
assert_same('Global autoresponders', $lang->t('Global autoresponders'));
|
||||
|
||||
$lang = Lang::load('fr', $settings);
|
||||
assert_same('pl', $lang->code());
|
||||
assert_same('Globalne autorespondery', $lang->t('Global autoresponders'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user