Re: Languages Apache ???

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 02 Feb 2006 21:11, CodeHeads wrote:
> Not sure if this fits this list for not.  But here it goes.
>
> I have a portal written in PHP and I need to have it in another language
> (Chinese or Japanese).  How would I do that in apache?? Bare in mind I
> need also to be in English.
>
> Sorry if this is the wrong list.

It is the wrong list, but I can try :-)

Basically, it means a re-write of the PHP application, to allow on-the-fly 
translations of the content of the site.  You supply a different file for 
each string that appears on the site (you have to normally translate entire 
phrases, not just words) and the visitor's browser, when it connects, 
supplies the context (i.e. most browsers will tell the server what language 
they are configured to display).

The application then chooses which language file to read the strings from when 
it composes each page that is served.

Apache itself does have a file-based translation capability .. but it has no 
idea about your application, so you need to provide the translations, and its 
often easier to do it inside the application, as Apache's solution is to 
server files from different directories dependant on the browser context. 
(Simplified explanation)

This makes sites with rapidly changing content VERY maintenance-heavy.

An example:

When reading in each PHP file, the script detects the browser setting (or the 
users preferences if its a site where those preferences are stored) and 
includes a file which contains an array specific to that language, indexed by 
the name of the string you need to modify ..

#file en.inc language english
$lang["Hello"]= "hello";
_________________________
#file fr.inc language French
#lang["Hello"] = "bonjour";  //yeah ok, my French is lousy
_________________________
#script file
//protocode only
if ($browser_lang=="Eng")
	include("lang/en.inc");
elseif ($browser_lang=="Fr")
	include("$lang/fr.inc");
endif

echo $lang["Hello"];
_________________________
TD


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux