On 2/20/12 3:08 PM, Jacob Carlborg wrote:
On 2012-02-20 20:12, Nick Sabalausky wrote:
If so, then I don't see any usefulness of "Variant[string] info" other
than
to start treating exceptions like JS's abomination of an "object" (Or at
least AS2's objects anyway - not 100% certain how much of AS2 is taken
from
JS). If not, then could you clarify what you meant?

In either case, I am interested to hear in more detail how you see
"Variant[string] info" being used to address i18n. I haven't really dealt
with a lot of i18n myself.

Internationalization in Ruby on Rails works something like this:

# set the locale
I18n.locale = :se

This will then, at an appropriate time load, a YAML file containing the
translations, defaults too <rails_app>/config/<locale>.yml. The YAML
file can look something like this:

se:
customer:
address:
first_name: Förnamn
last_name: Efternamn




Then to use the translation, it looks like this:

I18n.translate("customer.address.first_name")

Results in "Förnamn".

It's also possible to pass variables to the translation:

se:
product:
price: %{price} kr

I18n.translate("product.price", :price => 300)

":price => 300" is a hash map-literal.

This uses very nicely Ruby's built-in, elegant dynamic type information. The closest thing in D would use a hash Variant[string].


Andrei


Reply via email to