A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearBest system for multiple language support in PHP? - page 1
User InfoPosts
Best system for multiple language support in PHP?#1
I have an PHP application that I want localized. Currently, the way I(m doing this is a very ugly way: $loc[(hello(] = "Hello", echo $loc[(hello(]; will show Hello, and you can change the file to change the language. What I want is a better way and a faster of doing this, what I(m considering:


1 XML file with language data for all page (will it be slow as every page will load the language data for the entire site)
Multiple files, one xml file for each page (not much help as it is just as messy as the old system)
gettext() (This seem to be the best way, but I only discovered it today, so will it be hard to change from my current system to this? Is it fast?)


So to summarize, which way is the fastest, the cleanest, and the easiest to move from my current way to the new one. Thanks.

posted date: 2009-04-15 18:09:00


Re: Best system for multiple language support in PHP?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-15 18:09:01


Re: Best system for multiple language support in PHP?#3
Similar Questions:what is the best method to build “multilingual” script in php?Programming Multi-Language PHP applicationsHere(s a benchmark comparing gettext with string-array: Benchmarking PHP Localization - Is gettext fast enough?

posted date: 2009-04-15 18:20:00


Re: Best system for multiple language support in PHP?#4
A PHP array like the one you already have is pretty fast and clean in my opinion.Localization itself is ugly to code and manage changes so don(t expect that there is a method to make all the pain go away.

posted date: 2009-04-15 18:24:00


Re: Best system for multiple language support in PHP?#5
Thanks for the quick reply! But one of the thing I want to know is how slow would it be to let's say load a XML of 100 localization data when only 10 is required for the page. Does the XML parser read the whole file to memory? or does it look for the key you want.

posted date: 2009-04-15 18:29:00


Re: Best system for multiple language support in PHP?#6
I added a link for a benchmark test that compares gettext with other approaches.

posted date: 2009-04-15 18:33:00


Re: Best system for multiple language support in PHP?#7
If you're going to use XML, most probably the parser will read the whole file in order to allow search\access.

posted date: 2009-04-15 18:34:00


Re: Best system for multiple language support in PHP?#8
Ok, thanks, and for anyone who's wondering, I've decided to stick with my current system with a few modifications (all language data is in one file, but it only loads the required strings). And users can import an XML file which generates a PHP file (for people who don't know PHP and want to transl

posted date: 2009-04-16 13:57:00


Re: Best system for multiple language support in PHP?#9
well, I personally would go with gettext only if the project is large enough (i.e. worth the trouble). For small project or scripts, I would use something like string array or XML file.

posted date: 2009-04-16 15:44:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.