From 3f632e2fe98205a5ea73cb963feb448ca2eba94c Mon Sep 17 00:00:00 2001 From: Mathieu Lu Date: Tue, 14 Nov 2023 15:18:25 -0500 Subject: [PATCH] setup: Allow language selection regarless of whether languages are available --- CRM/Core/CodeGen/I18n.php | 2 + setup/plugins/blocks/l10n.civi-setup.php | 4 +- .../init/AvailableLangs.civi-setup.php | 11 +--- setup/res/languages.php | 56 +++++++++++++++++++ 4 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 setup/res/languages.php diff --git a/CRM/Core/CodeGen/I18n.php b/CRM/Core/CodeGen/I18n.php index 2f71133ba4..4fbe3a31f1 100644 --- a/CRM/Core/CodeGen/I18n.php +++ b/CRM/Core/CodeGen/I18n.php @@ -19,7 +19,9 @@ class CRM_Core_CodeGen_I18n extends CRM_Core_CodeGen_BaseTask { for ($i = 0; $i < count($matches[0]); $i++) { $langs[$matches[1][$i]] = $matches[2][$i]; } + // @todo Somewhere in 2024 or beyond, deprecate the old installer file_put_contents('../install/langs.php', "blocks['l10n'] = array( 'is_active' => TRUE, 'file' => __DIR__ . DIRECTORY_SEPARATOR . 'l10n.tpl.php', - 'class' => 'if-no-errors', - 'weight' => 30, + 'class' => '', + 'weight' => 10, ); }, \Civi\Setup::PRIORITY_PREPARE); diff --git a/setup/plugins/init/AvailableLangs.civi-setup.php b/setup/plugins/init/AvailableLangs.civi-setup.php index 4eb5730d6c..603fa494d3 100644 --- a/setup/plugins/init/AvailableLangs.civi-setup.php +++ b/setup/plugins/init/AvailableLangs.civi-setup.php @@ -19,16 +19,7 @@ if (!defined('CIVI_SETUP')) { $m = $e->getModel(); $langs = NULL; - require implode(DIRECTORY_SEPARATOR, [$m->srcPath, 'install', 'langs.php']); - foreach ($langs as $locale => $_) { - if ($locale == 'en_US') { - continue; - } - if (!file_exists(implode(DIRECTORY_SEPARATOR, array($m->srcPath, 'sql', "civicrm_data.$locale.mysql")))) { - unset($langs[$locale]); - } - } - + require implode(DIRECTORY_SEPARATOR, [$m->srcPath, 'setup', 'res', 'languages.php']); $m->setField('lang', 'options', $langs); }, \Civi\Setup::PRIORITY_PREPARE); diff --git a/setup/res/languages.php b/setup/res/languages.php new file mode 100644 index 0000000000..e93afcc274 --- /dev/null +++ b/setup/res/languages.php @@ -0,0 +1,56 @@ + 'Afrikaans', + 'sq_AL' => 'Albanian', + 'ar_EG' => 'Arabic', + 'bg_BG' => 'Bulgarian', + 'ca_ES' => 'Catalan; Valencian', + 'zh_CN' => 'Chinese (China)', + 'zh_TW' => 'Chinese (Taiwan)', + 'hr_HR' => 'Croatian', + 'cs_CZ' => 'Czech', + 'da_DK' => 'Danish', + 'nl_NL' => 'Dutch (Netherlands)', + 'nl_BE' => 'Dutch (Belgium)', + 'en_AU' => 'English (Australia)', + 'en_CA' => 'English (Canada)', + 'en_GB' => 'English (United Kingdom)', + 'en_US' => 'English (United States)', + 'et_EE' => 'Estonian', + 'fi_FI' => 'Finnish', + 'fr_CA' => 'French (Canada)', + 'fr_FR' => 'French (France)', + 'de_DE' => 'German', + 'de_CH' => 'German (Swiss)', + 'el_GR' => 'Greek, Modern', + 'he_IL' => 'Hebrew (modern)', + 'hi_IN' => 'Hindi', + 'hu_HU' => 'Hungarian', + 'id_ID' => 'Indonesian', + 'it_IT' => 'Italian', + 'ja_JP' => 'Japanese', + 'km_KH' => 'Khmer', + 'lt_LT' => 'Lithuanian', + 'nb_NO' => 'Norwegian Bokmål', + 'fa_IR' => 'Persian (Iran)', + 'pl_PL' => 'Polish', + 'pt_BR' => 'Portuguese (Brazil)', + 'pt_PT' => 'Portuguese (Portugal)', + 'ro_RO' => 'Romanian, Moldavian, Moldovan', + 'ru_RU' => 'Russian', + 'sr_RS' => 'Serbian', + 'sk_SK' => 'Slovak', + 'sl_SI' => 'Slovene', + 'es_ES' => 'Spanish; Castilian (Spain)', + 'es_MX' => 'Spanish; Castilian (Mexico)', + 'es_PR' => 'Spanish; Castilian (Puerto Rico)', + 'sv_SE' => 'Swedish', + 'te_IN' => 'Telugu', + 'th_TH' => 'Thai', + 'tr_TR' => 'Turkish', + 'uk_UA' => 'Ukrainian', + 'vi_VN' => 'Vietnamese', +]; -- 2.25.1