Hi, I''m starting to use GetText and have this code: render_text %(<script language="JavaScript" type="text/javascript"> parent.mainframe.onUpdateNew("Gallery <b>#{@media.name}</b> was successfully created.", "#{@media.name}","#{String(@media.id)}","#{@media.media_type}"); </script>) I need to convert it to use GetText, but what I need to do with the @media.name and how concaten with %() ?? The function from gettext is it: render_text "String" #widout gettext render_text _("String") #with gettext Thank you -- Pedro C. Valentini pedro-p14LI7ZcAE/pVLaUnt/cCQC/G2K4zDHf@public.gmane.org +55 (21) 8708-8035
You mean like this? render_text %{<script language="JavaScript" type="text/javascript"> parent.mainframe.onUpdateNew("#{_(''Gallery'')} <b>#{@media.name}</b> #{_(''was successfully created.'')}", "#{@media.name}","#{String(@media.id)}","#{@media.media_type}"); </script>} Also note that I enclosed the whole thing within ''%{'' and ''}''. Cheers, Erik. Pedro Valentini wrote:> Hi, > > I''m starting to use GetText and have this code: > render_text %(<script language="JavaScript" type="text/javascript"> > parent.mainframe.onUpdateNew("Gallery <b>#{@media.name}</b> was > successfully created.", > "#{@media.name}","#{String(@media.id)}","#{@media.media_type}"); > </script>) > > I need to convert it to use GetText, but what I need to do with the > @media.name and how concaten with %() ?? > The function from gettext is it: > render_text "String" #widout gettext > render_text _("String") #with gettext > > Thank you >
Is it not enough to translate constant strings seen by user? I.e. just translate the strings "Gallery" and "was successfully created" ... merely guessing as I''m not sure what @media.name means. message = sprintf(_("Gallery <b>%s</b> was successfully created."), @media.name) Here I''ve composed the string using format characters, as it is better known ans understood by translators. Other alternative is to concatenate translations of strings like "Gallery" and "was successfully .." but this will give poor context for a translator, while also hard coding word order that differs from language to language. For example a Hungarian translation would be: "Sikeresen létrehoztam a %s galáriát.". Words where placed in different order (believe me ;-)). Also there might be other small connecting words that must be inserted, like "a" "the" "in" and so on. These will become evident only if translator knows the whole context, instead of concatenated pieces. If you want to translate @media.name too, you should take care that all possible values have all their possible translations available. Cheers, Zsombor On 5/18/05, Pedro Valentini <pedro-p14LI7ZcAE/pVLaUnt/cCQC/G2K4zDHf@public.gmane.org> wrote:> Hi, > > I''m starting to use GetText and have this code: > render_text %(<script language="JavaScript" type="text/javascript"> > parent.mainframe.onUpdateNew("Gallery <b>#{@media.name}</b> was > successfully created.", > "#{@media.name}","#{String(@media.id)}","#{@media.media_type}"); > </script>) > > I need to convert it to use GetText, but what I need to do with the > @media.name and how concaten with %() ?? > The function from gettext is it: > render_text "String" #widout gettext > render_text _("String") #with gettext > > Thank you > > -- > > Pedro C. Valentini > pedro-p14LI7ZcAE/pVLaUnt/cCQC/G2K4zDHf@public.gmane.org > +55 (21) 8708-8035 > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- http://deezsombor.blogspot.com
This is basically a variation on concatenated strings theme. Problem is that translator must be aware of context, as you did not use whole sentences. For example single word without context is translated as: Gallery (English) Galerie (French) Galería (Spanish) While whole sentence (just using google translator for this, so it may sound odd): "Gallery %s was successfully created." (English) "La galerie %s a été avec succès créée." (French) "La galería %s fue creada con éxito." (Spanish) note that both translations begin with ''La'', word not present in out of context translation of ''gallery''. Also word/sentence order is hard coded, for languages where this would be different you would get strange results. This happens more often than you might think see the Spanish translation: last word isn''t ''creada''. I cannot stress this enough translated units should be either complete sentences or simple words that have meaning in their own. For example UI elements ''Save'', ''Cancel'', ''Undo'' etc. Cheers, Zsombor On 5/18/05, Erik Terpstra <erik-kVJDZvz1jv8qcZcGjlUOXw@public.gmane.org> wrote:> You mean like this? > > render_text %{<script language="JavaScript" type="text/javascript"> > parent.mainframe.onUpdateNew("#{_(''Gallery'')} <b>#{@media.name}</b> #{_(''was successfully created.'')}", "#{@media.name}","#{String(@media.id)}","#{@media.media_type}"); > </script>} > > Also note that I enclosed the whole thing within ''%{'' and ''}''. > > Cheers, > > Erik. > > Pedro Valentini wrote: > > Hi, > > > > I''m starting to use GetText and have this code: > > render_text %(<script language="JavaScript" type="text/javascript"> > > parent.mainframe.onUpdateNew("Gallery <b>#{@media.name}</b> was > > successfully created.", > > "#{@media.name}","#{String(@media.id)}","#{@media.media_type}"); > > </script>) > > > > I need to convert it to use GetText, but what I need to do with the > > @media.name and how concaten with %() ?? > > The function from gettext is it: > > render_text "String" #widout gettext > > render_text _("String") #with gettext > > > > Thank you > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- http://deezsombor.blogspot.com
Dee Zsombor wrote:> I cannot stress this enough translated units should be either complete > sentences or simple words that have meaning in their own. For exampleThanks a lot for the tip, I am fairly new to the whole localization thing. Erik.
Strange, rgettext don''t get this strings... I decided remove @media.name from the message, and not work with rgettext: render_text %{<script language="JavaScript" type="text/javascript"> parent.mainframe.onUpdateNew("#{_(''Gallery was successfully created.'')}", "#{@media.name}", "#{String(@media.id)}", "#{@media.media_type}"); </script>} Other, in http://manuals.rubyonrails.com/read/chapter/82 they suggest the use of one file for the translation of all application, all in messages.po ??? How I use one bindtextdomain(''messages''); in many files??? When I try to get content of the second file they don''t add to the first messages.pot. Thank you Pedro Valentini Erik Terpstra escreveu:>You mean like this? > >render_text %{<script language="JavaScript" type="text/javascript"> >parent.mainframe.onUpdateNew("#{_(''Gallery was successfully created.'')}", "#{@media.name}","#{String(@media.id)}","#{@media.media_type}"); ></script>} > >Also note that I enclosed the whole thing within ''%{'' and ''}''. > >Cheers, > >Erik. > >Pedro Valentini wrote: > > >>Hi, >> >>I''m starting to use GetText and have this code: >>render_text %(<script language="JavaScript" type="text/javascript"> >>parent.mainframe.onUpdateNew("Gallery <b>#{@media.name}</b> was >>successfully created.", >>"#{@media.name}","#{String(@media.id)}","#{@media.media_type}"); >></script>) >> >>I need to convert it to use GetText, but what I need to do with the >>@media.name and how concaten with %() ?? >>The function from gettext is it: >>render_text "String" #widout gettext >>render_text _("String") #with gettext >> >>Thank you >> >> >> > >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Pedro C. Valentini pedro-p14LI7ZcAE/pVLaUnt/cCQC/G2K4zDHf@public.gmane.org +55 (21) 8708-8035 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails