Sunday, June 14, 2015

[PrestaShop] ปัญหาการเกิด TECHNICAL ERROR: unable to load form. Details Error thrown:

[PrestaShop] ปัญหาการเกิด TECHNICAL ERROR: unable to load form. Details Error thrown:

เนื่องจากการใช้งานในรูปแบบ multilingual นั้น มักจะมีปัญหาการ load ข้อมูลมาเพื่อแสดงในรูปแบบ json  และ Prestashop ใช้การload โดยผ่าน global function ของ prestashop เอง ใน class \classes\Tools.php

ตัวอย่าง function
1.                  public static function jsonEncode($data)
2.           {
3.               if (function_exists('json_encode'))
4.                   return json_encode($data );
5.               else
6.               {
7.                   include_once(_PS_TOOL_DIR_.'json/json.php');
8.                   $pear_json = new Services_JSON();
9.                   return $pear_json->encode($data);
10.           }
11.       }

วิธีแก้ไข ให้เพิ่มคำสั่งในบรรทัดที่ 4 ด้วย
            return json_encode($data, JSON_UNESCAPED_UNICODE );
จะทำให้ไม่เกิดปัญหาอีกต่อได้



ยินดีด้วยกับผู้ที่เริ่มต้นการใช้งาน  J

Thursday, June 11, 2015

รูปแบบภาษาต่าง ๆ

รุ่น 1 : Programming Domains 1
ยุค จะหมายถึง Domain(กลุ่มของข้อมูลมากกว่า)
ยุคแรกต้องการการคำนวนแทนบุคคล โดยแรก ๆ จะเกี่ยวกับ Scientific
โดยจุดมุ่งหมายหลักคือต้องการ ประสิทธิภาสูง
FORTRAN จะเป็นภาษาที่นียมการคำนวนเกี่ยวกับตัวเลข ไม่มีการตัดทศนิยม (อ้างอิงฐาน 2)
ยุคที่สอง เกี่ยวกับ Bussiness
โดยเน้นการรายงานเกี่ยวกับ ธุรกิจต่าง ๆ โดยอ้างอิงตัวเลขฐานสิบ ตัวอย่างเช่น
COBOL
ยุคที่สามเกี่ยวกับ AI(Artificial intelligence)
โดยมักจะเขียนด้วยสัญลักษณ์ ต้องการเรียนแบบความคิด
เช่น LISP,Prolog

รุ่น 2 : Programming Domains 2
4 Systems Programming การสร้าง ระบบปฏิบัติการ ส่วนใหญ่มักติดต่อกับ H/W และทำการได้เร็ว ตัวอย่างเช่น
PL/S(IBM),BLISS(Digial),ALGOL(Burroughs),C(UNIX,LINUX,WINDOWS)
4 Scripting Languages ส่วนใหญ่จะใช้ command เป็นรูปประโยคในการทำงาน ตัวอย่างเช่น
sh and ksh(for shell),awk(report-generation),tcl and tk(X Window),Perl(CGI programming)
6 Special purpose languages มักจะใช้เฉพาะเจาะจงในการใช้งานเช่น
GPSS -> System simulation
PRG -> Business Report

Tuesday, June 09, 2015

[PrestaShop][EN]Let’s start to use PrestaShop Automatic Translations.

[Installation][PrestaShop] Using PrestaShop Translations with web hosting, it’s always found some problem in translation module as follows:

PHP message (some hosting)
Warning! Your hosting provider is using the Suhosin patch for PHP, which limits the maximum number of fields allowed in a form: 1000 สำหรับ suhosin.post.max_vars
1000 สำหรับ suhosin.request.max_vars
Please ask your hosting provider to increase the Suhosin limit to 3603 at least, or you will have to edit the translation files.

Future more, when you translate other languages you will always have many problems and you need to spend a lot of time to translate by yourselves, so I have developed a small application for translating both of translate individual and translate with google translation for easy to use it.
Finally, it’s free for used.

Let’s start to use PrestaShop Automatic Translations.

Download






Saturday, June 06, 2015

[PrestaShop][EN] Describing more detail in structure of PrestaShop for people who want to write PrestaShop in Multilanguage Part 2


          The latest blog, you have known about structure in PrestaShop for using Multilanguage or dynamic language after that I will explain more information in this structure that how the structure is.  For understanding before you customize the PrestaShop by yourself

