I support 8 languages and am using Chronoforms multi-language action for translations (see my current posts below). That part is working great.
My problem is that even though the form would be localized, the validation strings were not. After some research I noticed the validation language setting on the form. Then I found that this is loaded in cfaction_show_html.php.
Here's my proposed fix:
Add the following to the top of function _loadValidationScripts($form){
Then change the following line from:
To:
This way it uses the browser language to pick the validation to display. If you have suggestions for simplifying then I'm interested. I know that I could just keep the first two letters of the locale, but did it this way in case the user (me) set the SEF language tag different than the first letters in the locale.
I have to support Norwegian and Finnish and don't see them in your list. I'll assume you're interested in adding these after they are translated?
My problem is that even though the form would be localized, the validation strings were not. After some research I noticed the validation language setting on the form. Then I found that this is loaded in cfaction_show_html.php.
Here's my proposed fix:
Add the following to the top of function _loadValidationScripts($form){
//This just gets the language tag (en vs en-US)
$lang = JLanguageHelper::detectLanguage();
$languages = JLanguageHelper::getLanguages();
foreach ($languages as $language){
if($language->lang_code == $lang){
$current_language = $language->sef;
}
}
Then change the following line from:
$document->addScript($CF_PATH.'components/com_chronoforms/js/formcheck/lang/'.$form->form_params->get('jsvalidation_lang', 'en').'.js');
To:
$js_lang_file = 'components/com_chronoforms/js/formcheck/lang/'. $current_language .'.js';
if (file_exists($js_lang_file)) {
$document->addScript($CF_PATH.$js_lang_file);
} else {
$document-addScript($CF_PATH.'components/com_chronoforms/js/formcheck/lang/'.$form->form_params->get('jsvalidation_lang', 'en').'.js');
}
This way it uses the browser language to pick the validation to display. If you have suggestions for simplifying then I'm interested. I know that I could just keep the first two letters of the locale, but did it this way in case the user (me) set the SEF language tag different than the first letters in the locale.
I have to support Norwegian and Finnish and don't see them in your list. I'll assume you're interested in adding these after they are translated?