Skip to content

Commit

Permalink
added getShortCode method
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Dec 13, 2017
1 parent 1c6fcb4 commit e20facb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit e20facb

Please sign in to comment.