Add the Ol Chiki script (Olck), add getLanguages(), and fix the tests
The tests were using languageData.languages, which was undefined. This patch adds a method to get all the languages to be able to test.
This commit is contained in:
committed by
Niklas Laxström
parent
d6912d6c94
commit
87b3fd8666
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
package-lock.json
|
||||||
supplementalData.xml
|
supplementalData.xml
|
||||||
|
|||||||
@@ -651,7 +651,7 @@ scriptgroups:
|
|||||||
# Tibetan (Tibt) is here, even though it's classified as "Central Asian" by
|
# Tibetan (Tibt) is here, even though it's classified as "Central Asian" by
|
||||||
# Unicode, because linguistically and geographically it's closely related to
|
# Unicode, because linguistically and geographically it's closely related to
|
||||||
# the Brahmic family.
|
# the Brahmic family.
|
||||||
SouthAsian: [Beng, Deva, Gujr, Guru, Knda, Mlym, Orya, Saur, Sinh, Taml, Telu, Tibt, Thaa, Wara]
|
SouthAsian: [Beng, Deva, Gujr, Guru, Knda, Mlym, Olck, Orya, Saur, Sinh, Taml, Telu, Tibt, Thaa, Wara]
|
||||||
Cyrillic: [Cyrl]
|
Cyrillic: [Cyrl]
|
||||||
CJK: [Hans, Hant, Kana, Kore, Jpan, Yiii]
|
CJK: [Hans, Hant, Kana, Kore, Jpan, Yiii]
|
||||||
SouthEastAsian: [Bali, Batk, Bugi, Java, Khmr, Laoo, Mymr, Thai]
|
SouthEastAsian: [Bali, Batk, Bugi, Java, Khmr, Laoo, Mymr, Thai]
|
||||||
|
|||||||
9
index.js
9
index.js
@@ -24,6 +24,14 @@ function isRedirect( language ) {
|
|||||||
return ( isKnown( language ) && languageData.languages[ language ].length === 1 ) ? languageData.languages[ language ][ 0 ] : false;
|
return ( isKnown( language ) && languageData.languages[ language ].length === 1 ) ? languageData.languages[ language ][ 0 ] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the languages
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
|
function getLanguages() {
|
||||||
|
return languageData.languages;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the script of the language.
|
* Returns the script of the language.
|
||||||
* @param {string} language Language code
|
* @param {string} language Language code
|
||||||
@@ -278,6 +286,7 @@ module.exports = {
|
|||||||
getAutonyms,
|
getAutonyms,
|
||||||
getDir,
|
getDir,
|
||||||
getGroupOfScript,
|
getGroupOfScript,
|
||||||
|
getLanguages,
|
||||||
getLanguagesByScriptGroup,
|
getLanguagesByScriptGroup,
|
||||||
getLanguagesByScriptGroupInRegion,
|
getLanguagesByScriptGroupInRegion,
|
||||||
getLanguagesByScriptGroupInRegions,
|
getLanguagesByScriptGroupInRegions,
|
||||||
|
|||||||
@@ -4035,6 +4035,7 @@
|
|||||||
"Guru",
|
"Guru",
|
||||||
"Knda",
|
"Knda",
|
||||||
"Mlym",
|
"Mlym",
|
||||||
|
"Olck",
|
||||||
"Orya",
|
"Orya",
|
||||||
"Saur",
|
"Saur",
|
||||||
"Sinh",
|
"Sinh",
|
||||||
@@ -4757,8 +4758,8 @@
|
|||||||
"ne",
|
"ne",
|
||||||
"sat",
|
"sat",
|
||||||
"ks-arab",
|
"ks-arab",
|
||||||
"gbm",
|
|
||||||
"gom-deva",
|
"gom-deva",
|
||||||
|
"gbm",
|
||||||
"sd",
|
"sd",
|
||||||
"doi",
|
"doi",
|
||||||
"tcy",
|
"tcy",
|
||||||
@@ -5674,4 +5675,4 @@
|
|||||||
"tn"
|
"tn"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
10
package.json
10
package.json
@@ -10,8 +10,8 @@
|
|||||||
"l10n"
|
"l10n"
|
||||||
],
|
],
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Santhosh Thottingal",
|
"name": "Santhosh Thottingal",
|
||||||
"email": "santhosh.thottingal@gmail.com"
|
"email": "santhosh.thottingal@gmail.com"
|
||||||
},
|
},
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Amir Aharoni",
|
"Amir Aharoni",
|
||||||
@@ -29,13 +29,13 @@
|
|||||||
"url": "git://github.com/wikimedia/language-data.git"
|
"url": "git://github.com/wikimedia/language-data.git"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url" : "http://github.com/wikimedia/language-data/issues"
|
"url": "http://github.com/wikimedia/language-data/issues"
|
||||||
},
|
},
|
||||||
"engine": {
|
"engine": {
|
||||||
"node": ">=0.10.x"
|
"node": ">=0.10.x"
|
||||||
},
|
},
|
||||||
"license": "(MIT OR GPL-2.0+)",
|
"license": "(MIT OR GPL-2.0+)",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha"
|
"test": "mocha"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ describe( 'languagedata', function () {
|
|||||||
orphanScripts = function () {
|
orphanScripts = function () {
|
||||||
var language, script,
|
var language, script,
|
||||||
result = [];
|
result = [];
|
||||||
for ( language in languageData.languages ) {
|
for ( language in languageData.getLanguages() ) {
|
||||||
script = languageData.getScript( language );
|
script = languageData.getScript( language );
|
||||||
if ( languageData.getGroupOfScript( script ) === 'Other' ) {
|
if ( languageData.getGroupOfScript( script ) === 'Other' ) {
|
||||||
result.push( script );
|
result.push( script );
|
||||||
@@ -24,9 +24,9 @@ describe( 'languagedata', function () {
|
|||||||
badRedirects = function () {
|
badRedirects = function () {
|
||||||
var language, target,
|
var language, target,
|
||||||
result = [];
|
result = [];
|
||||||
for ( language in languageData.languages ) {
|
for ( language in languageData.getLanguages() ) {
|
||||||
target = languageData.isRedirect( language );
|
target = languageData.isRedirect( language );
|
||||||
if ( target && !languageData.languages[ target ] ) {
|
if ( target && !languageData.getLanguages()[ target ] ) {
|
||||||
result.push( language );
|
result.push( language );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ describe( 'languagedata', function () {
|
|||||||
doubleRedirects = function () {
|
doubleRedirects = function () {
|
||||||
var language, target,
|
var language, target,
|
||||||
result = [];
|
result = [];
|
||||||
for ( language in languageData.languages ) {
|
for ( language in languageData.getLanguages() ) {
|
||||||
target = languageData.isRedirect( language );
|
target = languageData.isRedirect( language );
|
||||||
if ( target && languageData.isRedirect( target ) ) {
|
if ( target && languageData.isRedirect( target ) ) {
|
||||||
result.push( language );
|
result.push( language );
|
||||||
@@ -55,7 +55,7 @@ describe( 'languagedata', function () {
|
|||||||
autonyms = [],
|
autonyms = [],
|
||||||
duplicateAutonyms = [];
|
duplicateAutonyms = [];
|
||||||
|
|
||||||
for ( language in languageData.languages ) {
|
for ( language in languageData.getLanguages() ) {
|
||||||
if ( languageData.isRedirect( language ) ) {
|
if ( languageData.isRedirect( language ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ describe( 'languagedata', function () {
|
|||||||
languagesWithoutAutonym = function () {
|
languagesWithoutAutonym = function () {
|
||||||
var language,
|
var language,
|
||||||
result = [];
|
result = [];
|
||||||
for ( language in languageData.languages ) {
|
for ( language in languageData.getLanguages() ) {
|
||||||
if ( typeof languageData.getAutonym( language ) !== 'string' ) {
|
if ( typeof languageData.getAutonym( language ) !== 'string' ) {
|
||||||
result.push( language );
|
result.push( language );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user