Page 1 of 1

i18n support on admin: content in Asian lang got mess coding

Posted: Sun Apr 27, 2014 3:07 pm
by daniel_locious
Hi guys,

I've tried follow the tutorials on i18n. Now I've added a new locale Chinese in to my demo site,; however when I try to enter some pages and content items, I got wrong coding (like ???). I assume this is because the input of the admin module didn't read the post content correctly, but I can't prove it - I am still struggling on setting up debug for my eclipse. My progress, though, was that I confirmed the database is utf8 and if I update the content in database in Chinese, the admin page can display it correctly.

Any help would be appreciated.

Cheers,

Dan

Re: i18n support on admin: content in Asian lang got mess coding

Posted: Tue Apr 29, 2014 5:06 pm
by phillipuniverse
Where are you seeing the ??? coding displayed? In the WYSIWYG editor?

Re: i18n support on admin: content in Asian lang got mess coding

Posted: Thu May 01, 2014 6:28 am
by daniel_locious
Hi Phillip,

Thanks for reply; it was on page description field and content field.

But, I figured this out again :D.
Here is what I did:

First, make sure the database is in utf8 character set; in mysql you may use

Code: Select all

create database <database-name> character set utf8;

Then change your persistent unit setting

Code: Select all

 <persistence-unit name="blPU" transaction-type="RESOURCE_LOCAL">
        <non-jta-data-source>jdbc/web</non-jta-data-source>
        <exclude-unlisted-classes/>
        <properties>
           <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
 
           [b]<property name="hibernate.connection.CharSet" value="utf8" />
           <property name="hibernate.connection.characterEncoding" value="utf8" />
           <property name="hibernate.connection.useUnicode" value="true" />[/b]
           
        </properties>
    </persistence-unit>

The last step:
jetty-env.xml

Code: Select all

<New class="org.apache.commons.dbcp.BasicDataSource">
            <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
            [b]<Set name="url">jdbc:mysql://<database-url>:3306/<database-name>?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=utf-8</Set>[/b]
            <Set name="username">root</Set>
            <Set name="password">root</Set>
         </New>


Btw, make sure the core.jar that deployed to admin and site project, is up-to-date. My problem was I didn't check maven dependency and left the old core-1.0.jar there, which makes it no difference no matter what I fix later on.

Hope this will help someone.

Cheers,

Dan

Re: i18n support on admin: content in Asian lang got mess coding

Posted: Thu May 01, 2014 11:05 am
by phillipuniverse
Ah, great find! Thanks for reporting back!