From 9669fe90d705aa288071b4b022332d5e9f5ae0ef Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Sat, 3 Oct 2015 14:07:27 +0200 Subject: [PATCH] If the language name is region-specific (longer then 2 chars), then return it in a readable way, e.g. English (US) / English (GB) --- system/src/Grav/Common/Language/LanguageCodes.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Language/LanguageCodes.php b/system/src/Grav/Common/Language/LanguageCodes.php index 73b8b3cce..2683c8b0a 100644 --- a/system/src/Grav/Common/Language/LanguageCodes.php +++ b/system/src/Grav/Common/Language/LanguageCodes.php @@ -744,7 +744,11 @@ class LanguageCodes public static function getNativeName($code) { - return static::get($code, 'nativeName'); + if (strlen($code) == 2) { + return static::get($code, 'nativeName'); + } else { + return static::get(substr($code, 0, 2), 'nativeName') . ' (' . substr($code, -2) . ')'; + } } public static function getNames(array $keys)