Merge pull request #73 from amire80/2013-01-09-fixes

2013 01 09 fixes
This commit is contained in:
Siebrand Mazeland
2013-01-09 05:20:43 -08:00
6 changed files with 43 additions and 19 deletions

View File

@@ -312,7 +312,8 @@ languages:
nl-informal: [Latn, [EU, AM], Nederlands (informeel)]
nl: [Latn, [EU, AM], Nederlands]
nn: [Latn, [EU], norsk (nynorsk)]
"no": [Latn, [EU]]
# There's also nb for Bokmål and nn for Nynorsk
"no": [Latn, [EU], norsk]
nov: [Latn, [WW], Novial]
nqo: [Nkoo, [AF], ߒߞߏ]
nrm: [Latn, [EU], Nouormand]

View File

@@ -72,6 +72,7 @@ $json = json_encode( $parsedLangdb );
$js = <<<JAVASCRIPT
// Please do not edit. This file is generated from data/langdb.yaml by ulsdata2json.php
( function ( $ ) {
'use strict';
$.uls = $.uls || {};
$.uls.data = $json;
} ( jQuery ) );

File diff suppressed because one or more lines are too long

View File

@@ -220,7 +220,6 @@
return $.uls.data.getLanguagesByScriptGroupInRegions( [ region ] );
};
/**
* Returns an associative array of all languages,
* grouped by script group.
@@ -237,23 +236,20 @@
*/
$.uls.data.getLanguagesByScriptGroup = function ( languages ) {
var languagesByScriptGroup = {},
scriptGroup,
language,
langScriptGroup;
language, codeToAdd, langScriptGroup;
for ( scriptGroup in $.uls.data.scriptgroups ) {
for ( language in languages ) {
langScriptGroup = $.uls.data.getScriptGroupOfLanguage( language );
for ( language in languages ) {
codeToAdd = $.uls.data.isRedirect( language ) || language;
if ( langScriptGroup !== scriptGroup ) {
continue;
}
langScriptGroup = $.uls.data.getScriptGroupOfLanguage( codeToAdd );
if ( !languagesByScriptGroup[scriptGroup] ) {
languagesByScriptGroup[scriptGroup] = [];
}
if ( !languagesByScriptGroup[langScriptGroup] ) {
languagesByScriptGroup[langScriptGroup] = [];
}
languagesByScriptGroup[scriptGroup].push( language );
// Prevent duplicate adding of redirects
if ( $.inArray( codeToAdd, languagesByScriptGroup[langScriptGroup] ) === -1 ) {
languagesByScriptGroup[langScriptGroup].push( codeToAdd );
}
}

View File

@@ -80,10 +80,17 @@
// Get the languages grouped by script group
var languagesByScriptGroup = $.uls.data.getLanguagesByScriptGroup( this.options.languages );
for ( var scriptGroup in languagesByScriptGroup ) {
// Make sure that we go by the original order
// of script groups
for ( var scriptGroup in $.uls.data.scriptgroups ) {
// Get the languages for the script group
var languages = languagesByScriptGroup[scriptGroup];
// It's possible that some script groups are missing
if ( !languages ) {
continue;
}
// Sort it based on autonym
languages.sort( $.uls.data.sortByAutonym );

View File

@@ -89,7 +89,7 @@
assert.ok( $.fn.uls, "$.fn.uls is defined" );
} );
test( "-- $.uls.data testing", 45, function ( assert ) {
test( "-- $.uls.data testing", 46, function ( assert ) {
// Add a language in run time.
// This is done early to make sure that it doesn't break other functions.
$.uls.data.addLanguage( 'qqq', {
@@ -153,7 +153,7 @@
assert.deepEqual( $.uls.data.getLanguagesInRegions( ["AM", "WW"] ),
[
"akz", "arn", "aro", "ase", "avk", "ay", "cho", "chr", "chy", "cr", "cr-latn",
"en-ca", "en", "eo", "es-419", "es-formal", "es", "esu", "fr", "gcf", "gn",
"en-ca", "en", "eo", "es-419", "es-formal", "es", "esu", "fr", "frc", "gcf", "gn",
"guc", "haw", "ht", "ia", "ie", "ik", "ike-cans", "ike-latn", "io", "iu", "jam",
"jbo", "kgp", "kl", "lad-latn", "lad-hebr", "lfn", "mfe", "mic", "mus", "nah", "nl-informal", "nl",
"nov", "nv", "pap", "pdc", "pdt", "ppl", "pt-br", "pt", "qu", "qug", "rap", "sei",
@@ -198,6 +198,24 @@
assert.strictEqual( $.uls.data.getAutonym( 'pa' ), 'ਪੰਜਾਬੀ', 'Correct autonym of the Punjabi language was selected using code pa.' );
assert.strictEqual( $.uls.data.getAutonym( 'pa-guru' ), 'ਪੰਜਾਬੀ', 'Correct autonym of the Punjabi language was selected using code pa-guru.' );
var languagesToGroup = {
'en': 'English',
'fiu-vro': 'Võro', // Alias before target
'ru': 'русский',
'sr': 'српски', // Alias before target
'sr-cyrl': 'српски', // Target before alias
'sr-latn': 'srpski', // Target before alias
'sr-el': 'srpski', // Alias after target
'vro': 'Võro' // Target after alias
},
groupedLanguages = {
Latin: [ 'en', 'vro', 'sr-latn' ],
Cyrillic: [ 'ru', 'sr-cyrl' ]
};
assert.deepEqual( $.uls.data.getLanguagesByScriptGroup( languagesToGroup ), groupedLanguages,
'A custom list of languages is grouped correctly using getLanguagesByScriptGroup.' );
var languagesByScriptGroupInEMEA = $.uls.data.getLanguagesByScriptGroupInRegions( $.uls.data.getRegionsInGroup( 3 ) );
assert.deepEqual( languagesByScriptGroupInEMEA['WestCaucasian'], [
'hy', 'ka', 'xmf'