Hi all,
consider the case you have more than one dynamic value for a text.
You can write:
<%= There are %d horses / 3 %>
but, what if:
<%= There are %d horses on the %s / [3, “moon”] %>
The following idea won’t work:
<%= (There are %d horses on the %s / 3) / “moon” %>
since Globalize would insert the two strings
“There are %d horses on the %s”
“There are 3 horses on the %s”
in the database and one more for each new value :).
My idea is to patch Globalize to accept an array of value.
Does anyone had the same problem?
Just wanna know what you think.
Thanx in advance.
Thomas
Thomas B. - Freiberuflicher Softwarecoach
fon: +49(40)411 622 35 mobil: +49(173)23 911 43
fax: +49(40)411 622 36
thomas.baustert(at)b-simple.de
Hi, I have also same problem.
<%="%s has %d apples and %s has more".t / “Goran” /5 /“Mihai”%>
generates 3 strings into the DB and, if you replace Goran with Sven,
another 2 strings are inserted into DB.
And also if you add a translation for %s has %d apples and %s has more
for a specific language, then load the in to that language, the string
is added again.
Did you solve the problem?
Hi Eduard,
no, sorry. So far I’m not using globalize and didn’t patched anything.
I guess, you have to redefined the method fetch() inside …/lib/
globalize/localization/db_view_translator.rb
def fetch(key, language, default = nil, arg = nil)
…
if num
return result.sub(‘%d’, num.to_s)
else
return arg.nil? ? result : result.sub(‘%s’, arg.to_s)
end
end
Maybe that’s all.
Thomas
Am 23.08.2006 um 11:23 schrieb Eduard:
–
Posted via http://www.ruby-forum.com/.
Railsi18n-discussion mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/railsi18n-discussion
Thomas B. - Freiberuflicher Softwarecoach
fon: +49(40)411 622 35 mobil: +49(173)23 911 43
fax: +49(40)411 622 36
thomas.baustert(at)b-simple.de
I solved that problem by adding a new method t_p to the String class.
So, we have “%s is tall but %s is %d inchs taller”.t_p([“Jim”, “Brian”,
2])
Just tell me if you still need it
Eduard