Translations for strings saved on the database
Internationalized strings saved on the database may cause translation errors when retrieved. One example is the country
attribute of a Profile
. If a user creates his profile using a pt-BR
locale, the country will be in portuguese. However, if he decides to switch languages and edit his profile, the form won't be able to show the stored data correctly because Carmen
won't find his contry while being on a different locale.
Similar errors may occur with other attributes such as occupation
and state
. The case with the state
attribute is even worse because we retrieve the state list using AJAX.
Some possible solutions that come to mind:
- Define a locale for the database (that may differ from the application's default locale)
- Store translations for the fields that may cause errors
- Find a way to look up a translation key by it's value and then use that key to fetch the correct internationalized value
Do you have other solutions?
===== Update =====
We've come up with the solution to store on the database strings that can be easily translated when we retrieve those values from the database. For the state
attribute, translating that way is impossible because Carmen does not support translations for states. We will numeric codes for countries
and numbers for the occupation
and gender
.
Task list:
-
Countries -
Gender -
Occupation -
School type