Replacing characters with session value

Most of the time I work on multiple language websites. In my DB tables I use names like: accommomdation_name_eng, accommomdation_name_ger, accommomdation_name_gre etc. The extentions I use in the names are exactly the same as the abbr I use in the session to switch languages (eng, ger, gre etc). I was wondering if there is a way that I can use the session value somehow In my <cfoutput> instead of using 6 or who knows how much <cfif’> to determine which language field to use. I tried for example:


<cfoutput>
#getAccommodation.accommodation_name_[session.language]#
</cfoutput>

but that was just a wild guess and is obviously not working. I’m sure there must be a way to make this work, I only don’t know which way.

You should read up on “Internationalization Practices” to optimize a site for multiple languages.

Here, you can simply use the Evaluate function.

#evaluate( "getAccommodation.accommodation_name_" & session.language )#

This would be the same as:

#getAccommodation.accommodation_name_en#
#getAccommodation.accommodation_name_de#
#getAccommodation.accommodation_name_ru#
etc.

Thanks Aaron works great :tup:

Do you know some good sources for this?