473,386 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

multilingual site

pradeepjain
563 512MB
Hii guys!!

I need to create a multilingual site say another 2 languages! I am using indic scripts as of now! in which i need to create say another 3 pages in 3 languages . Its tedious job! Is there any other way to do the conversions on the fly and show the page to the end users! Hope i have asked the question in correct forum as ma site is developed using php and mysql Db driven!
Sep 8 '09 #1
3 2180
Markus
6,050 Expert 4TB
@pradeepjain
I'm actually working on making a site multi-lingual now, in fact, so we have some common ground there.

Anyway, what I did was (after seeing Dorm do the same), create .ini language files that contain key => value pairs, that I could parse into an array using PHP's parse_ini_file() function. The lang files looked like this, note that the key has punctuation stripped (apart from hypens):
lang.en.ini
Expand|Select|Wrap|Line Numbers
  1. hello = "Hello"
  2. goodbye = "Goodbye"
  3. today = "Today"
  4.  
All of your .ini files would share the same set of keys, where the value changes to the language in question. So the French language would look like this:
lang.fr.ini
Expand|Select|Wrap|Line Numbers
  1. hello = "Bonjour"
  2. goodbye = "Au revoir"
  3. today = "Aujourd'hui"
  4.  
I then wrote a Language class that would produce an object with methods for retrieving values from the language array, parsing a new language array (parse_ini_file()), and others. The basic structure of that class:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. class My_Lang {
  4.  
  5.     /**
  6.      * Some doc
  7.      */
  8.     private $langs = array();
  9.     /**
  10.      * Some doc
  11.      */
  12.     private $dict = array();
  13.  
  14.     public function __construct($lang = null) {
  15.         // Load a default language
  16.         if (!$lang) {
  17.              $this->lang = 'en';
  18.         } else {
  19.              $this->lang = $lang;
  20.         }
  21.  
  22.         $this->loadLangs();
  23.         $this->loadLang($this->lang);
  24.     }
  25.  
  26.     /**
  27.      * Loads all available language selectors from
  28.      * some specified lang dir, into our
  29.      * $langs array.
  30.      *
  31.      * @return bool
  32.      */
  33.     public function loadLangs() {
  34.         // Load language selectors
  35.         $this->langs = $availLangsArray;
  36.     }
  37.  
  38.     /**
  39.      * Loads language array into our $dict array
  40.      * 
  41.      * @return bool
  42.      */
  43.     public function loadLang($lang) {
  44.         // Must be available to load
  45.         if (!in_array($lang, $this->langs)) {
  46.             throw new My_Lang_Not_Available;
  47.         }
  48.  
  49.         $this->dict = parse_ini_file('/path/to/'. $lang. '.ini');
  50.     }
  51.  
  52. }
  53.  
Sep 8 '09 #2
pradeepjain
563 512MB
So this is one of the tedious process where in language file with corresponding key => value pair must be maintained .

@Markus
Sep 8 '09 #3
Markus
6,050 Expert 4TB
@pradeepjain
It's hardly tedious in the long run, but suit yourself :D
Sep 8 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ed | last post by:
I want to create a multilingual website in ASP. Is the Dictionary object created with the application-level scope the way to go?
7
by: J?rg Keller | last post by:
Hi all I have to localize an Access 2002 application: The application using several form, tables etc. is currently only in English. Now the frontend has to be bilingual, so the user can choose...
0
by: JoanneC | last post by:
When developing dynamic web content for the global market place using ASP.NET, VB.NET and MS-Access, why should one install MS-Windows 2000 Server (mulitlanguage/multilingual), and is it necessary...
4
by: Jim Adams | last post by:
Anyone have any insights into this? I'm planning an upgrade to an existing ASP.Net project to support multiple display languages (e.g. English, Spanish, ...). I'd like to use a solution that...
3
by: charliewest | last post by:
Building Multilingual Portal I have been assigned a new project to build a multilingual portal using ASP.NET and the expected Microsoft technologies including C#, ADO.NET and SQL Server 2000. ...
64
by: Manfred Kooistra | last post by:
I am building a website with identical content in four different languages. On a first visit, the search engine determines the language of the content by the IP address of the visitor. What the...
2
by: | last post by:
Best practices and recommendations for asp.net 2 multilingual web sites? Thanks
8
by: CptDondo | last post by:
I have a small, embedded app that uses a webserver to serve up pages showing status, etc. Right now all the pages are hard-coded in English. We need to provide multi-lingual support. All of...
6
by: CAH | last post by:
I need to make at multilingual website, with php and mysql, and I have placed the different language in different columns in a database. But when the user chooses a language, should I make the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.