The Right Approach to Exceptions

Jacob Carlborg doob at
Mon Feb 20 13:08:42 PST 2012

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:

             first_name: Förnamn
             last_name: Efternamn

Then to use the translation, it looks like this:


Results in "Förnamn".

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

         price: %{price} kr

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

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

/Jacob Carlborg

More information about the Digitalmars-d mailing list