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

Adding the currency Name #12

Open
mame98 opened this issue Dec 27, 2020 · 4 comments · May be fixed by #14
Open

Adding the currency Name #12

mame98 opened this issue Dec 27, 2020 · 4 comments · May be fixed by #14

Comments

@mame98
Copy link

mame98 commented Dec 27, 2020

It would be really great if the library would know the full name of the currency. For example:

>>> Currency('USD').get_name()
"United States dollar"

or

>>> Currency('EUR').get_name()
"Euro"

I think english names would be a good starting point, but I think there should be a way to translate the names? I thought of JSON files for each language that contains the name for each currency. The library could then choose the correct file automatically.

@Alir3z4
Copy link
Owner

Alir3z4 commented Dec 27, 2020

Yeah, that seems be good idea.

I guess for translation, it could be 2 options, either using .po files using gettext lib which is a more proper standard, in any case JSON would work as well.

Feel free to make a pull request ;)

@mame98
Copy link
Author

mame98 commented Dec 28, 2020

I will try to make a pull request in the next few days, I will look at gettext, as it seems to be the "correct" way

@Alir3z4
Copy link
Owner

Alir3z4 commented Dec 28, 2020

While working with gettext mentioned on https://docs.python.org/3/library/i18n.html seems to be a good idea, it's gives pretty low level (basic?) integration.

I've heard good things about http://babel.pocoo.org/en/latest/index.html but have not used it myself and not sure for such small lib as python-currencies, it would be a good option or an overkill.

Many projects I've seen, the build simple wrappers around gettext functionality provided by Python directly, which would be text extraction etc.

Since python-currencies is pretty small, I don't think there would be a need for full fledges text extraction features and other fancy stuff comes out of the Babel.

Worth noting, xgettext does text extraction out of the box with no problem.

I think by making some small functions around gettext it should get the the job done without having to install other dependencies.

I myself don't have the experience with Python i18n out of Django, Flask and some others since they have all the tools and utilities included.

I did some quick searches and skimmed through several articles and so far I found https://simpleit.rocks/python/how-to-translate-a-python-project-with-gettext-the-easy-way/ to be the good start with clear explanations.

@Connor-Steward
Copy link

Hiya guys,
Newbie here - I'm looking to help out open source projects for Python practice and this Issue/feature request looks like a good starting point.

I agreed with all the above, but for starters I think a nice and simple translation to English (done via a JSON file) will suffice - at least to get basic functionality. This can then later be extended for other languages/alternative names

I'm part way through creating the JSON file (too short of a job to automate, but still tedious). I'll create a fork and wire up the .get_name() method in the main class after as well.

Example of the JSON file so far:

{
"AED" : "United Arab Emirates dirham",
"AFN" : "Afghan afghani",
"ALL" : "Albanian Lek",
"AMD" : "Armenian Dram",
"ANG" : "Netherlands Antillean guilder",
"AOA" : "Angolan kwanza",
"ARS" : "Argentine peso",
"AUD" : "Australian Dollar",
"AWG" : "Aruban florin",
"AZN" : "Azerbaijani manat",
"BAM" : "Bosnia and Herzegovina convertible mark",
"BBD" : "Barbados Dollar",
"BDT" : "Bangladeshi taka",
"BGN" : "Bulgarian lev",
"BHD" : "Bahraini dinar",
"BND" : "Brunei dollar",
"BOB" : "Bolivian Boliviano",
"BRL" : "Brazilian real",
"BSD" : "Bahamian dollar",
"BTN" : "Bhutanese ngultrum",
"BWP" : "Botswana pula",
"BYR" : "Belarusian ruble",
"BZD" : "Belize dollar",
"CAD" : "Canadian dollar",
"CHF" : "Swiss franc",
""
}

Any tips/advice are welcome :)

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

Successfully merging a pull request may close this issue.

3 participants