Jump to content

Language translation in HTML


Pawan_Agarwal

Recommended Posts

I want to include Indian language in html page [Tamil, telegu, kannada,bengali, gujrati, hindi, punjabi language]

 

If I select one language, the complete must be translated automatically in that particular selected language.

 

<select name=’_lang_’>                                                                  

<option>Tamil</option>

<option>Telegu</option>

<option>Kannada</option>

<option>Bengali</option>

<option>Gujrati</option>

<option>Hindi</option>

<option>Punjabi</option>

</select>

 

Can you provide a certain feature to my webpage by which I can make translation easily? If you having doubt in understanding my requirement, please feel free to ask anytime

Link to comment
Share on other sites

There are many ways to implement this. I assume you will already have the translated text for everything on your site. This can be stored in "language" files or int he database.

 

To start, I would use both a cookie and a session value to determine the user's language. When the user accesses any page on your site, Check if there is a session value for their preferred language. If so, use it and go to the next process of getting the correct content. If not, see if they have a cookie of their preferred language from a previous visit. If yes, set the session value and move to the next step. If not, provide the user a selection for the language to display or use a default. If they do make a selection, save it as both the Cookie and session value.

 

Once you know what language to display for a user you just need a 'framework' for providing the right content. You can have completely separate content files or you can store different placeholders in flat files or the database. I would go with the latter. So, on every page, break down the content to placeholders. All pages may have some common placeholders such as title, menu items, etc. While other content is specific to the specific page. For example, an "About Us" page may have a placeholder for an extended description about your site/company, then you may have placeholders for information about key people, contact information.

 

Store the content for those placeholders in separate 'language' files based upon the language of the content. So, one file for tamil and another for telegu. When the page loads, select the language file based upon the users selected (or default language). Then when you build the page, use the content from the language file to use in the placeholders.

 

Example page file:

 

<div id='welcome'><?php echo $welcome_message; ?></div>
 
<div id='description'><?php echo $company_description; ?></div>
 
<div id='president_label'>$pres_label; ?></div>
<div id='president_name'>John Smith</div>
 
<div id='vp_label'>$vp_label; ?></div>
<div id='vp_name'>Jane Davis</div>

 

The English language file for that page might look something like this

 

$welcome_message = "Welcome to ABC Company's website";
$company_description = "This is a description of our company . . . ";
 
$pres_label = "President";
$vp_label = "Vice President";
Link to comment
Share on other sites

You said that I must save all translated pages as database and then when the user select any particular language, it must change and display the page in that particular language. Do you have any other method for changing the page and language. 

 

You did not read my response correctly. You don't have to use a database. The example I laid out was to use flat files for the language content - not a database.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.