Search code examples
zend-frameworkdoctrinetranslatezend-translate

Multilingual database application with Zend and Doctrine


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?


Solution

  • 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.