Im not very familiar with RoR so this question might be kind of silly. I want to store strings from different lenguages in a database. I want to have the key for the string in english be the ''key'' for all the corresponding traslations of that string. For example: (database columns) lenguage-------------key-----------------value----- english hello "hello worl" spanish hello "hola mundo" french hello "Bon jour xxxxx" the point here is that all strings from diff. lenguages share the same key. I was thinking of creating three different tables and link them (if possible) and then somehow override the key of the other lenguges with the english string key...is this possible? Or is it better to store all strings from diff. lenguges in the same table and override the keys from the other lenguages with the one in english? I hope someone can help me out! thanks much -- Posted via http://www.ruby-forum.com/.
i think the relationship is key has many values/translations language belongs to key language has one values/translations I don''t know how the underlying table structure will look like but you can have similar table structure Language table PK language_id i.e. ''English'' Key table PK key_id i.e. ''Hello'' Translation table PK value_id i.e. "hola mundo", this table will have foreign keys from Language and Key table I hope this helps get you started I may be missing a thing or 2 about key and language relationship -daya On 8/2/06, Rob Jones <ricardo.orozco@hp.com> wrote:> > Im not very familiar with RoR so this question might be kind of silly. > I want to store strings from different lenguages in a database. I want > to have the key for the string in english be the ''key'' for all the > corresponding traslations of that string. For example: > (database columns) > lenguage-------------key-----------------value----- > english hello "hello worl" > spanish hello "hola mundo" > french hello "Bon jour xxxxx" > > the point here is that all strings from diff. lenguages share the same > key. I was thinking of creating three different tables and link them > (if possible) and then somehow override the key of the other lenguges > with the english string key...is this possible? Or is it better to > store all strings from diff. lenguges in the same table and override the > keys from the other lenguages with the one in english? > > I hope someone can help me out! > > thanks much > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060802/4033c635/attachment.html
Jean-Etienne Durand
2006-Aug-03 09:09 UTC
[Rails] Re: is it possible to duplicate a key? --new
Hi Rob, Just have a look at globalize plugin, it is very similar to your question (and perhaps you can even use it): You can see that unicity is on the pair [`tr_key`,`language_id`]: CREATE TABLE `globalize_translations` ( `id` int(11) NOT NULL auto_increment, `type` varchar(255) default NULL, `tr_key` varchar(255) default NULL, `table_name` varchar(255) default NULL, `item_id` int(11) default NULL, `facet` varchar(255) default NULL, `language_id` int(11) default NULL, `pluralization_index` int(11) default ''1'', `text` text, PRIMARY KEY (`id`), KEY `globalize_translations_tr_key_index` (`tr_key`,`language_id`), KEY `globalize_translations_table_name_index` (`table_name`,`item_id`,`language_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; GlobalizePlugin: http://www.globalize-rails.org/wiki/ Jean-Etienne -- Posted via http://www.ruby-forum.com/.
Hi Jean-Etienne thanks for your help. I read about globalize plugin (the link you sent me) and I got the feeling that this service would be more translating actual strings...is that right? thanks -- Posted via http://www.ruby-forum.com/.
Jean-Etienne Durand
2006-Aug-03 21:09 UTC
[Rails] Re: is it possible to duplicate a key? --new
Rob, I gave you this link just because you want to achieve something similar, not for the purpose itself :) This plugin allows you to do internalization in a very simple manner. For example, just write "foo".t in your views. According to the current language, it will convert this value (key) to the language specific form. Just have a look, it does a lot more than this (date, currency ...) Jean-Etienne -- Posted via http://www.ruby-forum.com/.