admin.php File from folder translations
$_LANGADM['AdminCartRulesd3b206d196cd6be3a2764c1fb90b200f'] = 'Delete selected';

Explaining the structure
$_LANGADM is a variable called Array
'AdminCartRulesd3b206d196cd6be3a2764c1fb90b200f' is the key of the Array it is a part of module and md5 string
d3b206d196cd6be3a2764c1fb90b200f is MD5 of string such as Delete selected = d3b206d196cd6be3a2764c1fb90b200f

‘Delete selected’; is value of the word or statement from Array
For example;
If you change the word from ‘Delete selected’ to ‘selected to delete’, the word on the screen display will be changed. Absolutely, if you want to translate other language you can do this.

For example: changing the language
$_LANGADM['AdminCartRulesd3b206d196cd6be3a2764c1fb90b200f'] = ' Sil seçili '; // turkish

P.S. It is more important, when you change value of key of the Array, you must not change md5 key that the key is ‘Delete selected’ encrypted.
On next paragraph, I will explain more detail for key md5 (read more ***)

a template file from modules, in this case, I choose blockuserinfo module. when you open folder blockuserinfo on ‘\modules\blockuserinfo’ you will look .tpl file at that folder, surely, filename .tpl is a PHP Smarty template that is on views folder or outside that folder.

For example: PHP Smarty Template
<p id="header_user_info">
                        {l s='Welcome' mod='blockuserinfo'}
                        {if $logged}
                                     <a href="{$link->getPageLink('my-account', true)|escape:'html'}" title="{l s='View my customer account' mod='blockuserinfo'}" class="account" rel="nofollow"><span>{$cookie->customer_firstname} {$cookie->customer_lastname}</span></a>
                                     <a href="{$link->getPageLink('index', true, NULL, "mylogout")|escape:'html'}" title="{l s='Log me out' mod='blockuserinfo'}" class="logout" rel="nofollow">{l s='Sign out' mod='blockuserinfo'}</a>
                        {else}
                                     <a href="{$link->getPageLink('my-account', true)|escape:'html'}" title="{l s='Log in to your customer account' mod='blockuserinfo'}" class="login" rel="nofollow">{l s='Sign in' mod='blockuserinfo'}</a>
                        {/if}
            </p>
 

In the structure .tpl, the file that contains tag for display Multilanguage on screen as follows;
{l s='Welcome' mod='blockuserinfo'}
{l s='View my customer account' mod='blockuserinfo'}
{l s='Log me out' mod='blockuserinfo'}
{l s='Log in to your customer account' mod='blockuserinfo'}
{l s='Sign in' mod='blockuserinfo'}


Describing:
{} is a tag for display from PHP smarty
l is a language
s is a string or sentence
mod is a module name

Normally, writing tag in smarty template I will always write in an English for standardization, so it’s meaning I have never written en.php file. Even though, some module write tag smarty not standardization I need to write en.php file too.
Be careful, writing “ l s=’String key’ from native language you must encrypt md5 from that language.


Next session, I will explain a relation of translations and module with .tpl and .php

Tags:
Admin, Introduction, Language, Module, Multilanguage, PHP, PrestaShop, Smarty, Translation, 

Writer:

WindowsDNA

[PrestaShop] การอธิบายเพิ่มเติม ในเนื้อหาภายในโครงสร้างว่ามีลักษณะอย่างไร สำหรับการเขียนเว็บไซต์หลายภาษา ด้วย PrestaShop ตอนที่ 2

[PrestaShop] หลังจากที่ทราบโครงสร้างขอ PrestaShop สำหรับการทำเว็บไซต์หลายภาษาแล้ว ทั้งนี้จะอธิบายเพิ่มเติม ในเนื้อหาภายในโครงสร้างว่ามีลักษณะอย่างไร เพื่อความเข้าใจก่อนการปรับแต่งให้เหมาะสมกับเว็บไซต์ของตัวเอง

ไฟล์ admin.php จาก Folder Translations มีโครงสร้างดังนี้
$_LANGADM['AdminCartRulesd3b206d196cd6be3a2764c1fb90b200f'] = 'Delete selected';

