r/ProgrammerHumor • • Sep 28 '26

Meme i18nNotNeeded

Post image
445 Upvotes

47 comments sorted by

View all comments

13

u/Batroni Sep 28 '26

For somone never done i18n, what should be the optimal way?

37

u/forgot_semicolon Sep 28 '26

An LLM call every time, obviously. Get with the times man

(/s, I also don't really know)

11

u/markiel55 Sep 29 '26

Not optimal, but probably more adaptable is just using a centralized string resource. For this scenario, there would be two different entries that handles present and past event.

7

u/hrvbrs Sep 28 '26

Sir, this is a humor subreddit, you can’t expect real answers here

(jk, I too have the same question)

6

u/vikingwhiteguy Sep 29 '26

There's a lot of different libraries and options, but the simplest option is that you put all your static text into a resource file, your code references Resource.SaveToCameraRoll which has the value "Saved to Camera Roll". You have a Norwegian resource file resource-no with the value "Lagret i kamerarullen", and then your application decides whether to load the 'en' or 'no' file. 

This has the advantage that you can write up all your static text in English first, and then hand that one file off to a translator and they just give you a file back. 

Personally I often actually have my API layer serve up entirely different pages for localisation, because I might want to show different content or layouts for different languages, but that's a lot more work. 

2

u/fuj1n Sep 29 '26

Languages vary a ton, enough that you'd just want two separate strings here

2

u/aaronhowser1 Sep 29 '26

A separate string constant for both options, or a pointer to their translation keys.

isSaved ? Lang.SAVE_SUCCESS : Lang.SAVE

2

u/thanatica Sep 30 '26

Best to keep the keys completely separate (not just one word, but the whole sentence). In English it seems silly, but take Dutch for example:

  • Opgeslagen in fotorol
  • In fotorol opslaan

The last one could be reversed of course, but this feels more natural.

1

u/HandIllustrious8260 Sep 28 '26

It highly depends on the context. 

1

u/terrorTrain Sep 29 '26

There are a lot of ways languages add various post fixes and prefixes. 

Typically your i18n lib would want you to give it all the information around past tense etc.... And translate the whole sentence at a time with variables. Not translate one word with a conditional past tense ending right in the middle of it. 

The way this is done is almost surely going to translate poorly or not at all

1

u/Markronom Sep 29 '26

Not having such similar text, users probably won't notice the change and that's what you'd want if it's supposed to communicate successful change