0

I am using Zend translate in my application. This works for most things, but what should I do in the case of database stored values that will be seen in the user interface. eg. A user has to select a colour from a select box. The select box is populated from the database. I would like, for instance, Spanish user to see 'rojo' instead of 'red'.

Is there a recognized way of achieving this?

My initial thoughts were that (talking relationship wise) a table called colours could have a one to many relationship with another table called colourtranslations. Each row in colourtranslations would contain a reference a row in the colour tbl, a locale and a translation. I would then have to create a method that creates a list of translated values for a given locale (with fallback to original value). Is this a feasible approach? Pros? Cons?

dimbo
  • 817
  • 1
  • 11
  • 25

1 Answers1

0

You should just use color ID's on your select:

<select name="colors">
    <option value="1">Red</option>
    <option value="2">Green</option>
    <option value="3">Blue</option>
</select>

This will allow you to only translate labels that users will see, not the information being passed to the server.

St.Woland
  • 5,357
  • 30
  • 30
  • Thanks for the answer. The problem with this approach is that the colour values seen by the user are not pulled from the db. I found the following post (too late) which pretty much answers my question: http://stackoverflow.com/questions/4057386/multilingual-site-in-zend-framework/4057564#4057564 but I will accept your answer so that this thread could help others – dimbo Mar 01 '12 at 21:59