swarm-game / swarm

Resource gathering + programming game
Other
842 stars 52 forks source link

Add localisation #244

Closed Nuxssss closed 5 months ago

Nuxssss commented 3 years ago

It would be really great if the game was translated into other languages

byorgey commented 3 years ago

Agreed!

xsebek commented 3 years ago

Thanks @Zuzuk-null, your #251 is a good start :+1:

Next we could localize the exceptions shown to user - I guess these come mainly from parsing and from failures in step function. I am thinking we could move the English exception text to some data structure and add a command to output it as YAML template. Then we could add --language XY flag that would try to load data/locale-XY.yaml.

It would be a bit of work but could improve namely the LSP experience for non-native speakers. :slightly_smiling_face:

There are also the entities descriptions, which I am unsure how to localize, maybe just make the description a map:

- description:
  - en: "A small rock."
  - cz: "Malý kamínek."
byorgey commented 3 years ago

Yes, I was thinking about making the description a map as well. It would result in a much larger entities.yaml file, but the benefit is that all the translations would live next to each other, and it would be very obvious to everyone how to contribute.

byorgey commented 3 years ago

I am thinking we could move the English exception text to some data structure

Yes, instead of directly returning text in exceptions, we could make an enumeration type to represent the different possible kinds of errors, then separately a function for rendering them as text using the current locale (e.g. by loading templates from data/locale-XY.yaml). Maybe that is already what you were saying.

byorgey commented 2 years ago

While I still think this would be great in theory, https://github.com/swarm-game/swarm/pull/251 nicely illustrates a big practical issue with doing this while the game is still changing a bunch: we would likely get some enthusiastic contributions which would then never be updated, leading to a bunch of out-of-date translations. I think we need to wait at least until we start making real releases. Then one of the tasks when doing a release is to make sure the translations are up to date (or drop any that are not).

EDIT: dropping out-of-date translations seems like a great way to lose momentum. Perhaps there would need to be some (semi-automated) mechanism for marking translations which are out of date. Honestly this all sounds like it would be a giant mess.

byorgey commented 2 years ago

Note, we now also have things like goal which contains a list of strings rather than just a string. However, I think the same principle would still apply, i.e. goal becomes a map from language keys to lists of strings.

goal:
  en:
    - Do something.
    - This is another paragraph.
  de:
    - Tun Sie etwas.
    - Dies ist ein weiterer Absatz.
byorgey commented 5 months ago

I'm going to close this as "won't fix". I just can't see a reasonable way for a small open-source project to manage this. Perhaps in some glorious future where Swarm has a large and active community of users we could reconsider this.