Language Converter

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
User avatar
sakthi
Forum Newbie
Posts: 12
Joined: Wed Apr 12, 2006 1:13 am
Location: Mumbai-India
Contact:

Language Converter

Post by sakthi »

Hi everybody,

This is my first post.I need a help from you.
i have to display some contents from database in different languages.
This is depends on the EndUser.

He/She shall like to view in Chinese or Japanese or arebian. Whatever
it is, i have to provide the facility to convert to the desired language
from english.

how can i achive in PHP.


anybody can help!, please.


thankyou...
jito
Forum Commoner
Posts: 85
Joined: Sat Mar 25, 2006 4:32 am
Location: india

Post by jito »

may be it's my fault that i can't understand it properly, but will u explain a bit. what u really want to do? u hava web page displaying data from a database in english and u want to translate that page in any other language at runtime? is it?
User avatar
sakthi
Forum Newbie
Posts: 12
Joined: Wed Apr 12, 2006 1:13 am
Location: Mumbai-India
Contact:

Language Converter - reply

Post by sakthi »

hello jito,

your understand is correct.

that is my requirement.i have to produce in different language
at runtime.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

PHP will not convert languages by using a set of functions. You would have to define your data in the different languages you will be allowing, and then call the correct data from the database.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

One option is to have the text to be used defined (as constants) based on the language desired. After that, define constants or a hash table that represents bits of the text you wish to use. For example:

Code: Select all

switch($language)
    {
    'English':
        {
        define('PAGE_TITLE', 'Hello!');
        define('SHOW_LOVE', 'I Love You');
        }

    'Spanish':
        {
        define('PAGE_TITLE', 'Hola!');
        define('SHOW_LOVE', 'Te Amo');
        }

    'Dutch':
        {
        define('PAGE_TITLE', 'Halo!');
        define('SHOW_LOVE', 'Ik houd van u');
        }
    }
The above is just an example. But as far as examples go, it's not entirely a good one. The reason being that we are talking about language. Your site will need a lot of definitions for the various bits of text that will be used on the site. A better option would be ...

Code: Select all

switch($language)
    {
    'English':
        { require_once('english_definitions.php'); }

    'Spanish':
        { require_once('spanish_definitions.php'); }

    'Dutch':
        { require_once('dutch_definitions.php'); }
    }
Lastly, you may not want to use constants. Setting up hundreds of these may be a bit slower then creating a big hash table (associative array).

Hope that helps. :wink:

Cheers,
BDKR
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

BDKR wrote:

Code: Select all

'Dutch':
        {
        define('PAGE_TITLE', 'Halo!');
        define('SHOW_LOVE', 'Ik houd van u');
        }
    }
Should be 'Hallo' and 'Ik hou van jou' :)
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

timvw wrote:
BDKR wrote:

Code: Select all

'Dutch':
        {
        define('PAGE_TITLE', 'Halo!');
        define('SHOW_LOVE', 'Ik houd van u');
        }
    }
Should be 'Hallo' and 'Ik hou van jou' :)
Thanx! My Dutch is really rusty as you can see. :oops:
Post Reply