LangEditor
LangEditor copied to clipboard
Bug for language Portuguese
Hi @unclecheese
I'm using your LangEditor for my Silverstripe Project. I have several Languages available on my site, also Portuguese-Portugal (pt_PT) and Portuguese-Brazil (pt_BR) Problem is, that i18n.php->common_languages array does not have the language key pt itself - instead it supports pt_PT and pt_BR. So it's not possible to select these two Languages in your LangEditor in CMS
quick fix for me was, that I added an if for the case of pt_PT and pt_BR in Methods getLanguages()
if (! in_array($label, static::config()->exclude_locales)) {
$name = i18n::get_language_name(self::get_lang_from_locale($label));
//add: due to lang-key 'pt' is not available in i18n->common_languages, use pt_BR and pt_PT as lang-key instead
if($label == 'pt_BR' || $label == 'pt_PT') {
$name = i18n::get_language_name($label);
}
$langs->push(new ArrayData([
'Link' => Director::baseURL().'admin/'.static::config()->url_segment.'/show/'.$label.'/'.str_replace(DIRECTORY_SEPARATOR, '$', static::config()->currentModule),
'Locale' => $label,
'Name' => $name,
'Current' => $label == static::config()->currentLocale ? true : false,
]));
}
and CreateTranslationForm()
if (! in_array($locale, static::config()->exclude_locales)) {
$language = self::get_lang_from_locale($locale);
//add: check if locale is pt_PT or pt_BR and set language due to i18n common_language-array does not support pt (just pt_PT and pt_BR)
if($locale == 'pt_PT' || $locale == 'pt_BR') {
$language = $locale;
}
$to_languages[$language] = $common_languages[$language];
}
Please have a look on this bug.
Greetings Magdalena
Hey,
is there already a solution to my problem?