Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple language (best way)

Status
Not open for further replies.

aspvbnetnerd

Programmer
May 16, 2006
278
SE
I am going to have multiple languages in my webshop.

What is the best and optimezed way to do.

1. Put all languages in a database and the use GetRows

2. Put all langueges in a ASP file and then use Include

If you have a better way to do so. Please let me know

George
 
I think it depends on how your site works. One method I used in the past was to have an administrative tool to allow admin's to edit content. Rather than store the modified content of a page in a database or text file, i actually would run an ASP script to output an HTML file based on the selections they made and store it in a content directory. The advantage of this is that only the admin saw the time and resourcs it took to dynamically build the page, and the end user got a very fast loading page that wasn't doing much more than including the finished HTML pages.
Granted there were portions of that site that were database driven, but everything that was static text was editable and stored in an included HTML file generated from the admin page.

I can't tell you the best way to do it, either of the methods you listed would work. However I would say that you want to rely as heavily as you can on using CSS and limited HTML to mark up these pages to make them easier to modify without breaking your localization.

My preference would be to create include files for each block of static content on the site, then create a folder called "content" and a subfolder for each language with the translated language files. Create a consistent naming scheme for these files so it will be easy to tell whats in them if you are looking for one and also easy to tell from your eventual source code what file your looking at.
Uou won't be able to use a direct include for this unless you use a case statement, which I would not suggest doing. My suggestion would be to store the language choice in either a cookie or a session variable, then create a general function in a general include that looks something like:
Code:
Function LoadLocalizedContent(baseFilename)
   Dim fso, fil
   Set fso = Server.CreateObject("Scripting.FileSystemObject")
   Set fil = fso.opentextFile("content/" & Session("language") & "/" & baseFilename,1)
   LoadLocalizedContent = fil.ReadAll()
   Set fil = Nothing
   Set fso = Nothing
End Function
Then in each place you need the localized content (after you have set your cookie or session var) you would simply call that function and pass the base filename for the file and receive back the content. You might want to consider adding an if statement to that function so that if a language is not selected yet, it uses a default language instead.

The most important part, no matter how you do it, is that you make sure you define your character set using Response.CharSet before you start outputting anything. I believe I usually use UTF-8 to support the special characters I need, but I cannot remember off the top of my head at the moment.

 
Thanks for the answer. I do have some question.
With your solution is that I use a file.
I would read the whole file and add it to LoadLocalizedContent.

How does a the file that you use look like and how should I set the text for the site from the LoadLocalizedContent.

Tarwn, if you do have some sample code to your solution that I can use?

George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top