Do not restrict language codes to two characters

In fact, they may be of 2-8 characters in length according to [BCP 47] 2.2.1.
I do not really see any reason to validate them anyway, and this way we could
also support e.g. `en-US` vs `en-GB`.

[BCP 47]: https://tools.ietf.org/rfc/bcp/bcp47.txt
This commit is contained in:
Jonas Herzig 2020-05-03 17:27:13 +02:00
parent 0ca2a45358
commit d6d55c9f9c

View file

@ -31,12 +31,7 @@ var _data = {};
* @author svartoyg
*/
async function retrieveData (language) {
const regexp = (new RegExp("^([a-z]{2})$"));
if (regexp.exec(language) === null) {
return Promise.reject(new Error('invalid language code "' + language + '"'));
} else {
return (await import(`../loc/${language}.json`)).default
}
}