nva-language 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +115 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,2 +1,116 @@
1
1
  # nva-language-js
2
- Javascript implementation of NVA language handling
2
+ Javascript implementation of NVA (the Norwegian national research archive) language handling.
3
+
4
+ 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.
5
+
6
+ NVA-language also routes non-preferred representations to preferred representations.
7
+
8
+ ## Using the library
9
+
10
+ Install with either:
11
+
12
+ ```javascript
13
+ const { <function(s)> } = require('nva-language)
14
+ ```
15
+
16
+ or
17
+
18
+ ```javascript
19
+ import { <function(s)> } from 'nva-language'
20
+ ```
21
+
22
+ (replace <function(s)> with the functions you actually use, see below).
23
+
24
+ Use with:
25
+
26
+ ```javascript
27
+ const english = getLanguageByBokmaalName('Engelsk')
28
+ ```
29
+
30
+ ## The language object
31
+
32
+ All functions return a language object, which has the structure:
33
+
34
+ ```json
35
+ {
36
+ "uri": "http://lexvo.org/id/iso639-3/deu",
37
+ "iso6391Code": "de",
38
+ "iso6392Codes": ["ger", "deu"],
39
+ "iso6393Code": "deu",
40
+ "eng": "German",
41
+ "nob": "Tysk",
42
+ "nno": "Tysk",
43
+ "sme": "Duiskkagiella"
44
+ }
45
+ ```
46
+
47
+ The properties are structured as follows:
48
+
49
+ - uri: a Lexvo ISO 639-3 uri
50
+ - iso6391Code: an ISO 639-1, two-letter code
51
+ - iso6392Codes: an array containing ISO 639-2 B/T three-letter codes (min one, max. two items)
52
+ - iso6393Code: an ISO 639-3 code
53
+ - eng: the English name of the language
54
+ - nob: the Norwegian Bokmål name of the language
55
+ - nno: the Norwegian Nynorsk name of the language
56
+ - sme: the Northern Sami name of the language
57
+
58
+ ## Available functions
59
+
60
+ There are a number of methods provided by nva-language, all of which return a Language object, these have self-explanatory names:
61
+
62
+ - getLanguageByBokmaalName
63
+ - example: `const english = getLanguageByBokmaalName('Engelsk')`
64
+ - 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
65
+ - Matching is not case-sensitive
66
+ - getLanguageByEnglishName
67
+ - example: `const english = getLanguageByEnglishName('English')`
68
+ - 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
69
+ - Matching is not case-sensitive
70
+ - getLanguageByIso6391Code
71
+ - example: `const english = getLanguageByIso6391Code('en')`
72
+ - Given an ISO 639-1 code, returns a Language object that either matches the token, or is the Undefined language
73
+ - Matching is not case-sensitive
74
+ - getLanguageByIso6392Code
75
+ - example: `const english = getLanguageByIso6392Code('eng')`
76
+ - Given an ISO 639-2 code, returns a Language object that either matches the token, or is the Undefined language
77
+ - Returns e.g. a Language object for German if either the B/T ("ger", "deu") variants are supplied
78
+ - Matching is not case-sensitive
79
+ - getLanguageByIso6393Code
80
+ - example: `const english = getLanguageByIso6393Code('eng')`
81
+ - Given an ISO 639-1 code, returns a Language object that either matches the token, or is the Undefined language
82
+ - Matching is not case-sensitive
83
+ - getLanguageByNynorskName
84
+ - example: `const english = getLanguageByNynorskName('Engelsk')`
85
+ - Given a Norwegian Nynorsk token for a language, say "Engelsk", returns a Language object that either matches the token, or is the Undefined language
86
+ - Matching is not case-sensitive
87
+ - The only difference between getLanguageByNynorskName and getLanguageByBokmaalName is Bokmål: "Flere språk", Nynorsk "Fleire språk"
88
+ - getLanguageBySamiName
89
+ - example: `const english = getLanguageBySamiName('Eaŋgalsgiella')`
90
+ - 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
91
+ - Matching is not case-sensitive
92
+ - getLanguageByUri
93
+ - example: `const english = getLanguageByUri(' http://lexvo.org/id/iso639-3/eng')`
94
+ - 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)
95
+ - Note: Lexvo does *not* use HTTPS
96
+
97
+ ## Notes
98
+ ### Valid and invalid languages
99
+
100
+ 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.
101
+
102
+ Thus, some valid languages will return Undefined Language not because they are invalid but because they are undefined in the context of NVA.
103
+
104
+ ### Norwegian
105
+
106
+ 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.
107
+
108
+ 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".
109
+
110
+ ### Sami
111
+
112
+ Since the primary source for the data for this module has been NSD DBH's publication channel data, a choice was made to map all "Samisk" to Northern Sami. This is unfortunate, but it solves the issue in view of a lack of Sami language skills. Sorry about that.
113
+
114
+ ### More than one language
115
+
116
+ We use the ISO 639-3 `mul` code for these cases, which is preferred over the sometimes used `mis` code.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nva-language",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "main": "./dist/LanguageMapper.js",
6
6
  "module": "./src/LanguageMapper.mjs",