แบ่งโครงสร้าง
$_LANGADM เป็น ตัวแปร เรียกว่า Array
'AdminCartRulesd3b206d196cd6be3a2764c1fb90b200f' คือ Key ของ Array นั้น ๆ โดยประกอบไปด้วย โมดูล + MD5
d3b206d196cd6be3a2764c1fb90b200f คือ MD5 ของข้อความของ Delete selected = d3b206d196cd6be3a2764c1fb90b200f

'Delete selected'; คือ ค่าที่บรรจุลงใน Array ข้างต้น เช่นถ้าเปลี่ยนเป็น ‘selected to delete’; ข้อความที่แสดงผ่านหน้าจอจะเปลี่ยนไป และหากอยากเปลี่ยนเป็นภาษาไทยเลยยังได้ เช่น
$_LANGADM['AdminCartRulesd3b206d196cd6be3a2764c1fb90b200f'] = 'ลบรายการที่เลือก';
*** ที่สำคัญ md5 ที่ได้จะต้องไม่เปลี่ยนแปลง ซึ่งจะยังคงเป็น md5 ของ Delete selected นั่นเอง
ต่อไปจะขยายความอีกครั้งว่าทำไมไม่เปลี่ยนแปลงในส่วน Key (เพิ่มเติม ***)


2 ไฟล์ template จาก modules โดยเลือก \modules\blockuserinfo เป็นตัวอย่าง จะเห็นไฟล์ .tpl ซึ่งเป็น PHP Smarty Template อาจจะอยู่ภายใต้ Folder views หรืออยู่ข้างนอกก็ได้
ตัวอย่าง PHP Smarty Template
<p id="header_user_info">
                        {l s='Welcome' mod='blockuserinfo'}
                        {if $logged}
                                     <a href="{$link->getPageLink('my-account', true)|escape:'html'}" title="{l s='View my customer account' mod='blockuserinfo'}" class="account" rel="nofollow"><span>{$cookie->customer_firstname} {$cookie->customer_lastname}</span></a>
                                     <a href="{$link->getPageLink('index', true, NULL, "mylogout")|escape:'html'}" title="{l s='Log me out' mod='blockuserinfo'}" class="logout" rel="nofollow">{l s='Sign out' mod='blockuserinfo'}</a>
                        {else}
                                     <a href="{$link->getPageLink('my-account', true)|escape:'html'}" title="{l s='Log in to your customer account' mod='blockuserinfo'}" class="login" rel="nofollow">{l s='Sign in' mod='blockuserinfo'}</a>
                        {/if}
            </p>
 

ในโครงสร้าง *.tpl นั้นจะบรรจุ Tag สำหรับ การแสดงผลในรูปแบบหลายภาษาด้วยตัวอย่างดังนี้
{l s='Welcome' mod='blockuserinfo'}
{l s='View my customer account' mod='blockuserinfo'}
{l s='Log me out' mod='blockuserinfo'}
{l s='Log in to your customer account' mod='blockuserinfo'}
{l s='Sign in' mod='blockuserinfo'}

คำอธิบาย
{} คือ โครงสร้างการแสดงผล Smarty
l คือ การแสดงผลภาษา
s คือ ข้อความที่ต้องการแสดงผล
mod คือ Module สำหรับการแสดงผลภาษานั้น ๆ

โดยปกติการเขียน Tag ในส่วน Template ของ Smarty นั้นเรามักจะเขียนเป็นภาษาอังกฤษเป็นมาตรฐาน ดังนั้นจะหมายความว่า เราไม่จำเป็นต้องเขียนไฟล์ภาษา en.php เลย หากแต่ว่า มีบางโมดูลไม่ได้เขียนเป็นภาษาอังกฤษก็จำเป็นจะต้องเขียนโครงสร้างไฟล์ภาษา en.php ด้วยเช่นเดียวกัน (***ข้อควรระวัง: การเขียน l s=’String Key’ ด้วยภาษาอะไร ก็ต้องจัดทำ MD5 ด้วยภาษานั้น ๆ)

ครั้งต่อไปจะพูดถึง Translations สำหรับ Modules โดยดูความสัมพันธ์ของ .tpl และ .php


Tags:

Multilanguage,Translation,PrestaShop,Module,Admin,Smarty,PHP

Writer:
WindowsDNA