Sort languages by script in the initial view

* Added new utility functions to return all languages by script group.
* Used that function to sort languages initially.
* Added tests.

Change-Id: I405cb73e6af13f59c307da5a7f2269049ecba698
This commit is contained in:
Amir E. Aharoni
2012-07-03 16:39:35 +03:00
parent 5625f6eb70
commit 31e483a19e
3 changed files with 38 additions and 8 deletions

View File

@@ -32,6 +32,20 @@
return $.uls.data.autonyms[language];
};
/**
* Returns an array of all region codes.
* @return array
*/
$.uls.data.allRegions = function() {
var allRegions = [];
for( var region in $.uls.data.regiongroups ) {
allRegions.push( region );
}
return allRegions;
};
/**
* Returns all languages written in script.
* @param script string
@@ -131,6 +145,15 @@
return $.uls.data.languagesByScriptGroupInRegions( [ region ] );
};
/**
* Returns an associative array of all languages,
* grouped by script group.
* @return associative array
*/
$.uls.data.allLanguagesByScriptGroup = function() {
return $.uls.data.languagesByScriptGroupInRegions( $.uls.data.allRegions() );
};
/**
* Returns an associative array of languages in several regions,
* grouped by script group.