Pawan_Agarwal Posted April 15, 2014 Share Posted April 15, 2014 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 Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 15, 2014 Share Posted April 15, 2014 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"; Quote Link to comment Share on other sites More sharing options...
Pawan_Agarwal Posted April 16, 2014 Author Share Posted April 16, 2014 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. Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 16, 2014 Share Posted April 16, 2014 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. Quote Link to comment Share on other sites More sharing options...
Pawan_Agarwal Posted April 17, 2014 Author Share Posted April 17, 2014 Still, I cannot understand !! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.