ChronoForms v4 uses the FormCheck validation library that has support built in for about twenty languages. This FAQ shows you how to set them up for a single or multi-language site and how to add a new language.
Single language sites
You can set the language using the JS Validation Language option on the JS Validation tab (click the Form Name link in the Forms Manager to see this).
The currently listed languages are:
English (default) Chinese, Danish, Deutsch, Dutch, Farsi, French, Greek, Italian, Japanese, Latvian, Norwegian, Polish, Portuguese, Romanian, Russian, Slovenšcina, Spanish and Turkish.
There are also files available for Bulgarian (bu), Croatian (hr) and Hungarian (hu) that are not in the list. You can add a new language file by copying and renaming one of the existing files in the folder components/com_chronoforms/js/formcheck/lang User provided translations for Swedish (se) and Norwegian (no) are below for you to copy and paste.
To use a language that is not in the list add the following code into a Custom Code action in the On Load event of your form replacing xx with the two letter language code:
<?php $form->form_params->set('jsvalidation_lang', 'xx'); ?>
If you want to add languages to the drop-down list you can hack the code around line 106 of administrator/components/com_chronoforms/views/edit.php If you do this the hack will be over-written when you next upgrade ChronoForms.
Multi-language sites
You can change language using the Joomla! language object to find the currently selected language. Add this code to a Custom Code action to do this:
<?php $lang = JFactory::getLanguage(); $tag = $lang->getTag(); $tag = substr( $tag, 0, 2 ); $form->form_params->set('jsvalidation_lang', $tag); ?>
Or you can try my custom Show HTML [GH] action which detects the language and selects the corresponding language file.
Language files
I guess it should be "from"
line 19: lengthmax: "The length is incorrect, it must be at max %0"
better "The length is incorrect, it must be at max of %0"
or "The length is incorrect, it must be %0 characters max"
line 21: words_min : "This field must concain at least %0 words, currently: %1 words"
Finnish (fi)
formcheckLanguage = { required: "Tämä kenttä on pakollinen.", alpha: "Tämä kenttä hyväksyy vain aakkosia.", alphanum: "Tämä kenttä hyväksyy vain aakkosia ja numeroita.", nodigit: "Vain kokonaisluvut sallittuja.", digit: "Syötä käypä kokonaisluku.", digitmin: "Luvun täytyy olla vähintään %0", digitltd: "Arvon täytyy olla välillä %0 ja %1", number: "Syötä käypä luku.", email: "Syötä käypä email: <br/><span>Esim. omanimi@domain.com</span>", image : "Tämä kenttä saa sisältää vain kuvatiedostoja", phone: "Syötä käypä puhelinnumero.", url: "Syötä käypä url: <br/><span>Esim. http://www.domain.com</span>", confirm: "Tämä kenttä eroaa arvosta %0", differs: "Tämän kentän täytyy erota arvosta %0", length_str: "Pituus on väärä, täytyy olla välillä %0 ja %1", length_fix: "Pituus on väärä, täytyy olla täsmälleen %0 merkkiä", lengthmax: "Pituus on väärä, saa olla enintään %0", lengthmin: "Pituus on väärä, täytyy olla vähintään %0", words_min : "Tämän kentän on sisällettävä vähintään %0 sanaa, tällä hetkellä: %1 sanaa", words_range : "Tämän kentän on sisällettävä %0-%1 sanaa, tällä hetkellä: %2 sanaa", words_max : "Tämä kenttä saa sisältää enimmillään %0 sanaa, tällä hetkellä: %1 sanaa", checkbox: "Rastita laatikko", checkboxes_group : "Rastita vähintään %0 laatikko(a)", radios: "Valitse yksi", select: "Valitse arvo", select_multiple : "Valitse vähintään yksi arvo" }
Slovak (sk)
formcheckLanguage = { required: "Toto pole je povinné.", alpha: "Toto pole môže obsahovat iba písmená.", alphanum: "Do tohoto pola môžete zadávat len alfanumerické znaky.", nodigit: "Toto pole nemôže obsahovat císlice.", digit: "Toto pole môže obsahovat iba celé kladné císla.", digitmin: "Císlo musí byt minimálne %0", digitltd: "Hodnota musí byt v intervale %0 až %1", number: "Císlo prosím zadajte v správnom formáte.", email: "Prosím, zadajte mail v správnom formáte: Napr. VaseMeno@domena.sk", image : 'Toto pole môže obsahovat len formáty obrázkov', phone: "Prosím, zadajte telefónne císlo v správnom formáte.", url: "URL prosím zadajte v správnom formáte: napr. http://www.domena.sk", confirm: "Pole nie je totožné s polom %0", differs: "Toto pole musí byt odlišné ako %0", length_str: "Zadaný retazec nemá správnu dlžku, musí byt v rozsahu %0 a %1", length_fix: "Zadaný retazec nemá správnu dlžku, musí mat dlžku presne %0 znakov", lengthmax: "Zadaný retazec nemá správnu dlžku, môže byt dlhý maximálne %0 znakov", lengthmin: "Zadaný retazec nemá správnu dlžku, musí byt kratší ako %0 znakov", words_min : "Toto pole musí obsahovat minimálne %0 slov. Momentálne má len: %1 slov", words_range : "Toto pole musí obsahovat %0-%1 slov. Momentálne má : %2 slov", words_max : "Toto pole môže obsahovat maximálne %0 slov. Momentálne má: %1 slov", checkbox: "Zaškrtnutie tohoto checkboxu je povinné", checkboxes_group : 'Prosím, vyberte minimálne %0 možnost(i)', radios: "Prosím vyberte jednu z možností", select: "Prosím vyberte jednu z možností", select_multiple : "Prosím vyberte jednu alebo viac možností" }
Swedish (se)
formcheckLanguage = { required: "Detta fält är obligatoriskt.", alpha: "Detta fält accepterar endast bokstäver.", alphanum: "Detta fält accepterar endast alfanumeriska tecken.", nodigit: "Inga siffror accepteras.", digit: "Ange ett giltigt heltal.", digitmin: "Antalet måste vara minst %0", digitltd: "Värdet måste vara mellan %0 och %1", number: "Ange ett giltigt nummer.", email: "Ange en giltig e-postadress: <br /><span>T.ex. dittnamn@domän.se</span>", image : 'Detta fält ska endast innehålla bildtyper', phone: "Ange ett giltigt telefonnummer.", url: "Ange en giltig webbadress: <br /><span>T.ex. http://www.domän.se</span>", confirm: "Detta fält skiljer sig från %0", differs: "Detta värde måste skilja sig från %0", length_str: "Längden är fel, den måste vara mellan %0 och %1", length_fix: "Längden är fel, den måste vara exakt %0 tecken", lengthmax: "Längden är fel, den måste vara max %0", lengthmin: "Längden är fel, den måste vara minst %0", words_min : "Detta fält måste innehålla minst %0 ord, för närvarande: %1 ord", words_range : "Detta fält måste innehålla %0-%1 ord, för närvarande: %2 ord", words_max : "Detta fält måste innehålla max %0 ord, för närvarande: %1 ord", checkbox: "Vänligen markera rutan", checkboxes_group : 'Vänligen markera minst %0 ruta/rutor', radios: "Vänligen gör ett val", select: "Välj ett värde", select_multiple : "Välj minst ett värde" }
formcheckLanguage = { alpha: "??? ?? ???? ?????? ??? ??? ????.", alphanum: "??? ?? ???? ?????? ??? ??? ??????? ????.", checkbox: "????? ??? ?? ???? ??????", checkboxes_group : '????? ??? ????? %0 ?????', confirm: "??? ?? ???? ? %0", differs: "??? ?? ???? ????? ???? ? %0", digit: "?? ????? ???? ???.", digitltd: "????? ???? ????? ??? %0 ? %1", digitmin: "????? ???? ????? ????? %0", email: "??? ???? ?????? ????: <br /><span>yourname@domain.com</span>", image : '??? ?? ???? ????? ?????? ????', length_fix: "???? ????, ???? ????? %0 ????? ?????", length_str: "???? ????, ???? ????? ??? %0 ? %1", lengthmax: "???? ????, ???? ????? %0 ???????", lengthmin: "???? ????, ???? ????? %0 ?????", nodigit: "?? ???? ????? ????? ???? ??.", number: "?? ??? ???? ???? ??.", phone: "??? ???? ???? ????? ????.", radios: "?? ???? ?????", required: "??? ??? ????.", select: "?? ????? ???", select_multiple : "?? ????? ??? ??? ?????", url: "??? ??? ????? ??????? ?????: <br /><span>http://www.domain.com</span>", words_max : "??? ?? ???? ????? %0-%1 ?????, ????: %2 ?????", words_min : "??? ?? ???? ????? %0 ????? ?????, ????: %1 ?????", words_range : "??? ?? ???? ????? %0 ????? ???????, ????: %1 ?????" }
Comments: