Yii Framework Forum: Step by step guide to create an english/arabic site - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Step by step guide to create an english/arabic site

#1 User is offline   Sarfraz Sarwar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 19-December 10

Posted 15 May 2011 - 04:02 AM

Dear all, i need a step by step guide to create a multilingual site in english and arabic. i dont want to write messages in a file and then translate them. i have already created the english version and only want to create the arabic views as they are rtl and design changes some what.
0

#2 User is offline   Muaid 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 107
  • Joined: 25-October 10
  • Location:Saudi Arabia

Posted 15 May 2011 - 11:02 AM

View PostSarfraz Sarwar, on 15 May 2011 - 04:02 AM, said:

i dont want to write messages in a file and then translate them.



للأسف الطريقة المعتمده لعمل موقع متعدد اللغات في Yii هي بإنشاء ملف للغات
بحث يعيد هذا الملف مصفوفة يكون فيها المفتاح هو source language والقيمة هي الترجمة


<?php
return array(
	....
	....
	'source message' => 'الترجمة هنا',
	....
	....
);
?>


ملاحظة قد قد تسهل عليك كثيرا
عند استخدام Yii::t(); فإنه يمكنك انشاء ملفات اللغات اوتوماتيكيا عن طريق سطر الاوامر بأمر بسيط

protected/yiic message <CONFIG_FILE>


بحيث ان <CONFIG_FILE> هو ملف داخل مجلد protected/messages/config.php

ويكون محتواة كالتالي (قم بتعديلة ليتناسب مع متطلباتك)


<?php
/**
 * This is the configuration for generating message translations
 * for the Yii framework. It is used by the 'yiic message' command.
 */
return array(
	// source Path to start recursive seach
	'sourcePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..',

	// messages folder Path
	'messagePath'=>dirname(__FILE__),

	// languages you want to translate the whole site into
	'languages'=>array('ar'),

	// specify a file types to look into
	'fileTypes'=>array('php'),

	// function search key
	'translator' => 'Yii::t',

	// if you do not need to exclude any file or folders you can remove it ..
	// this is only example and you should modify it to suite your needs.
	'exclude'=>array(
		'.git',
		'/index.php',
		'yiic.php',
		'/assets',
		'/blog',
		'/css',
		'/images',
		'/theme',
	),
);



فيصبح الامر النهائي كالتالي


protected/yiic message protected/messages/config.php



هذا فيما يخص الرسائل
:rolleyes:

اما بخصوص طريقة تحويل التصميم من اليمين إلى اليسار ماهي صعبة ان شاء الله

لنفرض انك تريد وضع dir="rtl" في وسم html في حال كانت اللغة المختارة هي العربية

الكود التالي سيكون موجود في ملف views/layouts/main.php بشكل افتراضي


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">



وانت تريدة ان تكون النتيجة في حال كانت اللغة العربية كالتالي

<html dir='rtl' xmlns="http://www.w3.org/1999/xhtml" xml:lang="ar" lang="ar">


كل ماعليك فعله هو التحقق من Yii::app()->language وعرض النتائج بناء على النتيجة كالتالي

<html <?php if(Yii::app()->language == 'ar')  echo "dir='rtl'"; ?> xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo Yii::app()->language; ?>" lang="<?php echo Yii::app()->language; ?>">



مع الاخذ بعين الاعتبار ان لغتك الاساسية في الموقع الانجليزية لذلك فإن قيمة Yii::app()->language في حال كانت اللغة انجليزية سيكون en

اذا في اي استفسار لاتتردد بالسؤال
موفق خير ان شاء الله

3

#3 User is offline   Muaid 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 107
  • Joined: 25-October 10
  • Location:Saudi Arabia

Posted 15 May 2011 - 11:11 AM


تذكرت هذا الرابط ممكن يفيدك


setting-and-maintaining-the-language-in-application-i18n
1

#4 User is offline   Sarfraz Sarwar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 19-December 10

Posted 21 May 2011 - 11:45 AM

thanks a lot muaid but i DON'T UNDERSTAND ARABIC.
sorry but i am only developing a site for a client and he wants it in two languages english and arabic. i have developed two different sides for this reason.
please guide me how i can set the language dynamically/on user request.
and then get the respective views.
the layout files also need to be changed.
how to do that
0

#5 User is offline   Muaid 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 107
  • Joined: 25-October 10
  • Location:Saudi Arabia

Posted 21 May 2011 - 12:07 PM

no problem at all Sarfraz Sarwar,

i believe the link i posted above is exactly what you need .. it show you how to make a drop down list with your tow languages and display the selected one Posted Image

i hope it solve your problem.
0

#6 User is offline   Sarfraz Sarwar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 19-December 10

Posted 22 May 2011 - 02:55 AM

View PostMuaid, on 21 May 2011 - 12:07 PM, said:

no problem at all Sarfraz Sarwar,

i believe the link i posted above is exactly what you need .. it show you how to make a drop down list with your tow languages and display the selected one Posted Image

i hope it solve your problem.


didn't like the control file option.
implemented the behavior idea given in the comments.
now what do i have to do to change the error messages created by yii, such as 'Email cannot be empty.'
0

#7 User is offline   Muaid 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 107
  • Joined: 25-October 10
  • Location:Saudi Arabia

Posted 22 May 2011 - 03:35 PM

