PICARD-2003: Include locales as package data inside the main package. #2591
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Problem
If picard got installed by
pip install picard
the translations where unavailable. That is because the locale files got included as a data files outside the package folder, and there is no default way to get this data folder.This PR ensures locales are available also in pip installs by moving the locale as data files into the picard package.
Solution
Move the locale directory holding the *.mo files into the picard package and include them as data files in the source package and wheel. Adjust the loading to use this locale dir by default.
This simplifies the code to build the locales, as there are no longer separate build target directories. This also removes the need to run
setup.py build_locales -i
aftersetup.py build
for local development.Separate handling is needed for pyinstaller "frozen" install. Oherwise the location of the locales is now always the same.
See also https://setuptools.pypa.io/en/latest/userguide/datafiles.html#interplay-between-these-keywords