Arabic and Chinese content

Find and share translations of CMSimple(_XH) core and plugins here

Moderator: Tata

Post Reply
bastingse
Posts: 253
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Arabic and Chinese content

Post by bastingse » Sun Sep 29, 2013 9:18 am

Hi folks,
I haven't been here for a long time. Sickness did kept me off-line for months. Now i try to catch up.

For a customer with an old installation of Cmsimple xh 1.1.2 (2010 i believe) i need to translate his website to Arabic and Chinese.

2 problems came up:
1. In the menu it is not showing the right text with Arabic and Chinese language. It does set the header to some numbers in the menu. However, on the page itself it is okay.
2. with Arabic language the text is from left to right (Google translate made the correct text from right to left but when paste it, things go wrong).

Did search for 2 hours now but can't find any solution.
If i update the version of Cmsimple, should that fix the problem? And if i wanne update, what version should i use from sourgeforce?

CMSimple_XH 1.1 2013-09-09
or
CMSimple_XH 1.5 2013-09-11

Thanks for any help/advice!

cmb
Posts: 12719
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Arabic and Chinese content

Post by cmb » Sun Sep 29, 2013 11:27 am

Hi Emile,
bastingse wrote:In the menu it is not showing the right text with Arabic and Chinese language. It does set the header to some numbers in the menu. However, on the page itself it is okay.
That might be related to an incompatibility of the code that strips out the heading ($h[...]) and the character encoding of the language file, as there is no special treatment of multibyte character sets in CMSimple_XH 1.1.x.
bastingse wrote:with Arabic language the text is from left to right (Google translate made the correct text from right to left but when paste it, things go wrong).
That is most likely due to a missing dir="rtl" attribute of the HTML element. You probably have to add that to the template.
bastingse wrote:If i update the version of Cmsimple, should that fix the problem? And if i wanne update, what version should i use from sourgeforce?
You should update at least to CMSimple_XH 1.1.7, mainly because several bugs and vulnerabilities have been fixed since XH 1.1.2. Updating should be relatively easy: after updating to XH 1.1.3 (I can look up what has to be done for this step), it should suffice to simply upload all files of the update package.

However, you're most likely better off to upgrade to CMSimple_XH 1.5.9. For one thing there won't be any maintenance releases for the CMSimple_XH 1.1 series after the end of this year, for another thing there have been many improvements made regarding the handling of UTF-8 encoded characters during the XH 1.5 series. Unfortunately, upgrading from XH 1.1.2 to 1.5.9 is not as simple than just updating to 1.1.7 (see how to do it).

The good news is that there are already Chinese translations for XH 1.5.x (simplified and traditional), and those seem to work fine. However, there is no Arabic translation (or for that matter any translation to a right-to-left language), so I don't know exactly, what has to be done to make that work. Besides adding the dir="rtl" attribute to the template (very easy, as you can use language specific templates since XH 1.5), you'll have to tell the editor to use rtl (using the TinyMCE plugin directionality is the easiest way to cater for all languages, although using the config option directionality seems to be preferable).

Anyway, the rtl stuff should be handled by CMSimple_XH, IMO. It already may suffice to add a new language setting and to make some modifcations to the editor.
bastingse wrote:Sickness did kept me off-line for months. Now i try to catch up.
I'm glad, you're doing better now. :) You may not be aware yet that there is a fork of CMSimple_XH 1.5.3 now under the name CMSimple 4.

Christoph

PS: I created the following patch against CMSimple_XH 1.5.9 (lines with a minus sign as first character have to removed; those with a plus sign have to be inserted; the rest is for orientation):

Code: Select all

Index: cmsimple/languages/en.php
===================================================================
--- cmsimple/languages/en.php	(revision 2)
+++ cmsimple/languages/en.php	(working copy)
@@ -223,4 +223,6 @@
 
 $tx['utf-8']['marker']="äöü";
 
+$tx['script']['directionality']="rtl";
+
 ?>
