diff --git a/core/modules/utils/utils.js b/core/modules/utils/utils.js index a228f91d4..621b3572e 100644 --- a/core/modules/utils/utils.js +++ b/core/modules/utils/utils.js @@ -162,6 +162,18 @@ exports.toTitleCase = function(str) { return (str || "").replace(/(^|\s)\S/g, function(c) {return c.toUpperCase();}); } +/* +Check whether a language code is supported by Intl +*/ +exports.checkLanguageCode = lang => { + try { + "a".localeCompare("a", lang); + return true; + } catch(e) { + return false; + } +} + /* Find the line break preceding a given position in a string Returns position immediately after that line break, or the start of the string