Jump to content

Recommended Posts

hi all,

 

I need to ask for your suggestion to design sites in different language, I need to make site in 4 language,

English, French, Spanish and Dutch.

 

All pages are dynamic PHP based, i completed the English part and was about to start for other language, but I thought it will be hard work, is there any technique to minimize the work or I need to make all the pages in each language.

 

The site consist of 54 pages and English is complete. For other language do I need to make all these pages or is there any idea. And for the Admin part how to design the database, I am getting confused.

 

Any Suggestion ???

 

 

Link to comment
https://forums.phpfreaks.com/topic/71479-desiging-website-in-different-languages/
Share on other sites

Php is not a storage method....

Just store messages in something else like a flatfile or RDBMS.

 

your answer got me confused again, what i meant is back end is done in PHP + MySQL, i am just asking do i need to save the contents for 4 language in separate table or not ??? Do I need to make all the pages 4 times for 4 different language...

 

thanks

No. Php is not a storage method. Using strings to store messages or content is bad practice, if you'll allow me the absolutism.

 

Application messages (e.g. "Please insert coin", "You missed the can. Please improve you aim"), as I said, store them externally.

 

For actual content ("How To Dodge An Atom Bomb", "Why George Bush Can't Do Without His Pink Panties"), there are plenty of ways to do this, but I'd just store the language code in a seperate col.

 

e.g.:

 

SELECT * FROM articles WHERE lang_code = "EN";

 

 

Ok as you say 448191

 

SELECT * FROM articles WHERE lang_code = "EN";

 

It will select everything from the table article where language is English, your reply looks good. But as you said I made a admin page from where the client will insert contents and there I kept a List box with values EN, FR, ESP and DE (for english, french, spainish and dutch). It will work for the contents only right, what about the Menu, other static contents do we have to make them separate file for each language or one will work. Just confused in that

 

 

If you don't mind I will ask you a question (to make my problem simple)

 

Suppose I give you a site to make with 20 static pages in 4 languages. The design for English is Complete and you have to make it in other 3 languages.

 

How are you going to do it to minimize the work?

 

Are you going to "SAVE AS" all the page in each language and make (20 x 3 = 60 pages ) and add the content from the respective language .

 

Thanks

 

 

 

Ok, I'll keep this as simple as I possibly can. We'll use a basic INI file.

 

file "NL.ini":

 

get_barred = "Ga fietsen."
home = "Thuis"

 

Rediculously simple Message class:

 

<?php
class Messages {
private static $strings = array();

public static function init($langCode = 'EN'){
	//Load the language file here
	self::$strings = ini_parse('/langfiles/'.$langCode.'.ini');
}
public static function get($id){
	//Return the appropiate string
	return self::$strings[$id];
}
}
?>

 

Example use in template:

 

<h1><?php echo Messages::get('get_barred'); ?></h1>

 

You have to load te file before that, obviously:

 

Messages::init('NL');

 

If you really want to get fancy, you'll use custom tags:

 

<h1><msg id="get_barred" lang="NL"></h1>

 

But to explain how you would do that would take me more time than I can get away with at work.  ;)

You can't really use a string/word conversion method for anything more than a simple menu and/or days of week/months, etc.

 

You need to store the fully translated data in a separate file or in a database and either include the correct language file or pull the correct data from the DB. 

 

if you are already pulling your text from a db, then that would be the way to go.

You can't really use a string/word conversion method for anything more than a simple menu and/or days of week/months, etc.

 

You need to store the fully translated data in a separate file or in a database and either include the correct language file or pull the correct data from the DB. 

 

if you are already pulling your text from a db, then that would be the way to go.

 

What if I don't need it dynamic, is it possible If I keep all the contents in a text file and fetch it through PHP, so that I don't have to create separate page for all the contents.

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.