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

Subfolders don't work #34

Closed Pukimaa closed 7 months ago

Pukimaa commented 2 years ago

My folder structure is as following:

| i18n
   | info
      | en.yml
      | de.yml
      | hr.yml
   | config
      | en.yml
      | de.yml
      | hr.yml

And if I load the files as following: i18n.load_path.append(f"{os.getcwd()}{path_trimmer}i18n") (path trimmer is / or \\ depending on the os) or just i18n.load_path.append("i18n")

And I get translation config.key or info.key I don't get the translation but only the input. However in the README it was stated:

If your files are in subfolders, the foldernames are also used as namespaces, so for example if your translation root path is /path/to/translations and you have the file /path/to/translations/my/app/name/foo.en.yml, the translation namespace for the file will be my.app.name and the file keys will therefore be accessible from my.app.name.foo.my_key.

Pukimaa commented 2 years ago

Also tried just to append "i18n" as the folder. That also didn't work. I mean everything works if I put it in the i18n folder.

pos1er commented 2 years ago

faced with the same problem, have you found a solution?

Also tried just to append "i18n" as the folder. That also didn't work. I mean everything works if I put it in the i18n folder.

Pukimaa commented 2 years ago

I've created another version (tako-discord/python-i18n) with the help from someone else. But you need to set the format to locale.extension (or however it was...so it removes the namespace) and then it works. However I haven't tried if it now also works without a subdir. i18n/category/en.yml -> category.key

RathanakSreang commented 2 years ago

@pos1er @Pukimaa make sure you have pyyaml install on your os.

Pukimaa commented 2 years ago

@pos1er @Pukimaa make sure you have pyyaml install on your os.

Not the issue. Having the folder structure different is no problem too.