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

Here I send you the step by step procedure, I think is all I need to do 
i18n work (at least in my interpretations of the documentation)*:

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 by<br/>
          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_=en<http://127.0.0.1:6543/?_LOCALE_=en>and doen'y 
work!  This sould say a the template "
*English hi* Welcome to..." but it say "*Hi* Welcome to..."

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/-/8qT6FOXjuuoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to