diff --git a/src/Language.php b/src/Language.php index 658b2da..642b195 100644 --- a/src/Language.php +++ b/src/Language.php @@ -246,6 +246,35 @@ public static function getLongCode($short = 'default') return $long; } + /** + * Returns the language short code. + * + * @param string $long + * + * @return string + **/ + public static function getShortCode($long = 'default') + { + if ($long == 'default') { + $long = app()->getLocale(); + } + + $short = 'en'; + + // Get languages from config + $languages = config('language.all'); + + foreach ($languages as $language) { + if ($language['long'] != $long) { + continue; + } + + $short = $language['short']; + } + + return $short; + } + /** * Returns the language name. *