npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nva-language

v1.0.19

Published

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

Downloads

894

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:

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

or

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

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

Use with:

    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:

  {
    "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

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.