these messages is (Yii's Core Messages) and needs to be translated and place them in messages/ar/*

there is a project for translating whole Yii framework (Guide, Blog tutorial and Core Messages) to many languages, and i am currently working on Arabic translation and looking for volunteers to help me completing this task as soon as possible ... project link


But you only need to translate tow files to accomplish your goal.

yii.php (contains 254 messages to be translated)
zii.php (i already translated this small file)
<i'll attachments the files>

after you finish translating those, you only need to upload them into

protected/messages/ar/yii.php
protected/messages/ar/zii.php



Congratulations !! you are done Posted Image


here are the tow files:
Attached File  files.tar.gz (6.74K)
Number of downloads: 112

unfortunately yii.php is not translated yet Posted Image

and if you do translate it, please contact me to commit it into the official yiidoc project.

thank you.
2

#8 User is offline   Sarfraz Sarwar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 19-December 10

Posted 04 June 2011 - 10:24 AM

View PostMuaid, on 22 May 2011 - 03:35 PM, said:

these messages is (Yii's Core Messages) and needs to be translated and place them in messages/ar/*

there is a project for translating whole Yii framework (Guide, Blog tutorial and Core Messages) to many languages, and i am currently working on Arabic translation and looking for volunteers to help me completing this task as soon as possible ... project link


But you only need to translate tow files to accomplish your goal.

yii.php (contains 254 messages to be translated)
zii.php (i already translated this small file)
<i'll attachments the files>

after you finish translating those, you only need to upload them into

protected/messages/ar/yii.php
protected/messages/ar/zii.php



Congratulations !! you are done Posted Image


here are the tow files:
Attachment files.tar.gz

unfortunately yii.php is not translated yet Posted Image

and if you do translate it, please contact me to commit it into the official yiidoc project.

thank you.


pasted the files in protected/messages/ar/
but it is not translating
"Displaying 1-1 of 1 result(s)."
is being displayed as
".(Displaying 1-1 of 1 result(s"

also pasted
'{attribute} cannot be blank.' => '.للا يمكن أن تكون فارغة {attribute}',

in protected/messages/ar/yii.php
but it is not being translated

file translation is working
only yii core messages and zii messages are not working.

please help. i have no idea
0

#9 User is offline   Muaid 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 107
  • Joined: 25-October 10
  • Location:Saudi Arabia

Posted 04 June 2011 - 12:54 PM

sorry my mistake,

add this code in your components configuration in protected/config/main.php :

return array(
  ......
  'components'=>array(
	'coreMessages'=>array(
      	'basePath'=>'protected/messages',
	),
   ......
  ),
 );

0

#10 User is offline   Sarfraz Sarwar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 19-December 10

Posted 05 June 2011 - 07:35 AM

thanks that worked

and can you tell me please how to translate the field name such as 'email'
0

#11 User is offline   Muaid 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 107
  • Joined: 25-October 10
  • Location:Saudi Arabia

Posted 05 June 2011 - 02:54 PM

sure :)

'email' => 'البريد الإلكتروني'
0

#12 User is offline   ItsYii 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 24-January 12

Posted 30 April 2013 - 08:58 AM

Hi Muiad

I'm currently looking to translate messages to arabic, I'm wondering how far you have reached. I chekced out the link but there's no downloads.

Have you managed to finish the Yii? if you have some done will you be able to provide it. If it's incomplete I will complete it and send it over.

This is the only link I have found for this topic, I can't find any Arabic messages currently.

Thanks
0

#13 User is offline   saleem 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 16-February 13

Posted 16 November 2013 - 06:05 AM

Hi Muaid,


i have developed the site in YII default language is english ,for that now client needs the arabic language conversion which means all the dynamic content should also get translated and another thing while typing the name in text box in the form should also in Arabic is this possible..

Thanks
Abs
0

#14 User is offline   Muaid 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 107
  • Joined: 25-October 10
  • Location:Saudi Arabia

Posted 18 November 2013 - 09:24 AM

View PostItsYii, on 30 April 2013 - 08:58 AM, said:

Hi Muiad

I'm currently looking to translate messages to arabic, I'm wondering how far you have reached. I chekced out the link but there's no downloads.

Have you managed to finish the Yii? if you have some done will you be able to provide it. If it's incomplete I will complete it and send it over.

This is the only link I have found for this topic, I can't find any Arabic messages currently.

Thanks


Hi ItsYii,

there is no Arabic translated messages till now (as i know). i translated it once before (on linux virtual machine) then i removed that machine and i forget that i have work there :(


any way the messages are not a big list of mesaages (around 250 strings), so if you already have it i can check it again with you then commit it to be available in next Yii version.

thank you.
0

#15 User is offline   Muaid 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 107
  • Joined: 25-October 10
  • Location:Saudi Arabia

Posted 18 November 2013 - 09:34 AM

saleem,


yes it can be done in Yii.


you need to translate the content of the website it self not only static contents, for this there is many approches to accomplish this:

1- adding new fields in the same table to hold translated content and in the view you can show needed content regarding current picked language.

2- generating new table that will hold the translated content and you can show needed content regarding current picked language.


for textbox you can do the same, if the user is showing arabic search in arabic content and vise versa.


i hope this hints will invoke your imagination in this regards.
0

#16 User is offline   Dana 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 203
  • Joined: 18-February 10
  • Location:Florida, USA

Posted 26 March 2014 - 04:38 PM

Have you had any progress in translating the base yii.php messages to arabic? I'm currently converting some pages to include this language setting, and it's the last bit that is missing. I had hoped that it might be near since the thread is so old, but I did not see it in the project?
0

#17 User is offline   rai4it 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 25-March 14

Posted 06 June 2014 - 03:28 PM

مشكورين
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users