Jump to content

website in 2 languages


phpmady

Recommended Posts

hi,

 

 

I want to develop website in 2 langauges arabci and english...

 

already i have a website in english, that constitute folders like

 

 

images

js

css

templates

home.php

news.php

articles.php

...

....

 

 

 

now how to proceed for arabic language, is it better to make the entire website duplicated for arabic, or only the templates change is enough,,, like

 

 

templates_arabic

templates_english

images

js

css

home.php

news.php

articles.php

...

....

 

 

 

Pls give me a suggestion, so that i can develop my website

 

Thank You

Link to comment
Share on other sites

The easiest way would be to use different template files as you suggested. A more complicated way, but doesn't repeat as much code is to have a language method when you output. So for example if you have this in a page

 

 

<h1>News</h1>

 

 

You would instead have

 

<h1><?php echo lang('News'); ?></h1>

 

And that method would check what language to use, and return the correct word. As to how you would get the correct word is up to you, you could use a flat file like a .txt file, or make a database table of terms with their translations.

Link to comment
Share on other sites

The easiest way would be to use different template files as you suggested. A more complicated way, but doesn't repeat as much code is to have a language method when you output. So for example if you have this in a page

 

 

<h1>News</h1>

 

 

You would instead have

 

<h1><?php echo lang('News'); ?></h1>

 

And that method would check what language to use, and return the correct word. As to how you would get the correct word is up to you, you could use a flat file like a .txt file, or make a database table of terms with their translations.

 

 

How can i traverse from one language to another language.. suppose if i am in news.php, i want to go to same in arabic news.php...

 

 

Link to comment
Share on other sites

You can use a cookie or session to track their current language, or even a $_GET variable. For instance, if we  went the get route and your pages could have links to http://www.mysite.com/?lang=arab

 

You could have this line of code on every php file

$language = isset($_GET['lang']) && $_GET['lang'] == 'arab' ? 'arab' : 'eng'; //Set language to arab if set in the url, otherwise default to eng.

 

Then when you include you can do

if($language == 'arab') include '/path/to/file/news_arab.php';
else include '/path/to/file/news.php';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.