Ideal D GUI Toolkit

Jacob Carlborg doob at me.com
Thu May 23 02:04:09 PDT 2013


On 2013-05-23 10:45, Diggory wrote:
> Given a change that is purely aesthetic like that you could just change
> the english translation instead... Also "find and replace" takes a few
> seconds...
>
> If you are suggesting to use a named constant as a key, this also
> suffers from the exact problem you are pointing out that if you need to
> change the name slightly you need to do it in all places that constant
> is used in the code.

I'm not suggesting you should change the key at all.

> It also suffers from the fact that unless you use unreasonably long
> names for the constant you can't easily tell what it contains.

Rails uses "nested keys". It's strings that are translated to keys, i.e.:

translate("items.show.title")

Translation file:

en:
   items:
     show:
       title: Foobar

With a bit of magic it becomes:

translate(".title")

See my reply to Nick:

http://forum.dlang.org/thread/vtaufckbpdkpuxyztyoi@forum.dlang.org?page=14#post-knhqji:241uq9:241:40digitalmars.com

> Plus assuming these constants are internally numbered and that is the
> key used, you get the problem of translations matched to the wrong key
> and nobody realising because the key does not relate in any way to the
> meaning. With a text key the only time you reuse a key is if it has the
> same meaning.

No, see above.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list