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

Multi-Language Version #1327

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Vlor999
Copy link

@Vlor999 Vlor999 commented Jan 2, 2025

Description

Sorry for the last pull request, it was a mistake. The idea is the people may want to use commitizen to make commits but some people may not speak English. This is where the idea came to introduce a language option. The idea is just to give the opportunity to users to have better understanding of the selection of possibility.

Checklist

  • Add test cases to all the changes you introduce
  • Run ./scripts/format and ./scripts/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

This new feature must increase the understanding and improve commits for users.

Steps to Test This Pull Request

  1. poetry shell
  2. python3 commitizen/main.py -language fr commit
  3. python3 commitizen/main.py commit
  4. python3 commitizen/main.py -language en commit
  5. exit

Additional context

Vlor999 and others added 2 commits December 30, 2024 12:49
…isplay informations

this is just a first version that is not yet efficient and must be implemented to be more efficient
@woile
Copy link
Member

woile commented Jan 2, 2025

Looks like a nice feature. Where's the french translation? How would people provide custom translations for their own rules, like cz-emoji?

Thoughts @Lee-W @noirbizarre ?

@Vlor999
Copy link
Author

Vlor999 commented Jan 2, 2025

Looks like a nice feature. Where's the french translation? How would people provide custom translations for their own rules, like cz-emoji?

Thoughts @Lee-W @noirbizarre ?

You can choose your translation on the command line. If it merge by typing : cz -language fr commit. With this sentence you will have the explanation in French, if you want other language, you can change the fr and if you want to stay with the English version you do not need to write -language. For the cz-emoji version, it could be a bit hard because my way of doing is to use a translator API. So if you want to make the cz-emoji, you have to add the datas/sentences into de cache-memories. Sorry if there is some mistakes in my code, I can already see that there is some issue about the python-check, this is my first contribution to an open source projects. I'm here to help you make this feature available if you wish so.

@noirbizarre
Copy link
Member

noirbizarre commented Jan 3, 2025

That's very interesting! I worked in French administrations and some teams/projects have french as a unique and mandatory language, so I can definitively see the use cases!

I worked a lot with translations and making them opt-in, including for extension, is straightforward with https://docs.python.org/fr/3/library/gettext.html

The idea would be:

  • keep all name keys in english
  • call gettext on display on the key:
    • either there is a translation provided, then it is displayed instead of the english one
    • either there is none, and the english one is displayed
  • extensions/plugins can provide their translation using a shared convention (often translations/{iso}/messages.po)

gettext has many advantages over json as it handles complex logic that are unavoidable when it comes with translating, like pluralization (in Python, given in some other languages there are libs offering these kind of features on JSON).

It is also a good idea to bind the default on LANG env var instead of en as it will fallback on en if the language does not exist.

To help with translations, translation services like transifex offer a free tier for open-source projects, but https://weblate.org is open source itself and free for open-source project.

For emojis, this is a special case which will require some design choices, but given it is already using the emoji library which is already supporting localization, it won't be that difficult to handle.

Anyway, I think this feature would be great, and I am ready to help on this one if required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants