چطور دوزبانه بنویسیم؟!

gigamax

کاربر متخصص جلوه های ویژه
سلام دوستان ... خوبین ؟

من بعد از کنکاش های فراوان برای قسمت بلاگ سایتم از سیستم ورد پرس می خوام استفاده کنم ... اما یه مشکلی هست ... من پستام دو زبانه هستن ... یعنی یک پست میدم اما یکی فارسی یکی انگلیسی ...

سوال من اینه چطور توی ورد پرس کاری کنیم که وقتی پستی رو میدم کاربر بتونه بین پست فارسی یا انگلیسی سوییچ کنه ؟!!

میشه همچین کاری کرد ؟!

موفق باشین
 

Mr.Steres

Active Member
می تونید مالتی بلاگی فارسی یا انگلیسی بسازید و مثل همه سایت ها منویی برای انتخاب زبان در نظر بگیرید
 

gigamax

کاربر متخصص جلوه های ویژه
چطور در ورد پرس این کارو بکنم ؟!!

نمی خوام دوتا بلاگ داشته باشم ... فقط هر پست شامل قسمت انگلیسی و فارسی جدا باشه ...

ممنونم از اینکه جواب میدین
 

Mr.Steres

Active Member
وردپرسی ها 2 هفته پیش ابزارکی رو دادند بیرون که با استفاده از گوگل ترانس مطالب رو ترجمه می کرد ! شمامی تونی زیر مطالب قسمتی رو قرار بدید که متن انگلیسی رو بنویسی ! البته بهترینش روش بالاست ...
 

gigamax

کاربر متخصص جلوه های ویژه
حالا گوگل ترنزلیتور حالا حالا ها کار داره ... هر دو متنو خودم باید بنویسم ...

می تونید یه نمونه از همین بلاگ ها رو آدرسشو بدین ببینم همین چیزیه که من می خوام یا نه ؟!
 

Mr.Steres

Active Member
اتفاقا فارسی به انگلیسیش قویه ! اینجا و اینجا جفتش هم وردپرس هست با همان مالتی بلاگ ساختن

اینم راهکار وردپرس :
PHP:
Solution:
Step One. Create two copies of the default single.php file. Give these two new files identifiable names, eg. single-general.php and single-reviews.php.

Step Two: Open the original default single.php file in your text editor (eg. Notepad). Delete all the code within this file and replace it with the following, then save and close the file.

$post = $wp_query->post;
if ( in_category('2') ) {
include(TEMPLATEPATH . '/single-reviews.php');
} else {
include(TEMPLATEPATH . '/single-general.php');
}
?>

What does this code do? Here's a dodgy plain english overview.

$post = $wp_query->post

When a user opens (or requests) a post, Wordpress takes a look at it, and runs a query on it (to see what it is).

if ( in_category('2') ) {
include(TEMPLATEPATH . '/single-reviews.php');

This starts the 'if' statement, and says 'if the post that has been queried is from the category with the ID '2' then use the single-reviews.php template. Obviously you'd create a 'Reviews' category in WordPress and use the 'Reviews' categories ID number. You can find the ID number by logging into your Dashboard and the selecting Manage > Categories then find the ID for the relevant category. For the sake of this exercise assume that the 'Reviews' category ID is '2'.

} else {
include(TEMPLATEPATH . '/single-general.php');
}

This section of code says that if the post is not from the category with the ID '2' then use the single-general.php template instead.

So that's pretty much all the code explained. The whole thing uses a simple 'if/else' statement. An 'if/else' statement works by testing a condition. If the condition is satisfied it does the 'if' section, if it's not satisfied it does the 'else' section of the code. In other words, you could read it as, "if I'm hungry, have lunch, else carry on as normal".

Step Three.
Style and layout your two new files, single-general.php and single-reviews.php, however you like. Now if everything has gone to plan you should be able to display posts from a specific category differently to posts from every other category

اینم کد گوگل ترانس :

HTML:
<script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/translatemypage.xml&up_source_language=fa&w=160&h=60&title=&border=&output=js"></script>

Language switcher هم میشه استفاده کرد !
 

جدیدترین ارسال ها

بالا