JSPM

  • Created
  • Published
  • Downloads 267478
  • Score
    100M100P100Q166790F
  • License MIT

Is given string a language code (as per IANA)

Package Exports

  • is-language-code

Readme

is-language-code

Is given string a language code (as per IANA)

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:

npm i is-language-code

If you need a legacy version which works with require, use version 3.1.0

Quick Take

import { strict as assert } from "assert";
import { isLangCode } from "is-language-code";

assert.deepEqual(isLangCode("de-419-DE"), {
  res: false,
  message: 'Two region subtags, "419" and "de".',
});

assert.deepEqual(isLangCode("sr-Latn"), {
  res: true,
  message: null,
});

Documentation

Please visit codsen.com for a full description of the API, examples and even a test playground.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License

Copyright (c) 2010-2021 Roy Revelt and other contributors

ok codsen star