Adding a special region

This is supposed to allow adding special languages.

This region's section is hidden by default and can be enabled by
passing different options to the lcd object.
This commit is contained in:
Amir E. Aharoni
2012-12-31 23:09:48 +02:00
parent 680e14196d
commit 829c827483
8 changed files with 71 additions and 15 deletions

View File

@@ -417,4 +417,36 @@
return $.uls.data.territories[territory];
};
/**
* Adds a language in run time and sets its options as provided.
* If the target option is provided, the language is defined as a redirect.
* Other possible options are script, regions and autonym.
*
* @param code string New language code.
* @param options Object Language properties.
* @return list of language codes
*/
$.uls.data.addLanguage = function( code, options ) {
if ( options.target ) {
$.uls.data.languages[code] = [options.target];
} else {
$.uls.data.languages[code] = [options.script, options.regions, options.autonym];
}
};
/**
* Removes a language from the langdb in run time.
*
* @param code string Language code to delete.
* @return true if the language was removed, false otherwise.
*/
$.uls.data.deleteLanguage = function( code ) {
if ( $.uls.data.languages[code] ) {
delete $.uls.data.languages[code];
return true;
}
return false;
};
} ( jQuery ) );