Make all autonyms unique and add a test for this

In a list of languages to select autonyms must be unique so that
every user would know what to select.

* Batak Toba language in the Batak writing variant (bbc-batk) has
  an autonum in the right script now. This is taken from the Indonesian
  Wikipedia article "Surat Batak".
* Similarly to the practice with pa -> pa-guru:
  * iu for Inuktitut in the Canadian script redirects to ike-cans.
  * ks for Kashmiri in the Arabic writing redirects to ks-arab.
  * tg for Tajik in the Cyrillic script redirects to tg-cyrl.
* zgh has an updated autonym, taken from Ethologue.
* zh-classical redirects to lzh, similarly to zh-yue -> yue.
This commit is contained in:
Amire80
2017-06-09 20:35:47 +03:00
parent e01c2e6440
commit 777d71e0d2
4 changed files with 50 additions and 46 deletions

View File

@@ -20,7 +20,7 @@
module( 'jquery.uls' );
var orphanScripts, badRedirects, doubleRedirects, languagesWithoutAutonym;
var orphanScripts, badRedirects, doubleRedirects, doubleAutonyms, languagesWithoutAutonym;
/*
* Runs over all script codes mentioned in langdb and checks whether
@@ -59,6 +59,31 @@
return result;
};
/*
* Runs over all languages and checks that all autonyms are unique.
*/
doubleAutonyms = function () {
var language, autonym,
autonyms = [],
duplicateAutonyms = [];
for ( language in $.uls.data.languages ) {
if ( $.uls.data.isRedirect( language ) ) {
continue;
}
autonym = $.uls.data.getAutonym( language );
if ( $.inArray( autonym, autonyms ) > -1 ) {
duplicateAutonyms.push( language );
}
autonyms.push( autonym );
}
return duplicateAutonyms;
};
/*
* Runs over all languages and checks that all redirects point to a language.
* There's no reason to have double redirects.
@@ -99,7 +124,7 @@
assert.ok( $.fn.uls, '$.fn.uls is defined' );
} );
test( '-- $.uls.data testing', 30, function ( assert ) {
test( '-- $.uls.data testing', 31, function ( assert ) {
var autonyms,
languagesToGroup, groupedLanguages;
@@ -126,6 +151,7 @@
assert.deepEqual( badRedirects(), [], 'All redirects have valid targets.' );
assert.deepEqual( doubleRedirects(), [], 'There are no double redirects.' );
assert.deepEqual( languagesWithoutAutonym(), [], 'All languages have autonyms.' );
assert.deepEqual( doubleAutonyms(), [], 'All languages have distinct autonyms.' );
assert.strictEqual(
$.uls.data.getGroupOfScript( 'Beng' ),