add language codes and names

This commit is contained in:
rolux 2014-07-23 15:54:24 +02:00
parent 28f221ef47
commit 0f6d70766f
2 changed files with 7220 additions and 7179 deletions

View file

@ -97,8 +97,10 @@ Ox.load.Geo = function(options, callback) {
> Ox.test.array
[196, 73, 10, 8, 28, 24, 14, 1]
@*/
Ox.COUNTRIES = data.countries;
//@ Ox.LANGUAGES <[o]> Array of ISO 639-1 language codes and names
Ox.LANGUAGES = data.languages;
Ox.COUNTRIES = data;
Ox.GEO_COLORS = {
'North America': [0, 0, 255],
@ -253,6 +255,26 @@ Ox.load.Geo = function(options, callback) {
return Ox.GEO_COLORS[str] || [128, 128, 128];
};
/*@
Ox.getLanguageCodeByName <f> Returns a language code
(str) -> <s> Two-letter ISO 639-1 language code, or original string
str <s> Language name
@*/
Ox.getLanguageCodeByName = function(str) {
var language = Ox.getObject(Ox.LANGUAGES, 'name', Ox.toTitleCase(str));
return language ? language.code : str;
};
/*@
Ox.getLanguageNameByCode <f> Returns a language name
(str) -> <s> Language name, or original string
str <s> Two-letter ISO 639-1 language code
@*/
Ox.getLanguageNameByCode = function(str) {
var language = Ox.getObject(Ox.LANGUAGES, 'code', str);
return language ? language.name : str;
};
/*@
Ox.splitGeoname <f> Splits a geoname into its component parts
(geoname) -> <[s]> Components

View file

@ -1,4 +1,5 @@
[
{
"countries": [
{
"area": 175767626.27131784,
"code": "AC",
@ -7325,4 +7326,22 @@
"south": -22.4245232,
"west": 25.237368
}
],
"languages": [
{"code": "ar", "name": "Arabic"},
{"code": "de", "name": "German"},
{"code": "en", "name": "English"},
{"code": "es", "name": "Spanish"},
{"code": "fr", "name": "French"},
{"code": "gr", "name": "Greek"},
{"code": "hi", "name": "Hindi"},
{"code": "it", "name": "Italian"},
{"code": "ja", "name": "Japanese"},
{"code": "ko", "name": "Korean"},
{"code": "nl", "name": "Dutch"},
{"code": "pt", "name": "Portuguese"},
{"code": "ru", "name": "Russian"},
{"code": "tr", "name": "Turkish"},
{"code": "zh", "name": "Chinese"}
]
}