Skip to content

Latest commit

 

History

History
46 lines (30 loc) · 4 KB

i18n.md

File metadata and controls

46 lines (30 loc) · 4 KB

Internationalisation

The bot is written in a way that allows for support of multiple languages.

The currently supported languages are:

  • 🇬🇧 English
  • 🇻🇳 Vietnamese

How to add a translation

Do you want to add support for a language you speak? Here's how you do it.

Firstly, use the English translation file as reference.

You will find a bunch of messages, each associated with a key. For example, a key would be a :waiting/not-enough-players and the associated message (right next to it) Not enough players.. Messages are enclosed in double quotes "...".
The other thing you will find are messages with placeholders. Placeholders are later replaced with things like player names, amount of chips and similar. For example: "It''s your turn, {0}!..." is a message associated with :playing/turn and it has a placeholder for the player whose turn it is ({0}). So, when this message is used, it will be turned into this: It's your turn, @Player!. Also note the duplicated ', which is required if you want to include a literal ' in the message.

You need to translate all the messages, but not the keys.

Choice patterns

So far, this should be very straight forward. There is probably one thing that might still seem confusing, and I want to explain this more in detail here. It is about choice patterns.
The problem with plain placeholders is that they can result in incorrect grammar. Take this example:

{1} more players can join.

{1} is the placeholder for the number of players that can still join, and at first glance this seems ok: 3 more players can join makes sense, so does 2 more players can join. However, 1 more players can join is grammatically incorrect in the English language. And 0 more players can join also doesn't look great, although it is technically correct.
The solution is to provide a different message depending on the value range of the number. For 0-1 (without including 1, so effectively just 0), we want to have no more players can join, for 1-2 (again, excluding 2), we want one more player can join and for everything for 2 and above we want what we had initially, i.e. {1} more players can join. We can realise this with a choice pattern which looks like this:

{1, choice, 0#no more players can join|1#One more player can join|1<{1} more players can join}.

This will do exactly what is described above and can be used to conform to grammatical rules in your language as well. If your language has more than just singular and plural, like Slovenian for example which has a special case for exactly two of something ("dual"), you can represent this as well:

{1, choice, 0#zero|1#one|2#two|2<more than two}

If your language is less complex than English in these regards you may want to remove such patterns where appropriate.

Translation liberties

It is not important that you stay 100% true to the original English messages. Translating is hard, and it is pretty likely that you will run into a message that is weird to translate to your language word by word. In such cases, feel free to adjust the wording so it fits your language better. Similar problems may arise with grammatical gender. Again, feel free to adjust it so it makes sense in your language. However it is obviously important that

  1. The meaning stays the same and
  2. You don't outright remove placeholders, they still need to be incorporated in your messages

I'm done, now what

First of all, thank you for helping me internationalise this bot! If you've translated message.edn to your language, you can join the Poker support server and send the file to me there.
Alternatively, if you're also a developer or know how to work with GitHub, you can fork this repository and make a pull request to add your translated file to resources.

The language won't be available immediately and I might still have some questions about your translation. But with a following update it should then become selectable from the language menu.