avian2 / unidecode

ASCII transliterations of Unicode text - GitHub mirror
https://pypi.python.org/pypi/Unidecode
GNU General Public License v2.0
517 stars 62 forks source link

Support localization #27

Closed PanderMusubi closed 6 years ago

PanderMusubi commented 6 years ago

Please, support localization for Unicode block and character description translations from https://github.com/unicode-table/unicode-table-data/tree/master/loc If possible, use a gettetxt approach similar to https://pypi.org/project/pycountry/ Implementing this feature will allow users to read Unicode descriptions in their own language, other than English.

avian2 commented 6 years ago

I don't understand. Unidecode does not "allow users to read Unicode descriptions" and does not contain "Unicode block and character descriptions".

PanderMusubi commented 6 years ago

Use localization from the files of unicode-table to translate descriptions of Unicode characters. For example, now is possible only in English:

from unicodedata import name
print(name('ß'))
LATIN SMALL LETTER SHARP S

So unidecode could provide a way to translate LATIN SMALL LETTER SHARP S to e.g. German with (proposed code):

from unicodedata import name
from gettext import translation
from unidecode import LOCALED_DIR
german = translation('Unicode' LOCALED_DIR, languages=['de'])
german.install()
print(_(name('ß')))
LATEINISCHER KLEINBUCHSTABE SCHARFES S
avian2 commented 6 years ago

I think you are confusing unicodedata and unidecode. This is outside of the scope of this library, which does transliteration.

PanderMusubi commented 6 years ago

Indeed, my bad. Sorry and gonna move the issue to there. Thanks.