
Journal roboros's Journal: Multi-language web applications in PHP? 7
I am going to build a web application in PHP. The application needs to provide the user interface in several languages, and will have rather complicated application logic including database access. Of course I will separate the logic from the presentation, but what is the best way to implement multi-language support?
I've briefly tried using gettext together with plain PHP files in the presentation layer, which works but makes it hard to use HTML editors for editing the user interface. Another option would be to simply make a copy of all presentation layer files for each language. I'm sure there are better alternatives.
If you have any experience with multi-language PHP applications, I would really like to hear about it. Which techniques did you use, and how did they perform in practise? Thanks in advance.
Use a templating enging like smarty, or use a db (Score:2)
Re:Use a templating enging like smarty, or use a d (Score:1)
Regarding UTF, the current project will only support English and a few other Western languages, and I can probably get away with just using ISO Latin 1 for all of them. But I will certainly keep your warning
Re:Use a templating enging like smarty, or use a d (Score:2)
Well you're always going to need to change the text. If you are smart with templating though, you can layer your templates. For instance, using HTML::Template style templates, I can template the following HTML:
The template above uses templates within templates. So, you can keep three templates: 1 for the layout, and 2 se
Re:Use a templating enging like smarty, or use a d (Score:2)
Here [php.net] is a link I just found illustrating the problem. You get spotty service, depending on what kind of encoding you are using. And, to make matters worse, multibyte string support needs to be compiled into PHP.
Re:Use a templating enging like smarty, or use a d (Score:1)
The UTF problems don't sound good at all. However, the project I'm working on now is not that complicated and so far I haven't seen any problems with Latin-1 characters. Let's hope it stays that way :)
Thanks for sharing your knowledge!
Arrays.... (Score:1)
Hi,
There are imho three ways of doing this. You can a) use gettext, b) a database or c) an array containing the strings (eventually using some wrapper class/functions)
Gettext:
Really nice but not installed on every host, so if you want to share the app it won't run everywhere. Maintainig is a bit harder, since youneeed some special tools, but, since there are many programsusing gettext there are many tools helping with the translation.
Database:
Simple changing texts with a browserinterface (or a datab
Re:Arrays.... (Score:1)
The project I'm working on is not that big and limited to a few Western languages. Most of the things that need translation are part of the static user interface, users won't be able to edit it.
I have done some simple tests using gettext, but not used it for any serious work. Do you know how fast it is?
For a start I will separate the user interface from the application logic and probably use a template engine like Smarty as recommended by KingOfBLASH in his replies above. That woul