Converting java language output to Joomla language output
- by jax
in java if I run :
Locale.getDefault().toString()
I get zh_tw
I am sending this to a joomla site and setting the language like this:
$lang = &JFactory::getLanguage();
$lang->setLanguage( $_GET['lang'] );
$lang->load();
however the site requires the following format zh-TW
It appears that if it is not in that exact format the language will not change. Is there a function somewhere in java or php that will convert the format for me?
I realise that I could write the method myself like this:
public static String convertLanguageToJoomlaFormat(String lang) {
String[] parts = lang.split("_");
if(parts.length ==2)
return parts[0]+"-"+parts[1].toUpperCase();
return lang;
}
but am unsure if there are any cases where the format changes for particular languages.