Reputation: 1717
Is it possible to use gettext to translate content of a database table?
For example, I have some database tables which never change content, e.g. a table which connects country id ("fr", "de",...) with country names ("France", "Germany",...) where country names are written in the English language. I could add additional table columns to provide translation of country names in various languages, but I was wondering, whether it is somehow possible to use gettext for translation of country names.
In case it matters, I use php and mark other fixed strings in the code with _('text-for-translation')
.
Upvotes: 6
Views: 1336
Reputation: 3430
This is untested, but have you tried to add the countries in the Database with the __();
markup?
So the content of the table look like this:
__('Germany');
Since gettext translates the same strings anyway you now just open the .po file of the language you like to translate it to in an text editor and add:
#: index.php:1
msgid "Germany"
msgstr "Deutschland"
You can use any file name or line (that works for me, my Gettext is from here)
Upvotes: 0
Reputation: 12713
You should be able to just use
string gettext ( string $message )
where $message
is your countryname from the db.
Upvotes: -1