How to write code that enables translation of variables in the database?

rszrama - November 13, 2007 - 14:22
Project:Translation template extractor
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:by design
Description

Hey Gabor, I couldn't remember if I asked about a solution for this problem when we met in Barcelona or not. Basically, a lot of Ubercart page titles, form element labels, etc. are customizable. Values are being stored in the database, but multi-lingual sites may still need to translate these stored values. I know I'm not supposed to use t() on variables, but is there any other option here to allow dynamic, multi-lingual strings?

The guys requesting these features for Ubercart have simply been hacking core, which obviously is bad. Multi-lingual sites are a subset of our normal users, so I'm not inclined to just do away with the core dynamic strings since they benefit so many of our single language users. But it seems like in this situation, the normal thing to do would be to hard code all strings and let sites that want to change text use the localizer (?) to do it. This option just isn't very user-friendly and doesn't seem to make things easy for the bulk of our users.

#1

Gábor Hojtsy - November 13, 2007 - 18:24
Status:active» by design

Well, t() is to be used for literal strings. Anything that is "beyong strings written in code", or to put it differently any "user defined content" is translatable through i18n module or localizer module. They have interfaces to translate things like variables stored with the variable_set()/_get() API. That's what you can suggest to your users. They will probably need about pages, contact details, privacy policies and other content in different languages on their sites, if they need their store translated to different languages.

#2

rszrama - November 14, 2007 - 14:15

Thanks for your time, Gábor. : )

 
 

Drupal is a registered trademark of Dries Buytaert.