Hi all,
I'm working on a project with i18n and localization, but when I want to use
the translations that simple doesn't work. I have done an example project,
may I'm forgetting something I just create the project using the
official documentation:
*
http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/project.html
using
pcreate -s starter MyProject
*
http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/i18n.html
*This is the step by step:*
* pcreate -s starter MyProject
* Modified *setup.py* to:
requires = [
'pyramid',
'pyramid_debugtoolbar',
'waitress',
*'Babel',*
*'lingua',*
]
setup(name='MyProject',
version='0.0',
description='MyProject',
.
entry_points = \
[paste.app_factory]
main = myproject:main
,
* message_extractors = { '.': [*
*('**.py', 'lingua_python', None ),*
*('**.pt', 'lingua_xml', None ),*
* ]},*
)
* Changed *development.ini* to add:
[app:main]
use = egg:MyProject
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en
pyramid.includes =
pyramid_debugtoolbar
*available_languages = en es*
* Added to *myproject/__init__.py*
def main(global_config, **settings):
This function returns a Pyramid WSGI application.
config = Configurator(settings=settings)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.scan()
*config.add_translation_dirs('locale/')*
return config.make_wsgi_app()
* Added to *myproject/views.py*
*
*from pyramid.view import view_config*
from pyramid.i18n import TranslationString as _
*
@view_config(route_name='home', renderer='templates/mytemplate.pt')
def my_view(request):
*hello = _('Hi')*
return {'project':'MyProject',
*'hello':hello,*}
Added to *myproject/templates/mytemplate.pt*:
p class=app-welcome
* ${hello}* Welcome to span class=app-name${project}/span,
an application generated bybr/
the Pyramid web application development framework.
/p
* Run python setup.py extract_messages
* Run python setup.py init_catalog -l en
* Run python setup.py init_catalog -l es
* Modified *myproject/locale/en/LC_MESSAGES/MyProject.po:*
*
*
*#: myproject/views.py:6*
*msgid Hi*
*msgstr English Hi*
*
*
* Modified *myproject/locale/es/LC_MESSAGES/MyProject.po:*
*#: myproject/views.py:6*
*msgid Hi*
*msgstr Spanish Hi*
* Run python setup.py compile_catalog
* Start the server
* Go to http://127.0.0.1:6543?_LOCALE_=enhttp://127.0.0.1:6543/?_LOCALE_=en
and
doesn't work at all!
Yo may see the example project at
https://bitbucket.org/aguirrel/translation_test/src
I have done a lot of test, but nothing work. So I preffer if you may check
this clear project.
Thanks a lot in advance,
Best regards,
Luis
--
You received this message because you are subscribed to the Google Groups
pylons-discuss group.
To view this discussion on the web visit
https://groups.google.com/d/msg/pylons-discuss/-/6Z_dB27TTXsJ.
To post to this group, send email to pylons-discuss@googlegroups.com.
To unsubscribe from this group, send email to
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.