0

I have a situation for which I want best solution as I already know a way to complete that. Only problem is I am facing the similar requirement times and again.

Situation is, I have multiple select lists in a single form and every select list has couple of items, client wants translation for those items.

So if I create a table for every select list then if I have 10 select lists then I have to fire 10 queries, which I want to know is OK because I don't see it fine.

Or I can create language file where I can declare those array and include that file as per selected language.

Can anyone share their experience tackling with this particular solution, how can we solve this problem in the best possible way.

Thanks in advance.

eggyal
  • 122,705
  • 18
  • 212
  • 237
Ashish
  • 189
  • 2
  • 9
  • What (programming) language and/or frameworks are you using at the front-end? – eggyal Apr 24 '12 at 06:32
  • I am using php as server side language and mysql as backend. Take php as core php without any framework. – Ashish Apr 24 '12 at 06:35
  • my suggestion is you need to create a page that contains the translations and put it in an array. so when you select another language, you will just find and include the page that contains the match language. – SuperNoob Apr 24 '12 at 07:56

1 Answers1

0

Unless every ounce of performance is a concern to you right now, I don't think there's anything terribly wrong with having 10 separate queries (provided they reuse the same database connection).

If that leaves you uncomfortable, you could retrieve all of the select box options for a given language with a single query (either by using UNION, or normalising your data so that a single table contains all of your select box options and columns indicate to which list and language each record belongs); then PHP could split apart the results of that single query accordingly.

But, as your question specifically asked about best practice, you might like to read up on PHP's support for gettext() (as described in this question) or look into a framework that provides localisation features.

Community
  • 1
  • 1
eggyal
  • 122,705
  • 18
  • 212
  • 237