Reputation: 3699
I have a kivy app that uses a module from another package. The packages are organised as follows:
.
├── kivy_app
│ ├── bin
│ │ └── myapp-0.1-debug.apk
│ ├── buildozer.spec
│ └── kivy_app
│ ├── __init__.py
│ ├── __main__.py
│ ├── main.py
│ ├── python_pkg -> /home/jeff/projects/kivy_pkg/python_pkg/python_pkg
│ └── source
│ └── kivy_app.py
└── python_pkg
└── python_pkg
├── __init__.py
├── locale
│ └── en_GB
│ └── LC_MESSAGES
│ └── python_pkg.mo
└── source
└── version.py
The module kivy_app.py accesses version.py in python_pkg. This latter package uses a translation file based on gettext, set up in the normal way.
The application works perfectly on the PC, but when the app is run on an android device it crashes. The relevant lines in the logcat output are:
09-07 16:28:22.142 10274 10340 I python : File "/home/jeff/projects/kivy_pkg/kivy_app/.buildozer/android/platform/build/build/other_builds/python3-libffi-openssl-sqlite3/armeabi-v7a__ndk_target_21/python3/Lib/gettext.py", line 524, in translation
09-07 16:28:22.142 10274 10340 I python : FileNotFoundError: [Errno 2] No translation file found for domain: 'python_pkg'
I cannot find where gettext.py is trying to locate the mo files. Can someone please suggest how I might change things so that it works?
PS It works if I set the fallback value to True in gettext.translation(), but then no translation gets done!
Upvotes: 1
Views: 393
Reputation: 11
I see that it is an old question, but recently I had the same problem: on PC it worked, on android crashed. And the output in the logcat was the same.
All .mo files were included in package. So, I've copied gettext.py
to my project and added print-statements in function find
. There is a part, where it goes through all possible languages, builds a path to .mo file and checks if it exists.
It appeared that on PC and android these language arrays are different. All I've got to do, was to change in my project locale directory name from EN
to en
, etc. Now it works.
Upvotes: 1