Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message Translations #123

Open
joao-conde opened this issue Feb 1, 2022 · 10 comments
Open

Message Translations #123

joao-conde opened this issue Feb 1, 2022 · 10 comments
Assignees
Labels
✨ feature New feature or request 🎃 hacktoberfest Suitable for Hacktoberfest

Comments

@joao-conde
Copy link
Collaborator

Rationale

Add translations to change the default parrot language from English to something else.

Description

  • Each message sent to the guild server must be translated.
  • It should default to English.
  • New translations can be easily added by open source contributors
@joao-conde joao-conde added the ✨ feature New feature or request label Feb 1, 2022
@joao-conde
Copy link
Collaborator Author

@aquelemiguel @afonsojramos I think we discussed this at a certain point. I have an idea of how to do it. Leave it to me if you agree with the issue.

@joao-conde joao-conde added the 👓 triage This issue is being reviewed label Feb 1, 2022
@afonsojramos
Copy link
Collaborator

afonsojramos commented Feb 1, 2022

Yeah, the big move to mostly using the strings.rs file was mostly to help with this. Go ahead!

@afonsojramos afonsojramos removed the 👓 triage This issue is being reviewed label Feb 1, 2022
@aquelemiguel
Copy link
Owner

Sure, removing other contributors from this.

@joao-conde
Copy link
Collaborator Author

Yeah, the big move to mostly using the strings.rs file was mostly to help with this. Go ahead!

Yes, but at the same time, the translations will no longer be stored in code and therefore not part of the release binary. This would make no sense for tons of translations.

Currently thinking of storing the translations in JSON files making it easier to change or add new ones without changing the codebase.

@afonsojramos
Copy link
Collaborator

I actually had already investigated a bit on how to do this properly with community integrations and stuff and I've found that platforms such as https://crowdin.com/ or https://weblate.org/en-gb/ offer a really good interface for managing the translations. Maybe it is a bit overkill, what do you think?

@joao-conde
Copy link
Collaborator Author

Seems a bit overkill to me but nonetheless when I have time I will look into them.

@joao-conde
Copy link
Collaborator Author

Alright, my proposed solution is one that:
1 - does not increase source and binary sizes with each new translation/locale
2 - can be easily contributed by open source devs
3 - custom translations can be easily be made locally

With that in mind, I propose the following:

  • a messaging.rs module which implements a key message(message_type, locale = "en") function
  • in that module, we keep the base strings we use right now as discord messages (they will be the default, English)
  • the idea is message_type will be an enum with the types of messages we send (the queue is empty, the user is not in the channel, etc.)
  • locale is the typical language ISO code; if none is given, use the default constants we have in strings.rs right now
  • the translations should be stored in JSON files that are read on startup into a hashmap and used for translating from message_type + locale -> string/message

Obviously, this means the binary of parrot alone when run will always default to English. The language translations are only available if the deployed parrot instance has local JSON translation files. Alternatively, we can serve the JSON files somewhere and make HTTP requests to fetch them, but I find this overkill.

What do you think @afonsojramos @aquelemiguel

@joao-conde joao-conde added the 💬 discussion Further information is requested label Feb 17, 2022
@aquelemiguel
Copy link
Owner

Sorry for taking a while to get on this, but I overall really like your implementation! 🙂

the translations should be stored in JSON files that are read on startup into a hashmap and used for translating from message_type + locale -> string/message

A follow-up question: what if for some reason a translation isn't available? For instance, a contributor that has to add a new constant cannot possibly know every translation. Do we default to English?

The language translations are only available if the deployed parrot instance has local JSON translation files. Alternatively, we can serve the JSON files somewhere and make HTTP requests to fetch them, but I find this overkill.

Keep it local, easier and encourages easy open-source contributions. 😎

@joao-conde
Copy link
Collaborator Author

The default would be English, yes. It would be basically lookup for JSON file translation (actually this will be loaded into memory at startup) and if it does not exist, use the default string.rs current English messages.

@aquelemiguel
Copy link
Owner

Sounds good, proceed with the implementation. 🙂

@aquelemiguel aquelemiguel removed their assignment Feb 21, 2022
@joao-conde joao-conde removed the 💬 discussion Further information is requested label Apr 16, 2022
@joao-conde joao-conde added the 🎃 hacktoberfest Suitable for Hacktoberfest label Oct 4, 2022
@joao-conde joao-conde removed the 🎃 hacktoberfest Suitable for Hacktoberfest label Feb 27, 2023
@joao-conde joao-conde added the 🎃 hacktoberfest Suitable for Hacktoberfest label Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature New feature or request 🎃 hacktoberfest Suitable for Hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants