From 8a0dba7b8d0fb886918d07d4c96b420914c58015 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 7 Apr 2020 21:14:38 -0700 Subject: [PATCH] CRM_Core_I18n - Provide a better label for new/unknown locales Overview -------- Suppose you add new/unrecognized data files in the `l10n` folder - and then you navigate to the screen `civicrm/admin/setting/localization?reset=1`. Before ------ The new language appears in the admin UI as a blank item. Every page in the app displays a warning about the unrecognized locale. After ----- The new language appears in the admin UI with a placeholder name (based on the code). The warnings are not displayed. Comment ------- We've just had an issue where a new language was added to the `l10n` data-set, and then all automated test-suites for all versions (incl `5.25` RC and `5.24` stable) started to throw blocker errors on unrelated PRs. This is because the `l10n` data is generally evergreen, but each branch/tag of `civicrm-core` has the list hard-coded in multiple spots. This patch tries to make the symptom less painful when mixing/matching different revisions of `civicrm-core.git` and `l10n.git`. --- CRM/Core/I18n.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index aff19c9f80d1..2f0e3207f352 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -193,7 +193,7 @@ public static function languages($justEnabled = FALSE) { if (preg_match('/^[a-z][a-z]_[A-Z][A-Z]$/', $filename)) { $codes[] = $filename; if (!isset($all[$filename])) { - $all[$filename] = $labels[$filename]; + $all[$filename] = $labels[$filename] ?? "($filename)"; } } }