Skip to content

Commit

Permalink
try locale without country before returning default translation (#579)
Browse files Browse the repository at this point in the history
before returning default translation, try using locale without country suffix
  • Loading branch information
mjauvin authored Jun 18, 2020
1 parent b1ea008 commit 692ac77
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public function forLocale($locale = null, $default = null)
$locale = self::DEFAULT_LOCALE;
}

if (!array_key_exists($locale, $this->message_data)) {
// search parent locale (e.g. en-US -> en) before returning default
list($locale) = explode('-', $locale);
}

if (array_key_exists($locale, $this->message_data)) {
return $this->message_data[$locale];
}
Expand Down

0 comments on commit 692ac77

Please sign in to comment.