danhper / python-i18n

Easy to use i18n library for Python
https://pypi.python.org/pypi/python-i18n
MIT License
228 stars 45 forks source link

How to exclude files from search path? #41

Open fhg-isi opened 6 months ago

fhg-isi commented 6 months ago

I use

i18n.set('filename_format', 'translations.{format}')

to load translations.yml and that works fine.

However, I would like to exclude synonyms.yml from the load path because I use that file for a different purpose.

=> How to do so?

I tried to use negative look ahead regular expression

'^(?!synonyms)translations.{format}'

but that did not work.

solaluset commented 5 months ago

Hello

I have tried settings you've mentioned and it indeed doesn't ignore synonyms.yml, which is strange. I don't know exactly what causes this, but looks like my fork has this fixed, you can try it out: https://github.com/solaluset/i18nice

EDIT: figured it out https://github.com/danhper/python-i18n/blob/4b7deea70b07b4286c96a59cc176abe14784b360/i18n/resource_loader.py#L101-L103 Looks like this causes keys without namespace to load translations from unrelated files.