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.

Type: Pre-Sale
Status: In Progress
tangent
View Replies:
jgarcia replied on at Permalink Reply
jgarcia
All field data is outputted in the form exactly as the site admin entered it, so no translation takes place.
tangent replied on at Permalink Reply
tangent
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.
tangent replied on at Permalink Reply
tangent
Hello again.

Just trying to bump this please.
tangent replied on at Permalink Reply
tangent
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?
PhilYoung replied on at Permalink Reply
PhilYoung
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
tangent replied on at Permalink Reply
tangent
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
$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.

concrete5 Environment Information

# concrete5 Version
Core Version - 8.4.3
Version Installed - 8.4.3
Database Version - 20180716000000

# concrete5 Packages
Add Attributes (0.0.1), All In: The Advanced Member Import Add On by ampersandApps (1.1.1), Clear Clipboard (1.0.0), Community Store (1.3.1), Dynamic Images (1.2), EZ Event (1.0), Formify (3.0), Fundamental (4.0.4), Idoit Accordion (1.0.0), Idoit IFA User Search (1.0.0.0), IdoIT Image block (1.0), IFA User Search (0.0.3.2), Package Magic (1.0.3), Package Magic Starter (1.0), Page Redirect (2.0), Page Selector Attribute (2.0), Read More (1.1.0), User Renewals (0.1.6), Vivid Simple Accordion (1.0.1), Whale OWL Carousel (2.5.7.9), WorldPay Hosted Payment Gateway (1.0)

# concrete5 Overrides
blocks/gond_read_more_bottom/view.js, blocks/gond_read_more_bottom, blocks/switch_language/controller.php, blocks/switch_language/templates/dropflags/view.php, blocks/switch_language/templates/dropflags/view.css, blocks/switch_language/templates/dropflags/view.js, blocks/switch_language/templates/dropflags, blocks/switch_language/templates, blocks/switch_language, blocks/search/templates/hourglass/view.php, blocks/search/templates/hourglass/view.css, blocks/search/templates/hourglass, blocks/search/templates, blocks/search, blocks/formify_form/templates/enclosed_names/view.php, blocks/formify_form/templates/enclosed_names/view.css, blocks/formify_form/templates/enclosed_names/view.js, blocks/formify_form/templates/enclosed_names, blocks/formify_form/templates/fields_container/images.zip, blocks/formify_form/templates/fields_container/fields_container.zip, blocks/formify_form/templates/fields_container/view.php, blocks/formify_form/templates/fields_container/icon.png, blocks/formify_form/templates/fields_container/view.css, blocks/formify_form/templates/fields_container/images/processing.gif, blocks/formify_form/templates/fields_container/images/select.png, blocks/formify_form/templates/fields_container/images, blocks/formify_form/templates/fields_container/form.php, blocks/formify_form/templates/fields_container/edit.php, blocks/formify_form/templates/fields_container/view.js, blocks/formify_form/templates/fields_container/controller.php, blocks/formify_form/templates/fields_container/db.xml, blocks/formify_form/templates/fields_container/add.php, blocks/formify_form/templates/fields_container, blocks/formify_form/templates, blocks/formify_form, js/bootstrap-editable.js, themes/fundamental2/css/foundation.custom.css, themes/fundamental2/css, themes/fundamental2, src/Concrete/Form/Service/Validation.php, src/Concrete/Form/Service/Widget/Color.php, src/Concrete/Form/Service/Widget/Rating.php, src/Concrete/Form/Service/Widget/PageSelector.php, src/Concrete/Form/Service/Widget/Attribute.php, src/Concrete/Form/Service/Widget/DateTime.php, src/Concrete/Form/Service/Widget/UserSelector.php, src/Concrete/Form/Service/Widget/Typography.php, src/Concrete/Form/Service/Widget, src/Concrete/Form/Service/Form.php, src/Concrete/Form/Service, src/Concrete/Form/CustomFormServiceProvider.php, src/Concrete/Form, src/Concrete

# concrete5 Cache Settings
Block Cache - Off
Overrides Cache - Off
Full Page Caching - Off
Full Page Cache Lifetime - Every 6 hours (default setting).

# Server Software
Apache/2.4.37 (cPanel) OpenSSL/1.0.2p mod_bwlimited/1.4

# Server API
cgi-fcgi

# PHP Version
5.6.38

# PHP Extensions
bcmath, bz2, calendar, cgi-fcgi, Core, ctype, curl, date, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, imagick, imap, intl, ionCube Loader, json, ldap, libxml, mbstring, mcrypt, mhash, mysql, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, posix, pspell, readline, Reflection, session, SimpleXML, soap, sockets, SPL, sqlite3, standard, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend Guard Loader, Zend OPcache, zip, zlib

# PHP Settings
max_execution_time - 30
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 2000
memory_limit - 256M
post_max_size - 256M
sql.safe_mode - Off
upload_max_filesize - 200M
ldap.max_links - Unlimited
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
session.cache_limiter - <i>no value</i>
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
opcache.max_accelerated_files - 2000
opcache.max_file_size - 0
opcache.max_wasted_percentage - 5
zend_optimizerplus.max_accelerated_files - 2000
zend_optimizerplus.max_file_size - 0
zend_optimizerplus.max_wasted_percentage - 5

Browser User-Agent String

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.