From c6214b855f3c6880e03b356124519c40fbecc3ac Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Tue, 15 Jan 2019 15:04:39 +1300 Subject: [PATCH] MINOR Update add_i18n_javascript to load lowercase-dash language files --- src/View/Requirements_Backend.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/View/Requirements_Backend.php b/src/View/Requirements_Backend.php index 5286ed1f4..272a61988 100644 --- a/src/View/Requirements_Backend.php +++ b/src/View/Requirements_Backend.php @@ -18,6 +18,7 @@ use SilverStripe\Core\Path; use SilverStripe\Dev\Debug; use SilverStripe\Dev\Deprecation; use SilverStripe\i18n\i18n; +use SilverStripe\ORM\FieldType\DBField; class Requirements_Backend { @@ -1004,13 +1005,21 @@ class Requirements_Backend $files = array(); $candidates = array( - 'en.js', - 'en_US.js', - i18n::getData()->langFromLocale(i18n::config()->get('default_locale')) . '.js', - i18n::config()->get('default_locale') . '.js', - i18n::getData()->langFromLocale(i18n::get_locale()) . '.js', - i18n::get_locale() . '.js', + 'en', + 'en_US', + i18n::getData()->langFromLocale(i18n::config()->get('default_locale')), + i18n::config()->get('default_locale'), + i18n::getData()->langFromLocale(i18n::get_locale()), + i18n::get_locale(), + strtolower(DBField::create_field('Locale', i18n::get_locale())->RFC1766()), + strtolower(DBField::create_field('Locale', i18n::config()->get('default_locale'))->RFC1766()) ); + + $candidates = array_map( + function ($candiate) { return $candiate . '.js'; }, + $candidates + ); + foreach ($candidates as $candidate) { $relativePath = Path::join($langDir, $candidate); $absolutePath = Director::getAbsFile($relativePath);