From b9489576c4acedbc5ae52599c7515bc99737897f Mon Sep 17 00:00:00 2001 From: Leilei332 Date: Thu, 2 Oct 2025 12:50:33 +0800 Subject: [PATCH] Add checkLanguageCode util function --- core/modules/utils/utils.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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