Index: plugins/tinymce/init.php
===================================================================
--- plugins/tinymce/init.php	(revision 2)
+++ plugins/tinymce/init.php	(working copy)
@@ -88,7 +88,7 @@
  * @return string
  */
 function tinymce_config($xh_editor, $config) {
-    global $pth, $sl, $sn, $cf, $plugin_cf;
+    global $pth, $sl, $sn, $cf, $tx, $plugin_cf;
 
     if (!isset($plugin_cf['tinymce'])) {
 	include_once $pth['folder']['plugins'] . 'tinymce/config/config.php';
@@ -160,6 +160,8 @@
 
     $temp = str_replace("%FILEBROWSER_CALLBACK%", $_SESSION['tinymce_fb_callback'], $temp);
 
+    $temp = str_replace('%DIRECTIONALITY%', $tx['script']['directionality'], $temp);
+
     return $temp;
 }
 
Index: plugins/tinymce/inits/init_full.js
===================================================================
--- plugins/tinymce/inits/init_full.js	(revision 2)
+++ plugins/tinymce/inits/init_full.js	(working copy)
@@ -33,6 +33,8 @@
     external_image_list_url : "%TINY_FOLDER%cms_image_list.js",
     external_link_list_url : "%TINY_FOLDER%cms_link_list.js",
 
+    directionality: "%DIRECTIONALITY%",
+
     // Extra
     plugin_insertdate_dateFormat: "%d-%m-%Y",
     plugin_insertdate_timeFormat: "%H:%M:%S",
Index: templates/mini1/template.htm
===================================================================
--- templates/mini1/template.htm	(revision 2)
+++ templates/mini1/template.htm	(working copy)
@@ -1,17 +1,17 @@
 <!DOCTYPE html>
-<html>
+<html dir="<?php echo $tx['script']['directionality'];?>">
 <head>
 <?php echo head();?>
 </head>
-  
+
 <body id="body" <?php echo onload();?>>
 
     <!--Head Navigation-->
     <div class="headnav">
         <p>
-            <?php echo mailformlink();?> &nbsp; 
-            <?php echo sitemaplink();?> &nbsp; 
-            <?php echo printlink();?> &nbsp; 
+            <?php echo mailformlink();?> &nbsp;
+            <?php echo sitemaplink();?> &nbsp;
+            <?php echo printlink();?> &nbsp;
             <?php echo languagemenu();?>
         </p>
     </div>
This seems to solve the most basic issues wrt. right-to-left scripts, but it seems for a completely proper support of such scripts there are several details to be improved and depending on the template this might have to be adapted (plugins might need adaption, too).
Last edited by cmb on Sun Sep 29, 2013 3:11 pm, edited 1 time in total.
Reason: added PS
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

manu
Posts: 661
Joined: Wed Jun 04, 2008 12:05 pm
Location: St. Gallen - Schweiz
Contact:

Re: Arabic and Chinese content

Post by manu » Mon Sep 30, 2013 1:54 pm

bastingse wrote: 1. In the menu it is not showing the right text with Arabic and Chinese language. It does set the header to some numbers in the menu. However, on the page itself it is okay.
Maybe it's the same bug shown here.

cmb
Posts: 12719
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Arabic and Chinese content

Post by cmb » Mon Sep 30, 2013 3:25 pm

In CMSimple_XH 1.1.2 this particular bug had already been resolved:

Code: Select all

    $c = explode("\xC2\xA7", preg_replace("/(<h[1-".$cf['menu']['levels']."][^>]*>)/i", "\xC2\xA7\\1", str_replace("\xC2\xA7", '&sect;', rf($pth['file']['content']))));
But with multibyte character sets other than UTF-8 there may be similar issues, as e.g. the ">" sign encoded as Latin-1(character encoding of the PHP sources) is \x3E, which could be part of a multibyte character of the charset used for the content. Other characters may make problems as well, even an "h" (\x68) which could be part of a Big5 character.

IMHO one should use old CMSimple(_XH) versions only with single byte character sets that extends ASCII (such as ISO-8859-X). New versions of CMSimple_XH might have similar problems with characters sets other than UTF-8, by the way.
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

bastingse
Posts: 253
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Re: Arabic and Chinese content

Post by bastingse » Wed Oct 02, 2013 9:24 am

CMB and Manu, thank you both for reply to this topic. I'll see what i can do/change/update to my installation on this website.
I'm almost sure that i'll get it done with your tips and tricks!!

Thanks very much for your friendly help!

bastingse
Posts: 253
Joined: Fri Jun 06, 2008 9:38 pm
Location: Netherlands
Contact:

Re: Arabic and Chinese content

Post by bastingse » Mon Oct 21, 2013 5:05 pm

Today i found out how to solve the problem of Arabic language from right to left........

Place text between div's and put in a dir="rtl"

Done !! :-)

Thanks all for being so helpful !

Post Reply