While trying to translate a form, I found the problem of inserting an equal (=) in the translations, so I fixed it with the next code:
If you look at the foreach's that make the language array I modify them slightly.
I hope it is helpful.
function onload( $option, $row, $params, $html_string ) {
global $mainframe;
$my = JFactory::getUser();
$database =& JFactory::getDBO();
$lang =& JFactory::getLanguage();
$LangTag = $lang->getTag();
$supportedLanguages = explode(",", trim($params->get('languages')));
$LangCount = 1;
$LangArray = array();
$Lang_Temp_Array = array();
$cfLangDone = false;
foreach($supportedLanguages as $supportedLanguage){
if($LangTag == trim($supportedLanguage)){
$LangData = $row->{"extra".$LangCount};
$Lang_Temp_Array = explode("\n", $LangData);
if(count($Lang_Temp_Array)){
foreach($Lang_Temp_Array as $Lang_Temp_Element){
$This_Lang_Element = explode("=", $Lang_Temp_Element);
$key = $This_Lang_Element[0];
$value = implode("=", array_slice($This_Lang_Element, 1));
$LangArray[$key] = $value;
}
foreach($LangArray as $original => $translation){
$html_string = str_replace($original, $translation, $html_string);
}
}
$cfLangDone = true;
}
//create the default language array
if(trim($params->get('default_language')) == trim($supportedLanguage)){
$LangData = $row->{"extra".$LangCount};
$Lang_Temp_Array = explode("\n", $LangData);
if(count($Lang_Temp_Array)){
foreach($Lang_Temp_Array as $Lang_Temp_Element){
$This_Lang_Element = explode("=", $Lang_Temp_Element);
$key = $This_Lang_Element[0];
$value = implode("=", array_slice($This_Lang_Element, 1));
$DefaultLangArray[$key] = $value;
}
}
}
$LangCount++;
}
//if no translations found, do default language
if(!$cfLangDone && trim($params->get('default_language'))){
foreach($DefaultLangArray as $original => $translation){
$html_string = str_replace($original, $translation, $html_string);
}
}
return $html_string ;
}
If you look at the foreach's that make the language array I modify them slightly.
I hope it is helpful.
Hi graffiacane,
I haven't see this one before but there was a similar bug in the cuRL and ReDirect actions.
It might be simpler to add the limit to the explode
As a workaround you could use the HTML entity = for the remaining =
Bob
I haven't see this one before but there was a similar bug in the cuRL and ReDirect actions.
It might be simpler to add the limit to the explode
$This_Lang_Element = explode("=", $Lang_Temp_Element, 1);
that way only the fors + is exploded.As a workaround you could use the HTML entity = for the remaining =
Bob
I am try to fix this items. Thank for admin's reply.
Tour Halong bay*Vietnam tour itinerary*Violet Cruise Halong
Tour Halong bay*Vietnam tour itinerary*Violet Cruise Halong
This topic is locked and no more replies can be posted.