News for hackers. Stuff that matters.
Re:Easy i18n in Angular Apps by lelf on Sunday November 24, 2013 @11:38AM (#6790008)
What's obsession with those TITLE, PARAGRAPH_ABOUT_FOO, SECOND_SENTENSE_FROM_TO_RIGHT_WHERE_THEY_KILLED_THE_RABBIT stupidity?

translate("This is a paragraph.")

PS and in the real world, please don't translate language names with each language change

Re:Easy i18n in Angular Apps by unfug on Sunday November 24, 2013 @11:58AM (#6790094)
Off hand I can think of a few reasons for using the mapping object as they did in angular-translate:

- It may make sense to translate the same English sentence to something slightly different in different contexts in German.

- JSLint/JSHint should be able to check for usages on an identifier like TITLE, PARAGRAPH_ABOUT_FOO, etc. easier than comparing strings (you'd have to build something custom for that).

- Brevity. If you have the same long string of text written twice it may be useful to have a shorter identifier for it.

I agree with not translating language names though, in the real world that doesn't really make sense.

Re:Easy i18n in Angular Apps by lelf on Sunday November 24, 2013 @12:09PM (#6790152)
> It may make sense to translate the same English sentence to something slightly different in different contexts in German

Then obviously you add context. It all has been solved for xx years http://www.gnu.org/software/gettext/manual/html_node/Context...

> JSLint/JSHint should be able to check for usages on an identifier like TITLE, PARAGRAPH_ABOUT_FOO, etc. easier than comparing strings (you'd have to build something custom for that)

That's not difficult if you absolutely need it

> Brevity. If you have the same long string of text written twice it may be useful to have a shorter identifier for it

You don't need them twice. Add attribute telling: this text can be translated. That's all.

Re:Easy i18n in Angular Apps by Gigablah on Sunday November 24, 2013 @11:53AM (#6790075)
In the "real world", you'll eventually run into cases where you have to translate recurring words/phrases/sentences differently due to context or language peculiarities.
Re:Easy i18n in Angular Apps by ch0wn on Sunday November 24, 2013 @11:32AM (#6789995)
angular-translate is really a pleasure to use. I used it in two separate smallish apps and wouldn't hesitate to do it again. Very compact, easy API and great docs.