Skip to content

Commit

Permalink
Merge pull request #24764 from eileenmcnaughton/runtime
Browse files Browse the repository at this point in the history
Fix language negotiation exception to be standard
  • Loading branch information
totten authored Oct 20, 2022
2 parents 3d86618 + b3ba538 commit d4e3a1c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Civi/Core/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,12 @@ public static function detect(): Locale {
* Ex: `en_US`, `es_ES`, `fr_CA`
* @return \Civi\Core\Locale
* The effective locale specification.
* @throws \CRM_Core_Exception
*/
public static function negotiate(string $preferred): Locale {
// Create a locale for the requested language
if (!preg_match(';^[a-z][a-z]_[A-Z][A-Z]$;', $preferred)) {
throw new \RuntimeException("Cannot instantiate malformed locale: $preferred");
throw new \CRM_Core_Exception("Cannot instantiate malformed locale: $preferred");
}

$systemDefault = \Civi::settings()->get('lcMessages');
Expand Down

0 comments on commit d4e3a1c

Please sign in to comment.