nva-language 1.0.3 → 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.
- package/.babelrc +4 -1
- package/README.md +115 -1
- package/dist/LanguageConstants.js +1 -1
- package/dist/LanguageMapper.js +1 -1
- package/package.json +3 -2
- package/src/Language.mjs +12 -0
- package/src/LanguageConstants.mjs +57 -0
- package/src/LanguageMapper.mjs +45 -0
- package/.github/workflows/node.js.yaml +0 -22
- package/.github/workflows/npm.publish.yaml +0 -21
- package/dist/tests/Behaviour.test.js +0 -57
package/.babelrc
CHANGED
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.
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ALL_LANGUAGES = exports.UNDEFINED_LANGUAGE = exports.HUNGARIAN = exports.CZECH = exports.POLISH = exports.CHINESE = exports.CATALAN = exports.GREEK = exports.BULGARIAN = exports.AFRIKAANS = exports.MULTIPLE = exports.SWEDISH = exports.SPANISH = exports.RUSSIAN = exports.PORTUGUESE = exports.NORWEGIAN = exports.ITALIAN = exports.ICELANDIC = exports.FINNISH = exports.DANISH = exports.DUTCH = exports.GERMAN = exports.FRENCH = exports.SAMI = exports.NYNORSK = exports.BOKMAAL = exports.ENGLISH = void 0;
|
|
7
7
|
|
|
8
|
-
var _Language = _interopRequireDefault(require("./Language.
|
|
8
|
+
var _Language = _interopRequireDefault(require("./Language.js"));
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
11
|
|
package/dist/LanguageMapper.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getLanguageByUri = exports.getLanguageBySamiName = exports.getLanguageByNynorskName = exports.getLanguageByBokmaalName = exports.getLanguageByEnglishName = exports.getLanguageByIso6393Code = exports.getLanguageByIso6392Code = exports.getLanguageByIso6391Code = void 0;
|
|
7
7
|
|
|
8
|
-
var _LanguageConstants = require("./LanguageConstants.
|
|
8
|
+
var _LanguageConstants = require("./LanguageConstants.js");
|
|
9
9
|
|
|
10
10
|
var convertString = function convertString(string) {
|
|
11
11
|
return string !== null ? string.trim().toLowerCase() : '';
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nva-language",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/LanguageMapper.js",
|
|
6
|
-
"module": "./src/
|
|
6
|
+
"module": "./src/LanguageMapper.mjs",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"lint": "eslint . --ext .mjs --ext .js",
|
|
9
9
|
"lint:fix": "npm run lint -- --fix",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"@babel/cli": "^7.15.7",
|
|
30
30
|
"@babel/core": "^7.15.5",
|
|
31
31
|
"@babel/preset-env": "^7.15.6",
|
|
32
|
+
"babel-plugin-replace-import-extension": "^1.1.1",
|
|
32
33
|
"c8": "^7.9.0",
|
|
33
34
|
"chai": "^4.3.4",
|
|
34
35
|
"eslint-config-standard": "^16.0.3",
|
package/src/Language.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default (iso6391Code, iso6392Code, iso6393Code, eng, nob, nno, sme) => {
|
|
2
|
+
return {
|
|
3
|
+
uri: `http://lexvo.org/id/iso639-3/${iso6393Code}`,
|
|
4
|
+
iso6391Code: iso6391Code,
|
|
5
|
+
iso6392Codes: iso6392Code,
|
|
6
|
+
iso6393Code: iso6393Code,
|
|
7
|
+
eng: eng,
|
|
8
|
+
nob: nob,
|
|
9
|
+
nno: nno,
|
|
10
|
+
sme: sme
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Language from './Language.mjs'
|
|
2
|
+
|
|
3
|
+
export const ENGLISH = Language('en', ['eng'], 'eng', 'English', 'Engelsk', 'Engelsk', 'Eaŋgalsgiella')
|
|
4
|
+
export const BOKMAAL = Language('nb', ['nob'], 'nob', 'Bokmål', 'Bokmål', 'Bokmål', 'Girjedárogiella')
|
|
5
|
+
export const NYNORSK = Language('nn', ['nno'], 'nno', 'Nynorsk', 'Nynorsk', 'Nynorsk', 'Ođđadárogiella')
|
|
6
|
+
export const SAMI = Language('se', [], 'sme', 'Sami', 'Samisk', 'Samisk', 'Davvisámegiella')
|
|
7
|
+
export const FRENCH = Language('fr', ['fra', 'fre'], 'fra', 'French', 'Fransk', 'Fransk', 'Fránskkagiella')
|
|
8
|
+
export const GERMAN = Language('de', ['deu', 'ger'], 'deu', 'German', 'Tysk', 'Tysk', 'Duiskkagiella')
|
|
9
|
+
export const DUTCH = Language('nl', ['nld', 'dut'], 'nld', 'Dutch', 'Nederlandsk', 'Nederlandsk', 'Hollánddagiella')
|
|
10
|
+
export const DANISH = Language('da', ['dan'], 'dan', 'Danish', 'Dansk', 'Dansk', 'Dánskkagiella')
|
|
11
|
+
export const FINNISH = Language('fi', ['fin'], 'fin', 'Finnish', 'Finsk', 'Finsk', 'Suomagiella')
|
|
12
|
+
export const ICELANDIC = Language('is', ['isl', 'ice'], 'isl', 'Icelandic', 'Islandsk', 'Islandsk', 'Islánddagiella')
|
|
13
|
+
export const ITALIAN = Language('it', ['ita'], 'ita', 'Italian', 'Italiensk', 'Italiensk', 'Itáliagiella')
|
|
14
|
+
export const NORWEGIAN = Language('no', ['nor'], 'nor', 'Norwegian', 'Norsk', 'Norsk', 'Dárogiella')
|
|
15
|
+
export const PORTUGUESE = Language('pt', ['por'], 'por', 'Portuguese', 'Portugisisk', 'Portugisisk', 'Portugálagiella')
|
|
16
|
+
export const RUSSIAN = Language('ru', ['rus'], 'rus', 'Russian', 'Russisk', 'Russisk', 'Ruoššagiella')
|
|
17
|
+
export const SPANISH = Language('es', ['spa'], 'spa', 'Spanish', 'Spansk', 'Spansk', 'Spánskkagiella')
|
|
18
|
+
export const SWEDISH = Language('sv', ['swe'], 'swe', 'Swedish', 'Svensk', 'Svensk', 'Ruoŧagiella')
|
|
19
|
+
export const MULTIPLE = Language(null, ['mul'], 'mul', 'Multiple languages', 'Flere språk', 'Fleire språk', 'gielat')
|
|
20
|
+
export const AFRIKAANS = Language('af', ['afr'], 'afr', 'Afrikaans', 'Afrikaans', 'Afrikaans', 'Afrikánsagiella')
|
|
21
|
+
export const BULGARIAN = Language('bg', ['bul'], 'bul', 'Bulgarian', 'Bulgarsk', 'Bulgarsk', 'Bulgáriagiella')
|
|
22
|
+
export const GREEK = Language('el', ['gre', 'ell'], 'ell', 'Greek', 'Gresk', 'Gresk', 'Greikkagiella')
|
|
23
|
+
export const CATALAN = Language('ca', ['cat'], 'car', 'Catalan', 'Katalansk', 'Katalansk', 'Katalánagiella')
|
|
24
|
+
export const CHINESE = Language('zh', ['zho', 'chi'], 'zho', 'Chinese', 'Kinesisk', 'Kinesisk', 'Kiinnágiella')
|
|
25
|
+
export const POLISH = Language('pl', ['pol'], 'pol', 'Polish', 'Polsk', 'Polsk', 'Polskkagiella')
|
|
26
|
+
export const CZECH = Language('cs', ['ces', 'cze'], 'ces', 'Czech', 'Tsjekkisk', 'Tsjekkisk', 'Čeahkagiella')
|
|
27
|
+
export const HUNGARIAN = Language('hu', ['hun'], 'hun', 'Hungarian', 'Ungarsk', 'Ungarsk', 'Ungárgiella')
|
|
28
|
+
export const UNDEFINED_LANGUAGE = Language(null, ['und'], 'und', 'Unknown language', 'Ukjent språk', 'Ukjent språk', 'Dovdameahttun giella')
|
|
29
|
+
|
|
30
|
+
export const ALL_LANGUAGES = Object.freeze([
|
|
31
|
+
ENGLISH,
|
|
32
|
+
BOKMAAL,
|
|
33
|
+
NYNORSK,
|
|
34
|
+
SAMI,
|
|
35
|
+
FRENCH,
|
|
36
|
+
GERMAN,
|
|
37
|
+
DUTCH,
|
|
38
|
+
DANISH,
|
|
39
|
+
FINNISH,
|
|
40
|
+
ICELANDIC,
|
|
41
|
+
ITALIAN,
|
|
42
|
+
NORWEGIAN,
|
|
43
|
+
PORTUGUESE,
|
|
44
|
+
RUSSIAN,
|
|
45
|
+
SPANISH,
|
|
46
|
+
SWEDISH,
|
|
47
|
+
MULTIPLE,
|
|
48
|
+
UNDEFINED_LANGUAGE,
|
|
49
|
+
AFRIKAANS,
|
|
50
|
+
BULGARIAN,
|
|
51
|
+
GREEK,
|
|
52
|
+
CATALAN,
|
|
53
|
+
CHINESE,
|
|
54
|
+
POLISH,
|
|
55
|
+
CZECH,
|
|
56
|
+
HUNGARIAN
|
|
57
|
+
])
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ALL_LANGUAGES, UNDEFINED_LANGUAGE, BOKMAAL, NORWEGIAN } from './LanguageConstants.mjs'
|
|
2
|
+
|
|
3
|
+
const convertString = string => string !== null ? string.trim().toLowerCase() : ''
|
|
4
|
+
|
|
5
|
+
const mappedValue = language => {
|
|
6
|
+
if (language === null || language === undefined) {
|
|
7
|
+
return UNDEFINED_LANGUAGE
|
|
8
|
+
}
|
|
9
|
+
if (NORWEGIAN === language) {
|
|
10
|
+
return BOKMAAL
|
|
11
|
+
}
|
|
12
|
+
return language
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const getLanguageByIso6391Code = code => mappedValue(
|
|
16
|
+
ALL_LANGUAGES.find(language => convertString(code) === language.iso6391Code)
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
export const getLanguageByIso6392Code = code => mappedValue(
|
|
20
|
+
ALL_LANGUAGES.find(language => language.iso6392Codes.find(variant => convertString(code) === variant))
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
export const getLanguageByIso6393Code = code => mappedValue(
|
|
24
|
+
ALL_LANGUAGES.find(language => convertString(code) === language.iso6393Code)
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
export const getLanguageByEnglishName = name => mappedValue(
|
|
28
|
+
ALL_LANGUAGES.find(language => convertString(name) === language.eng.toLowerCase())
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
export const getLanguageByBokmaalName = name => mappedValue(
|
|
32
|
+
ALL_LANGUAGES.find(language => convertString(name) === language.nob.toLowerCase())
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
export const getLanguageByNynorskName = name => mappedValue(
|
|
36
|
+
ALL_LANGUAGES.find(language => convertString(name) === language.nno.toLowerCase())
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
export const getLanguageBySamiName = name => mappedValue(
|
|
40
|
+
ALL_LANGUAGES.find(language => convertString(name) === language.sme.toLowerCase())
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
export const getLanguageByUri = (uri) => mappedValue(
|
|
44
|
+
ALL_LANGUAGES.find(language => convertString(uri) === language.uri)
|
|
45
|
+
)
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
name: Node.js CI
|
|
2
|
-
|
|
3
|
-
on: [push,pull_request]
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
build:
|
|
7
|
-
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v2
|
|
12
|
-
- uses: volta-cli/action@v1
|
|
13
|
-
- run: npm ci
|
|
14
|
-
- run: npm run build --if-present
|
|
15
|
-
- run: npm test
|
|
16
|
-
- run: npm run coverage
|
|
17
|
-
# Disabling for now since codaacy-coverage-reporter does not currently support ECMAScript modules
|
|
18
|
-
# - name: codacy-coverage-reporter
|
|
19
|
-
# uses: codacy/codacy-coverage-reporter-action@v1.1.0
|
|
20
|
-
# with:
|
|
21
|
-
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
|
22
|
-
# coverage-reports: coverage/cobertura-coverage.xml
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
name: Publish
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
build:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v1
|
|
13
|
-
- uses: volta-cli/action@v1.7.0
|
|
14
|
-
- name: Publishing steps
|
|
15
|
-
run: |
|
|
16
|
-
npm install
|
|
17
|
-
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
|
|
18
|
-
npm run build
|
|
19
|
-
npm publish --ignore-scripts
|
|
20
|
-
env:
|
|
21
|
-
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _mocha = require("mocha");
|
|
4
|
-
|
|
5
|
-
var _LanguageMapper = require("../LanguageMapper.mjs");
|
|
6
|
-
|
|
7
|
-
var _LanguageConstants = require("../LanguageConstants.mjs");
|
|
8
|
-
|
|
9
|
-
var _chai = _interopRequireDefault(require("chai"));
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
-
|
|
13
|
-
var expect = _chai["default"].expect;
|
|
14
|
-
(0, _mocha.describe)('String values exist', function () {
|
|
15
|
-
(0, _mocha.it)('should return expected URI"', function () {
|
|
16
|
-
_LanguageConstants.ALL_LANGUAGES.forEach(function (language) {
|
|
17
|
-
return expect(language.uri).to.equal('http://lexvo.org/id/iso639-3/' + language.iso6393Code);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
(0, _mocha.it)('should return English when input is valid', function () {
|
|
21
|
-
expect((0, _LanguageMapper.getLanguageByIso6391Code)('en')).to.equal(_LanguageConstants.ENGLISH);
|
|
22
|
-
expect((0, _LanguageMapper.getLanguageByIso6392Code)('eng')).to.equal(_LanguageConstants.ENGLISH);
|
|
23
|
-
expect((0, _LanguageMapper.getLanguageByIso6393Code)('eng')).to.equal(_LanguageConstants.ENGLISH);
|
|
24
|
-
expect((0, _LanguageMapper.getLanguageByEnglishName)('english')).to.equal(_LanguageConstants.ENGLISH);
|
|
25
|
-
expect((0, _LanguageMapper.getLanguageByBokmaalName)('engelsk')).to.equal(_LanguageConstants.ENGLISH);
|
|
26
|
-
expect((0, _LanguageMapper.getLanguageByNynorskName)('engelsk')).to.equal(_LanguageConstants.ENGLISH);
|
|
27
|
-
expect((0, _LanguageMapper.getLanguageBySamiName)('eaŋgalsgiella')).to.equal(_LanguageConstants.ENGLISH);
|
|
28
|
-
});
|
|
29
|
-
(0, _mocha.it)('should return German when input is ISO 639-2 variant', function () {
|
|
30
|
-
['deu', 'ger'].forEach(function (variant) {
|
|
31
|
-
expect((0, _LanguageMapper.getLanguageByIso6392Code)(variant)).to.equal(_LanguageConstants.GERMAN);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
(0, _mocha.it)('should return Bokmål when input is Norwegian', function () {
|
|
35
|
-
expect((0, _LanguageMapper.getLanguageByIso6391Code)('no')).to.equal(_LanguageConstants.BOKMAAL);
|
|
36
|
-
expect((0, _LanguageMapper.getLanguageByIso6392Code)('nor')).to.equal(_LanguageConstants.BOKMAAL);
|
|
37
|
-
expect((0, _LanguageMapper.getLanguageByIso6393Code)('nor')).to.equal(_LanguageConstants.BOKMAAL);
|
|
38
|
-
expect((0, _LanguageMapper.getLanguageByEnglishName)('norwegian')).to.equal(_LanguageConstants.BOKMAAL);
|
|
39
|
-
expect((0, _LanguageMapper.getLanguageByBokmaalName)('norsk')).to.equal(_LanguageConstants.BOKMAAL);
|
|
40
|
-
expect((0, _LanguageMapper.getLanguageByNynorskName)('norsk')).to.equal(_LanguageConstants.BOKMAAL);
|
|
41
|
-
expect((0, _LanguageMapper.getLanguageBySamiName)('dárogiella')).to.equal(_LanguageConstants.BOKMAAL);
|
|
42
|
-
});
|
|
43
|
-
(0, _mocha.it)('should return Undefined language when input is ISO 639-1 Unknown', function () {
|
|
44
|
-
expect((0, _LanguageMapper.getLanguageByIso6391Code)('øl')).to.equal(_LanguageConstants.UNDEFINED_LANGUAGE);
|
|
45
|
-
});
|
|
46
|
-
(0, _mocha.it)('should return Undefined language when input is ISO 639-1 empty', function () {
|
|
47
|
-
[null, '', ' ', '\t', '\r\n'].forEach(function (input) {
|
|
48
|
-
expect((0, _LanguageMapper.getLanguageByIso6391Code)(input)).to.equal(_LanguageConstants.UNDEFINED_LANGUAGE);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
(0, _mocha.it)('should return language when input is valid URI', function () {
|
|
52
|
-
expect((0, _LanguageMapper.getLanguageByUri)('http://lexvo.org/id/iso639-3/eng')).to.equal(_LanguageConstants.ENGLISH);
|
|
53
|
-
});
|
|
54
|
-
(0, _mocha.it)('should return undefined when input is unknown URI', function () {
|
|
55
|
-
expect((0, _LanguageMapper.getLanguageByUri)('http://example.org/spambot')).to.equal(_LanguageConstants.UNDEFINED_LANGUAGE);
|
|
56
|
-
});
|
|
57
|
-
});
|