multilingual php site

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
toyo
Forum Commoner
Posts: 42
Joined: Thu May 15, 2014 1:27 am

multilingual php site

Post by toyo »

Hi team, i have a site in english and i want to translate it into italian. Any one with any code snippet or technique to do this? i want the user to be able to choose preffered language to browse the site.. thx,

I will upload the current site if necessary
toyo
Forum Commoner
Posts: 42
Joined: Thu May 15, 2014 1:27 am

Re: multilingual php site

Post by toyo »

here is the site.. some codes need to be fixed too.. i will appreciate anyone willing to assist me.. thx
Attachments
New WinRAR ZIP archive.zip
(1.54 MiB) Downloaded 112 times
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: multilingual php site

Post by Celauran »

Depends on the site setup. For CMS-driven content, I'll typically use separate fields for each language, say title_en and title_fr, content_en and content_fr, etc. and choose which to display based on the language chosen by the user. For more static strings, you can use locale files (ie. .po) or even hashes.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: multilingual php site

Post by Christopher »

There are a number ways to do this. The simplest is multiple templates in sub-directories -- one directory for each language code. You can also use CSV files or even databases. And there is PHP's gettext() support.
(#10850)
toyo
Forum Commoner
Posts: 42
Joined: Thu May 15, 2014 1:27 am

Re: multilingual php site

Post by toyo »

OK team. can anyone put a litle tutorial together for me on how to do this? i will also be happy if you can download the attachment and go tru it for constructive criticism.. thx
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: multilingual php site

Post by Celauran »

Nobody's going to download some random zip. Why not put your code somewhere we can see it (Pastebin, Bit Bucket, GitHub, etc)?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: multilingual php site

Post by Christopher »

Your first decision is whether you want to have separate files for each page for each language, or do have multi-lanugage code in the page?
(#10850)
Post Reply