Python : No translation file found for domain using custom locale folder

前端 未结 1 758
我寻月下人不归
我寻月下人不归 2021-01-12 07:22

I have the following structure :

/
|- main.py
|- brainz
|    |- __init__.py
|    |- Brainz.py
|- datas
     |- locale
          |- en_US
               |- LC         


        
相关标签:
1条回答
  • 2021-01-12 08:01

    I think your __init__.py should be something like:

    import locale
    import gettext
    import os
    
    current_locale, encoding = locale.getdefaultlocale()
    
    locale_path = 'datas/locale/'
    language = gettext.translation ('brainz', locale_path, [current_locale] )
    language.install()
    
    0 讨论(0)
提交回复
热议问题