Step by step guide to create an english/arabic site

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.

[rtl]

للأسف الطريقة المعتمده لعمل موقع متعدد اللغات في Yii هي بإنشاء ملف للغات

بحث يعيد هذا الملف مصفوفة يكون فيها المفتاح هو source language والقيمة هي الترجمة

[/rtl]


<?php

return array(

	....

	....

	'source message' => 'الترجمة هنا',

	....

	....

);

?>

[rtl]

ملاحظة قد قد تسهل عليك كثيرا

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

[/rtl]


protected/yiic message <CONFIG_FILE>

[rtl]

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

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

[/rtl]


<?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',

	),

);

[rtl]

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

[/rtl]


protected/yiic message protected/messages/config.php

[rtl]

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

:rolleyes:

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

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

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

[/rtl]


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

[rtl]

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

[/rtl]


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

[rtl]

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

[/rtl]


<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; ?>">

[rtl]

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

اذا في اي استفسار لاتتردد بالسؤال

موفق خير ان شاء الله

[/rtl]

[rtl]

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

[/rtl]

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

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

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

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.’

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

here are the tow files:

1652

files.tar.gz

unfortunately yii.php is not translated yet

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

sorry my mistake,

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




return array(

  ......

  'components'=>array(

	'coreMessages'=>array(

      	'basePath'=>'protected/messages',

	),

   ......

  ),

 );



thanks that worked

and can you tell me please how to translate the field name such as ‘email’

sure :)

‘email’ => ‘البريد الإلكتروني’

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 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

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.

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.

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?

[right]مشكورين[/right]

[size="7"][center][center]هذا المنتدى عربي أم إنجليزي

!!!!!!!!!!!!!!!!!!!![/center][/center][/size]

هذا المنتدى عربي ولا كن بعض الاسئلة تطرح من قبل غير المتحدثين باللغة العربية

Have you had any progress in translating the base yii.php messages to arabic? I had hoped that it might be near since the thread is so old, but I did not see it in the project?