News for hackers. Stuff that matters.
Re:Yagni Exceptions (2021) by Izkata on Monday October 17, 2022 @09:43AM (#33233362)
> I have used the Angular one and the Laravel one, and both are a chore to use, because they interrupt your flow. If I'm writing the view of my component, I don't want to have to switch to another file, think of a key that identifies that text well enough and then translate the text, thinking of potential plurals and others. I just want to write my damn text.

In django (python), the key is just the English text (with optional extra context), and if it doesn't find a translation for the target language it dumps that text back out. You don't need to go anywhere else until actually doing the translating.

Re:Yagni Exceptions (2021) by iLoveOncall on Monday October 17, 2022 @01:06PM (#33236539)
It does the same in one of the two that I mentioned (Angular I believe), but you still need to mark plurals and other stuff like that.

Here is an example about a basic case that you will encounter multiple times per page:

  <span i18n="Pretty update timestamp|Update timestamp prettyfied accompanied by user gender@@prettyUpdateTimestamp">Updated: {minutes, plural,
    =0 {just now}
    =1 {one minute ago}
    other {{{minutes}} minutes ago by {gender, select, male {male} female {female} other {other}}}}
  </span>
Re:Yagni Exceptions (2021) by SebastianKra on Monday October 17, 2022 @07:03PM (#33240659)
Does this work well?

What happens when you need to make a change in the english version? Do you just search/replace through all the translations?

Does django do anything to make this easier, or does it work with any i18n library?

Re:Yagni Exceptions (2021) by Izkata on Tuesday October 18, 2022 @12:07AM (#33242847)
There's also "translate to English", so you can instead treat it directly as a key and use that, or treat the English text as a key and change/add to the file if it's just something like a typo.

Don't recall about the second, we only had translations on one site and it's been a few years.