Step by step guide to create an english/arabic site
#1
Posted 15 May 2011 - 04:02 AM
#2
Posted 15 May 2011 - 11:02 AM
Sarfraz Sarwar, on 15 May 2011 - 04:02 AM, said:
للأسف الطريقة المعتمده لعمل موقع متعدد اللغات في 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
هذا فيما يخص الرسائل
اما بخصوص طريقة تحويل التصميم من اليمين إلى اليسار ماهي صعبة ان شاء الله
لنفرض انك تريد وضع 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
اذا في اي استفسار لاتتردد بالسؤال
موفق خير ان شاء الله
#4
Posted 21 May 2011 - 11:45 AM
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
#5
Posted 21 May 2011 - 12:07 PM
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.
#6
Posted 22 May 2011 - 02:55 AM
Muaid, on 21 May 2011 - 12:07 PM, said:
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.'
#7
Posted 22 May 2011 - 03:35 PM
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:
files.tar.gz (6.74K)
Number of downloads: 76
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.
#8
Posted 04 June 2011 - 10:24 AM
Muaid, on 22 May 2011 - 03:35 PM, said:
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:
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
#9
Posted 04 June 2011 - 12:54 PM
add this code in your components configuration in protected/config/main.php :
return array(
......
'components'=>array(
'coreMessages'=>array(
'basePath'=>'protected/messages',
),
......
),
);
#10
Posted 05 June 2011 - 07:35 AM
and can you tell me please how to translate the field name such as 'email'
#12
Posted 30 April 2013 - 08:58 AM
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

Help











