Localisation and Labels
Permalink Browser Info Environment
Hello.
I have been helping develop a multilingual site and we have been setting up forms using Formify. We are now looking at the other languages and I would like to know if the Formify label fields will be converted by the .po files we are in the process of translating?
Thanks.
I have been helping develop a multilingual site and we have been setting up forms using Formify. We are now looking at the other languages and I would like to know if the Formify label fields will be converted by the .po files we are in the process of translating?
Thanks.
Type: | Pre-Sale |
---|---|
Status: | In Progress |
All field data is outputted in the form exactly as the site admin entered it, so no translation takes place.
Hello.
Thanks for getting back to me about this.
When I paste, for instance, Japanese text into a 'label' in the field editing interface, it looks fine an stays there after I select the green tick. But if I refresh the page or view the form the label is not displaying Japanese characters but another character set.
If I view the labels in the FormifyFields table using PhpMyAdmin, they show correctly .
The table FormifyFields label collation is utf8_unicode_ci and the general MySQL server collation is UTF8MB4_unicode_ci.
Thanks for getting back to me about this.
When I paste, for instance, Japanese text into a 'label' in the field editing interface, it looks fine an stays there after I select the green tick. But if I refresh the page or view the form the label is not displaying Japanese characters but another character set.
If I view the labels in the FormifyFields table using PhpMyAdmin, they show correctly .
The table FormifyFields label collation is utf8_unicode_ci and the general MySQL server collation is UTF8MB4_unicode_ci.
Hello again.
Just trying to bump this please.
Just trying to bump this please.
Hi Justin.
This is pretty urgent. The client needs to make the site go live and we are stuck on the form Labels not displaying the correct characters. The labels look fine in the database, why not when the form is viewed?
Is there anything you can advise us with to work around this please?
This is pretty urgent. The client needs to make the site go live and we are stuck on the form Labels not displaying the correct characters. The labels look fine in the database, why not when the form is viewed?
Is there anything you can advise us with to work around this please?
Hi,
Not sure if you ever resolved this. My investigations are below.
It is is a utf-8 issue
you can try changing the code in, for example,
\formify\elements\field_types\textbox\view.php
to the below
<input class="form-control" type="text" id="formify-field-<?php echo $field->ffID; ?>" name="<?php echo $field->name; ?>" value="<?php echo htmlspecialchars(utf8_decode($field->defaultValue)); ?>" placeholder="<?php echo htmlspecialchars(utf8_decode($field->placeholder)); ?>" maxlength="<?php echo $field->fieldSize; ?>" />
and see if this works in terms of displaying the appropriate kanji in a textbox field. if it does not try changing the word utf8_decode to utf8_encode. The simple code in formify "echo htmlspecialchars" is not enough. In fact the utf8 may not work you might need to use one of ether of the 2 pieces of code below.
Shift_JIS - Japanese
EUC-JP - Japanese
You will need to make this change in all field types that your are using in their associated view.php.
Check
http://www.w3schools.com/php/func_string_htmlspecialchars.asp...
Best
Phil
Not sure if you ever resolved this. My investigations are below.
It is is a utf-8 issue
you can try changing the code in, for example,
\formify\elements\field_types\textbox\view.php
to the below
<input class="form-control" type="text" id="formify-field-<?php echo $field->ffID; ?>" name="<?php echo $field->name; ?>" value="<?php echo htmlspecialchars(utf8_decode($field->defaultValue)); ?>" placeholder="<?php echo htmlspecialchars(utf8_decode($field->placeholder)); ?>" maxlength="<?php echo $field->fieldSize; ?>" />
and see if this works in terms of displaying the appropriate kanji in a textbox field. if it does not try changing the word utf8_decode to utf8_encode. The simple code in formify "echo htmlspecialchars" is not enough. In fact the utf8 may not work you might need to use one of ether of the 2 pieces of code below.
Shift_JIS - Japanese
EUC-JP - Japanese
You will need to make this change in all field types that your are using in their associated view.php.
Check
http://www.w3schools.com/php/func_string_htmlspecialchars.asp...
Best
Phil
Hi Phil.
Thanks for getting back to me on this.
We have a fix, not just for Japanese. The site currently runs Chinese, Simplified and Traditional, Japanese, Korean and Spanish (not that it needs special characters). There are plenty of other languages to be added.
The database is set to UTF8_general_ci.
I went through the code and found the part where the field label is loaded from the database in /packages/formify/src/FormifyField.php
Altered the code in function 'getFromArray($data)' from
to
Problem solved! All the labels show in the correct language.
Our problem now is getting the Translation system to work with this so we only have to create one Form for all the different languages.
Thanks for getting back to me on this.
We have a fix, not just for Japanese. The site currently runs Chinese, Simplified and Traditional, Japanese, Korean and Spanish (not that it needs special characters). There are plenty of other languages to be added.
The database is set to UTF8_general_ci.
I went through the code and found the part where the field label is loaded from the database in /packages/formify/src/FormifyField.php
Altered the code in function 'getFromArray($data)' from
$field = new self; foreach($data as $col => $val) { //Fix UTF-8 issues $field->$col = utf8_encode($val); }
to
$field = new self; foreach($data as $col => $val) { if($val != '') { $field->$col = ($col === 'label' ? t($val) : $val); } } ...
Problem solved! All the labels show in the correct language.
Our problem now is getting the Translation system to work with this so we only have to create one Form for all the different languages.