Skip to content

Commit 94b5584

Browse files
committed
Adds a fallback locale for not supported langs in DateTimeRangeGrammar. See #72948
1 parent 5312dab commit 94b5584

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/elements/DateTime/DateTimeRangeGrammar.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class CUI.DateTimeRangeGrammar
6565
#
6666
# KEY: (optional) Identifier that is used in the format method.
6767
###
68+
@SUPPORTED_LOCALES = ["de-DE", "en-US"]
69+
@DEFAULT_LOCALE = "en-US"
6870
@PARSE_GRAMMARS = {} # TODO: Add ES & IT.
6971
@PARSE_GRAMMARS["de-DE"] = [
7072
["DATE bis DATE", "range", [0, 2], null, "RANGE"]
@@ -464,6 +466,11 @@ class CUI.DateTimeRangeGrammar
464466

465467
# Main method to check against every grammar.
466468
@stringToDateRange: (input, locale = CUI.DateTime.getLocale()) ->
469+
470+
if locale not in CUI.DateTimeRangeGrammar.SUPPORTED_LOCALES
471+
console.warn("Locale not supported for stringToDateRange: #{locale}, using default locale: #{CUI.DateTimeRangeGrammar.DEFAULT_LOCALE}")
472+
locale = CUI.DateTimeRangeGrammar.DEFAULT_LOCALE
473+
467474
if CUI.util.isEmpty(input) or not CUI.util.isString(input)
468475
return error: "Input needs to be a non empty string: #{input}"
469476

0 commit comments

Comments
 (0)