# nva-language

> Javascript implementation of NVA (the Norwegian national research archive) language handling.

Latest version **1.0.25** (published 2026-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install nva-language
pnpm add nva-language
yarn add nva-language
bun add nva-language
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.0.25 |
| Published | 2026-09-09 |
| First published | 2021-10-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 27.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| Author | Rurik Thomas Greenall |
| Maintainers | brinxmat |
| Keywords | NVA language mapper |

## Links

- npm: https://www.npmjs.com/package/nva-language
- Repository: https://github.com/BIBSYSDEV/nva-language-js
- Homepage: https://github.com/BIBSYSDEV/nva-language-js#readme
- Issues: https://github.com/BIBSYSDEV/nva-language-js/issues
- npm.io page: https://npm.io/package/nva-language

## Recent versions

- 1.0.25 (latest) — 2026-09-09
- 1.0.24 — 2026-09-09
- 1.0.23 — 2026-06-15
- 1.0.22 — 2026-06-11
- 1.0.21 — 2026-03-26
- 1.0.19 — 2024-07-09
- 1.0.18 — 2024-07-09
- 1.0.17 — 2024-07-05
- 1.0.16 — 2024-02-11
- 1.0.15 — 2022-11-24
- 1.0.13 — 2022-11-13
- 1.0.12 — 2022-11-13
- 1.0.11 — 2021-10-11
- 1.0.10 — 2021-10-11
- 1.0.9 — 2021-10-08
- … 9 more at https://npm.io/package/nva-language/versions

## README

# nva-language-js
Javascript implementation of NVA (the Norwegian national research archive) language handling.

Languages in NVA are represented by URIs, this module allows users to find the correct URI for a language and find a name string in a given language for each URI without dereferencing the URI.

NVA-language also routes non-preferred representations to preferred representations.

## Using the library

Install with either:

```javascript
    const { <function(s)> } = require('nva-language)
```

or

```javascript
    import { <function(s)> }  from 'nva-language'
```

(replace <function(s)> with the functions you actually use, see below).

Use with:

```javascript
    const bokmaal = getLanguageByBokmaalName('Engelsk')
    const english = getLanguageByEnglishName("English")
    const iso6391 = getLanguageByIso6391Code("en")
    const iso6392 = getLanguageByIso6392Code("eng")
    const iso6393 = getLanguageByIso6393Code("eng")
    const nynorsk = getLanguageByNynorskName("Engelsk")
    const sami = getLanguageBySamiName("Eaŋgalsgiella")
    const uri = getLanguageByUri('http://lexvo.org/id/iso639-3/eng')
```

## The language object

All functions return a language object, which has the structure:

```json
  {
    "uri": "http://lexvo.org/id/iso639-3/deu",
    "iso6391Code": "de",
    "iso6392Codes": ["ger", "deu"],
    "iso6393Code": "deu",
    "eng": "German",
    "nob": "Tysk",
    "nno": "Tysk",
    "sme": "Duiskkagiella"
  }
```

The properties are structured as follows:

-   uri: a Lexvo ISO 639-3 uri
-   iso6391Code: an ISO 639-1, two-letter code
-   iso6392Codes: an array containing ISO 639-2 B/T three\letter codes (min one, max. two items)
-   iso6393Code: an ISO 639-3 code
-   eng: the English name of the language
-   nob: the Norwegian Bokmål name of the language
-   nno: the Norwegian Nynorsk name of the language
-   sme: the Northern Sami name of the language

## Available functions

There are a number of methods provided by nva-language, all of which return a Language object, these have self-explanatory names:

### getLanguageByBokmaalName

-   example: `const english = getLanguageByBokmaalName('Engelsk')`
-   Given a Norwegian Bokmål token for a language, say "Engelsk", returns a Language object that either matches the token, or is the Undefined language
-   Matching is not case sensitive

### getLanguageByEnglishName

-   example: `const english = getLanguageByEnglishName('English')`
-   Given a Norwegian Bokmål token for a language, say "English", returns a Language object that either matches the token, or is the Undefined language
-   Matching is not case sensitive

### getLanguageByIso6391Code

-   example: `const english = getLanguageByIso6391Code('en')`
-   Given an ISO 639-1 code, returns a Language object that either matches the token, or is the Undefined language
-   Matching is not case sensitive

### getLanguageByIso6392Code

-   example: `const english = getLanguageByIso6392Code('eng')`
-   Given an ISO 639-2 code, returns a Language object that either matches the token, or is the Undefined language
-   Returns e.g. a Language object for German if either the B/T ("ger", "deu") variants are supplied
-   Matching is not case sensitive

### getLanguageByIso6393Code

-   example: `const english = getLanguageByIso6393Code('eng')`
-   Given an ISO 639-1 code, returns a Language object that either matches the token, or is the Undefined language
-   Matching is not case sensitive

### getLanguageByNynorskName

-   example: `const english = getLanguageByNynorskName('Engelsk')`
-   Given a Norwegian Nynorsk token for a language, say "Engelsk", returns a Language object that either matches the token, or is the Undefined language
-   Matching is not case sensitive
-   The only difference between getLanguageByNynorskName and getLanguageByBokmaalName is Bokmål "Flere språk", Nynorsk "Fleire språk"
 
### getLanguageBySamiName

-   example: `const english = getLanguageBySamiName('Eaŋgalsgiella')`
-   Given a Northern Sami token for a language, say "Eaŋgalsgiella", returns a Language object that either matches the token, or is the Undefined language
-   Matching is not case sensitive

### getLanguageByUri

-   example: `const english = getLanguageByUri('http://lexvo.org/id/iso639-3/eng')`
-   Given a Lexvo ISO 639-3 URI, returns the corresponding language object or Undefined language (in the case that the URI is not in use)
-   Note: Lexvo does *not* use HTTPS

## Notes

### Valid and invalid languages

The languages supported in NVA are limited to the core languages used in Norwegian research publications, the list grows over time, but the list is still not long.

Thus, some valid languages will return Undefined Language not because they are invalid but because they are undefined in the context of NVA.

### Norwegian

Since NVA is typically concerned with written language, codes and strings related to "Norwegian", as opposed to "Bokmål" and "Nynorsk" are not to be used.

Using a term associated with "Norwegian" will return "Bokmål". No offense is intended here, this mechanism fits better for the majority of cases where texts are marked as "Norwegian".

### Sami

See [NVA's technical notes regarding languages]('https://github.com/BIBSYSDEV/nva-language?tab=readme-ov-file#representing-sami-languages')

### More than one language

We use the ISO 639-3 `mul` code for these cases, which replaces the sometimes-used `mis` code if provided as input.

---
_Source: https://npm.io/package/nva-language · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
