Showing posts with label Introduction. Show all posts
Showing posts with label Introduction. Show all posts

Sunday, June 21, 2015

[PrestaShop][Language][EN] Deep into the translation of modules and system in PrestaShop (Final Episode) Part 2

[PrestaShop][Language][EN] Deep into the translation of modules and system in PrestaShop (Final Episode) Part 2

In the last episode of translations in prestashop, you will see the structure of theme as follows,

The structure of folder Lang from theme for instance, \themes\ap_office\lang. it is the last folder that I will explain.
Please look at below
global $_LANG; 
$_LANG = array(); 

$_LANG['404_d0fbda9855d118740f1105334305c126'] = 'Page not found'; 
$_LANG['404_44b1d05764b093cb00c25b8228cb87d3'] = 'This page is not available'; 
$_LANG['addresses_d95cf4ab2cbf1dfb63f066b50558b07d'] = 'My account'; 
$_LANG['addresses_e45be0a0d4a0b62b15694c1a631e6e62'] = 'My addresses'; 

For the language in which is written by theme that It has a new variable, so you will see the name is $_LANG, and the name as a variable that controls all of messages to express on all screen that more details as below.
$_LANG['addresses_e45be0a0d4a0b62b15694c1a631e6e62'] = 'My addresses'; 
$_LANG means a variable
addresses_ means an action or a template file(*.tpl) that is expected a relations of expression on screen for this example you will see a relation of language and addresses.tpl that contains a command or sentence for instance,
{l s='My addresses'}  you will see the language tag is too small detail, moreover you may not write mod(ule) tag concatenates the language tag.

e45be0a0d4a0b62b15694c1a631e6e62 means MD5 of My addresses
'My addresses' means a message or string to express on screen

          The concluding of explaining translation language, you will see the prestashop that is designed for support multilingual or using multiple language website as well as comfortable.
even though, there are more parts of language I won’t explain but it has more important as good as template file that is a language of database, as if I have never explained on the other hand you can write and save many languages on the screen of prestashop system that the system provided a part of optional language too, furthermore, you will write more details and more languages If you want to express it.


Hopefully, All the articles that I wrote, It will explain you so that you will understand in mechanism of multilingual in prestashop as well as possible. If you have some question you can send a message for me. I glad to meet you all guys.


WindowsDNA wrote.


[PrestaShop][Language][EN] Deep into the translation of modules and system in PrestaShop (Final Episode) Part 1

[PrestaShop][Language][EN] Deep into the translation of modules and system in PrestaShop (Final Episode) Part 1

          Folder both Translations and Lang that there are more different structure, Today, I will explain all of structures to you so that you would try to use its correction and automation if you use with Prestashop Automatic Translations with google.

The structure of translations from system for instance, \translations\en\admin.php

global $_LANGADM; 
$_LANGADM = array(); 

$_LANGADM['AdminAddressesd3b206d196cd6be3a2764c1fb90b200f'] = 'Delete selected'; 
$_LANGADM['AdminAddressese25f0ecd41211b01c83e5fec41df4fe7'] = 'Delete selected items?'; 
$_LANGADM['AdminAddressesb718adec73e04ce3ec720dd11a06a308'] = 'ID'; 

If variables as a part of admin section or it’s an expression a message from backend zone that it will use variable name is $_LANGADM

$_LANGADM['AdminAddressesd3b206d196cd6be3a2764c1fb90b200f'] = 'Delete selected'; 

$_LANGADM means a name of variable
AdminAddresses means module’s name which express with each part
d3b206d196cd6be3a2764c1fb90b200f means MD5 of a message’s name is ‘Delete selected’
'Delete selected' means a message that you want to express on the screen

Although, It has many variables for admin section as if $_ERRORS, $_FIELDS, $_LANGPDF except $_TABS, so It contains a key without encrypt with MD5

the structure of translations from module for instance, fbconnect_psb\translations
global $_MODULE; 
$_MODULE = array(); 
$_MODULE['<{fbconnect_psb}prestashop>registration_fb_6335a00a08fde0fbb8f6d6630cdadd92'] = 'ข้อมูลส่วนบุคคล'; 
$_MODULE['<{fbconnect_psb}prestashop>registration_fb_b78a3223503896721cca1303f776159b'] = 'คำนำหน้า'; 
You will see the structure that It has a different variable which the prestashop system use a name of variable called $_MODULE as follows,
$_MODULE['<{fbconnect_psb}prestashop>registration_fb_6335a00a08fde0fbb8f6d6630cdadd92'] = 'ข้อมูลส่วนบุคคล'; 
$_MODULE means a name’s variable for get value of language
<{fbconnect_psb}prestashop>registration_fb_ means the key that is a part of language’s express and there are covered 3 attributes such as,
·       {fbconnect_psb} means a module name
·       <prestashop> means a Tag of prestashop
·       registration_fb means an action or a part of template file (*.tpl)

When 3 attributes compound, the language file will support module that have a several template files with only one file.

PS1: Even though, it contains the same word, but it is different template file. You must write a new key of template file.

PS2: For example a template file, you will see a statement as bellow,
{l s='Your personal information' mod='fbconnect_psb'}
It means a l(anguage) that contains s(tring) name is ‘Your personal information’ in a part of mod(ule) name is fbconnect_psb that It relates with en.php or th.php from the explanation above.


6335a00a08fde0fbb8f6d6630cdadd92   means MD5 of a message name is “ข้อมูลส่วนบุคคล

'ข้อมูลส่วนบุคคล' means a message you want to express on the screen

to be continued...

http://windowsdna.blogspot.com/2015/06/prestashoplanguageen-deep-into_21.html

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
d3b206d196cd6be3a2764c1fb90b200คือ MD5 ของข้อความของ Delete selected = d3b206d196cd6be3a2764c1fb90b200f

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


ไฟล์ 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
คือ การแสดงผลภาษา
คือ ข้อความที่ต้องการแสดงผล
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