mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-05-03 01:57:15 +00:00
Add checkLanguageCode util function
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user