[olso][pbr][i18n] Using setup.cfg [files] data_files to install localization files
Hello everyone :),
I was wondering what the preferred method to install localization files is. I can think of some probably solutions such as:
1: Including the locale files as part of a package for the target systems package manager (pacman, yum, apt, etc). 2: adding the locale files to the [files] directive in setup.cfg:
I hope someone can answer my question.
Kind regards, Corne Lukken
Hello,
Good question, I think that both solutions can do the job, and it depends on your needs.
If you choose the second option I think you also need to edit the `MANIFEST.in` to recursively grab your files in your package, then that will look like something like: ``` # MANIFEST.in recursive-include translations/ * ``` ``` # setup.cfg [files] packages = yourproject data_files = etc/yourproject/translation = translations/* ```
Where do you want to use this? I mean, do you have a specific project behind this question?
Le lun. 25 nov. 2019 à 16:18, info@dantalion.nl info@dantalion.nl a écrit :
Hello everyone :),
I was wondering what the preferred method to install localization files is. I can think of some probably solutions such as:
1: Including the locale files as part of a package for the target systems package manager (pacman, yum, apt, etc). 2: adding the locale files to the [files] directive in setup.cfg:
I hope someone can answer my question.
Kind regards, Corne Lukken
Hello,
This questions comes from noticing locales aren't detected on Watcher and many other OpenStack projects when `python setup.py install` is executed. The behavior of installing and detecting locales seems to be the same both inside and without a virtualenv.
On Watcher we do not have a MANIFEST.in file in the repository, what would such a file look like do you perhaps have a reference?
Currently I was thinking of doing something like this:
#setup.cfg[files] data_files = usr/share/locale/nl/LC_MESSAGES = watcher/locale/nl/LC_MESSAGES/watcher.mo
This, however, feels clunky and I would expect locale installation and detection to be more automatic.
you can test if locales are detected for a project using:
`oslo_i18n.get_available_languages(DOMAIN)`
In the case of Watcher this only returns `['en_US']` which is inserted as default.
Maybe `python setup.py install` is not the right command to install locales?
Kind regards,
Corne Lukken
On 26-11-19 16:18, Herve Beraud wrote:
Hello,
Good question, I think that both solutions can do the job, and it depends on your needs.
If you choose the second option I think you also need to edit the `MANIFEST.in` to recursively grab your files in your package, then that will look like something like:
# MANIFEST.in recursive-include translations/ *
# setup.cfg [files] packages = yourproject data_files = etc/yourproject/translation = translations/*
Where do you want to use this? I mean, do you have a specific project behind this question?
Le lun. 25 nov. 2019 à 16:18, info@dantalion.nl info@dantalion.nl a écrit :
Hello everyone :),
I was wondering what the preferred method to install localization files is. I can think of some probably solutions such as:
1: Including the locale files as part of a package for the target systems package manager (pacman, yum, apt, etc). 2: adding the locale files to the [files] directive in setup.cfg:
I hope someone can answer my question.
Kind regards, Corne Lukken
Hi,
I think localization files are automatically included in a python package even if setup.cfg has no explicit entry.
Here is an example of the case of the horizon repository: http://paste.openstack.org/show/786732/ I can see localized files after installing a horizon wheel package into a virtualenv.
1: Including the locale files as part of a package for the target systems package manager (pacman, yum, apt, etc).
These package managers just do the similar thing in a different way.
2: adding the locale files to the [files] directive in setup.cfg:
I don't think we need to specify them in setup.cfg. Am I missing something?
Thanks, Akihiro Motoki (amotoki)
On Tue, Nov 26, 2019 at 12:17 AM info@dantalion.nl info@dantalion.nl wrote:
Hello everyone :),
I was wondering what the preferred method to install localization files is. I can think of some probably solutions such as:
1: Including the locale files as part of a package for the target systems package manager (pacman, yum, apt, etc). 2: adding the locale files to the [files] directive in setup.cfg:
I hope someone can answer my question.
Kind regards, Corne Lukken
Hello,
I don't think we need to specify them in setup.cfg. Am I missing something?
I thought so to but I recently checked on Watcher and noticed that executing 'python setup.py install' does not build + move the .mo files into the required locale directories. I proceeded to test on other OpenStack projects and saw the same behavior.
This was verified by listing the available languages with: `oslo_i18n.get_available_languages(DOMAIN)` which than only returns `['en_US']`
Maybe `python setup.py install` is not the correct command to do this?
Kind regards. Corne Lukken
On 26-11-19 16:47, Akihiro Motoki wrote:
Hi,
I think localization files are automatically included in a python package even if setup.cfg has no explicit entry.
Here is an example of the case of the horizon repository: http://paste.openstack.org/show/786732/ I can see localized files after installing a horizon wheel package into a virtualenv.
1: Including the locale files as part of a package for the target systems package manager (pacman, yum, apt, etc).
These package managers just do the similar thing in a different way.
2: adding the locale files to the [files] directive in setup.cfg:
I don't think we need to specify them in setup.cfg. Am I missing something?
Thanks, Akihiro Motoki (amotoki)
On Tue, Nov 26, 2019 at 12:17 AM info@dantalion.nl info@dantalion.nl wrote:
Hello everyone :),
I was wondering what the preferred method to install localization files is. I can think of some probably solutions such as:
1: Including the locale files as part of a package for the target systems package manager (pacman, yum, apt, etc). 2: adding the locale files to the [files] directive in setup.cfg:
I hope someone can answer my question.
Kind regards, Corne Lukken
It seems you need to break down the thing into two parts: (1) Installing po files (2) Compiling po files into .mo files
In my understanding, python setup.py (or more preferably pip install) handles only (1). (2) is not covered by the python package installation process and you need to compile mo files manually if you use pip to install OpenStack python packages.
gettext (used under oslo_i18n.get_available_languages) only looks for mo files. That's the reason get_available_languages() did not detect languages other than en_US.
In case of horizon, po files are compiled explicitly during devstack stack.sh. Most distro packages generate mo files during package creation or package installation.
If you would like to enable translations in OpenStack services, I believe you need to compile po files into mo files.
Akihiro
On Wed, Nov 27, 2019 at 2:27 AM info@dantalion.nl info@dantalion.nl wrote:
Hello,
I don't think we need to specify them in setup.cfg. Am I missing something?
I thought so to but I recently checked on Watcher and noticed that executing 'python setup.py install' does not build + move the .mo files into the required locale directories. I proceeded to test on other OpenStack projects and saw the same behavior.
This was verified by listing the available languages with: `oslo_i18n.get_available_languages(DOMAIN)` which than only returns `['en_US']`
Maybe `python setup.py install` is not the correct command to do this?
Kind regards. Corne Lukken
On 26-11-19 16:47, Akihiro Motoki wrote:
Hi,
I think localization files are automatically included in a python package even if setup.cfg has no explicit entry.
Here is an example of the case of the horizon repository: http://paste.openstack.org/show/786732/ I can see localized files after installing a horizon wheel package into a virtualenv.
1: Including the locale files as part of a package for the target systems package manager (pacman, yum, apt, etc).
These package managers just do the similar thing in a different way.
2: adding the locale files to the [files] directive in setup.cfg:
I don't think we need to specify them in setup.cfg. Am I missing something?
Thanks, Akihiro Motoki (amotoki)
On Tue, Nov 26, 2019 at 12:17 AM info@dantalion.nl info@dantalion.nl wrote:
Hello everyone :),
I was wondering what the preferred method to install localization files is. I can think of some probably solutions such as:
1: Including the locale files as part of a package for the target systems package manager (pacman, yum, apt, etc). 2: adding the locale files to the [files] directive in setup.cfg:
I hope someone can answer my question.
Kind regards, Corne Lukken
participants (3)
-
Akihiro Motoki
-
Herve Beraud
-
info@dantalion.nl