Rajesh
Rajesh

Reputation: 139

Best approach to implement multi language support on website

I am using bellow approach to implement Multi Language.

I have researched about how to implement multi language in website. and found there are four way to implementing multi language as follows

  1. Simple and easy way Implement google translater .

  2. Created every page in each language and put different folder and sub domain.(expensive process and difficult to configuration)

  3. Using json or xml as resources.(difficult to manage but fast working)

  4. Using db to contain each column for every language.(easy to manage but it's slow work as compare to json and resource))

Which one is best way to implements?

please suggest if should have better solution.

Thank you in advance.

Upvotes: 4

Views: 573

Answers (1)

drew sutherland
drew sutherland

Reputation: 86

Have you considered a labels approach? You can have a Struct in the application scope which holds the text for a specific unique label name, and for that particular language:

<cfset application.labels['main.search.title']['EN'] = 'Search for widgets' /> 
<cfset application.labels['main.search.title']['FR'] = 'Chercher pour widgets' /> 

You can populate the struct from a 'labels' table in the database or even a text file sitting in the applications' directory. The function to populate the struct can be called on application start or even checked whether it is necessary on every request. It depends on performance and how the user is able to change language.

But either way, it then becomes simple to just output the label in your page view with the language in session:

<cfoutput>
    #application.labels['main.search.title'][session.user_lg]#
</cfoutput>

Upvotes: 3

Related Questions