I need to localize my pyramid application, but I have an issue.
The setup.py
file contains the following message_extractors
variable:
message_extractors = { '.': [
('templates/**.html', 'mako', None),
('templates/**.mako', 'mako', None),
('static/**', 'ignore', None)
]},
I've created directory my_package_name/locale
. In __init__.py
I added config.add_translation_dirs('my_package_name:locale')
.
But, when I run
(my_virtual_env): python setup.py extract_messages
I receive messages
running extract_messages
error: no output file specified`
If I understand correctly, extract_messages
does not require the --output-file parameter in this case.
What is the reason for this behavior?
You also need setup.cfg in the same directory as setup.py, containing roughly this:
[compile_catalog]
directory = YOURPROJECT/locale
domain = YOURPROJECT
statistics = true
[extract_messages]
add_comments = TRANSLATORS:
output_file = YOURPROJECT/locale/YOURPROJECT.pot
width = 80
[init_catalog]
domain = YOURPROJECT
input_file = YOURPROJECT/locale/YOURPROJECT.pot
output_dir = YOURPROJECT/locale
[update_catalog]
domain = YOURPROJECT
input_file = YOURPROJECT/locale/YOURPROJECT.pot
output_dir = YOURPROJECT/locale
previous = true
Of course, you will replace YOURPROJECT with your project name. I think the setup.cfg file used to be a part of the projects before pyramid 1.5 but now that pyramid uses lingua and gettext instead of babel it is not needed anymore. You might be better off if you follow current pyramid docs: http://pyramid.readthedocs.org/en/latest/narr/i18n.html