pyramid-localize 0.1.0__py3.3.egg

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. EGG-INFO/PKG-INFO +139 -0
  2. EGG-INFO/SOURCES.txt +50 -0
  3. EGG-INFO/dependency_links.txt +1 -0
  4. EGG-INFO/not-zip-safe +1 -0
  5. EGG-INFO/requires.txt +15 -0
  6. EGG-INFO/top_level.txt +2 -0
  7. pyramid_localize/__init__.py +62 -0
  8. pyramid_localize/__pycache__/__init__.cpython-33.pyc +0 -0
  9. pyramid_localize/__pycache__/models.cpython-33.pyc +0 -0
  10. pyramid_localize/__pycache__/negotiator.cpython-33.pyc +0 -0
  11. pyramid_localize/__pycache__/request.cpython-33.pyc +0 -0
  12. pyramid_localize/__pycache__/tools.cpython-33.pyc +0 -0
  13. pyramid_localize/config/config.yml +13 -0
  14. pyramid_localize/models.py +37 -0
  15. pyramid_localize/negotiator.py +41 -0
  16. pyramid_localize/request.py +124 -0
  17. pyramid_localize/resources/locale/pyramid_localize.pot +58 -0
  18. pyramid_localize/resources/templates/_list.mako +33 -0
  19. pyramid_localize/resources/templates/index.mako +19 -0
  20. pyramid_localize/resources/templates/layout.mako +12 -0
  21. pyramid_localize/routing/__init__.py +5 -0
  22. pyramid_localize/routing/__pycache__/__init__.cpython-33.pyc +0 -0
  23. pyramid_localize/routing/__pycache__/predicates.cpython-33.pyc +0 -0
  24. pyramid_localize/routing/predicates.py +18 -0
  25. pyramid_localize/subscribers/__init__.py +5 -0
  26. pyramid_localize/subscribers/__pycache__/__init__.cpython-33.pyc +0 -0
  27. pyramid_localize/subscribers/__pycache__/fake.cpython-33.pyc +0 -0
  28. pyramid_localize/subscribers/__pycache__/i18n.cpython-33.pyc +0 -0
  29. pyramid_localize/subscribers/fake.py +27 -0
  30. pyramid_localize/subscribers/i18n.py +27 -0
  31. pyramid_localize/tools.py +100 -0
  32. pyramid_localize/views/__init__.py +5 -0
  33. pyramid_localize/views/__pycache__/__init__.cpython-33.pyc +0 -0
  34. pyramid_localize/views/__pycache__/catalogue.cpython-33.pyc +0 -0
  35. pyramid_localize/views/catalogue.py +225 -0
  36. tests/__init__.py +1 -0
  37. tests/__pycache__/__init__.cpython-33.pyc +0 -0
  38. tests/__pycache__/conftest.cpython-33.pyc +0 -0
  39. tests/__pycache__/test_negotiator.cpython-33.pyc +0 -0
  40. tests/__pycache__/test_predicates.cpython-33.pyc +0 -0
  41. tests/__pycache__/test_request.cpython-33.pyc +0 -0
  42. tests/__pycache__/test_subscribers.cpython-33.pyc +0 -0
  43. tests/__pycache__/test_tools.cpython-33.pyc +0 -0
  44. tests/conftest.py +58 -0
  45. tests/test_negotiator.py +55 -0
  46. tests/test_predicates.py +23 -0
  47. tests/test_request.py +89 -0
  48. tests/test_subscribers.py +80 -0
  49. tests/test_tools.py +105 -0
EGG-INFO/PKG-INFO ADDED
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 1.1
2
+ Name: pyramid-localize
3
+ Version: 0.1.0
4
+ Summary: Package to provide translation methods for pyramid,
5
+ and means to reload translations without stopping the application
6
+ Home-page: https://github.com/fizyk/pyramid_localize
7
+ Author: Grzegorz Sliwinski
8
+ Author-email: username: fizyk, domain: fizyk.net.pl
9
+ License: MIT License
10
+ Description: pyramid_localize
11
+ ================
12
+
13
+ .. image:: https://pypip.in/v/pyramid_localize/badge.png
14
+ :target: https://pypi.python.org/pypi/pyramid_localize/
15
+ :alt: Latest PyPI version
16
+
17
+ .. image:: https://pypip.in/d/pyramid_localize/badge.png
18
+ :target: https://pypi.python.org/pypi/pyramid_localize/
19
+ :alt: Number of PyPI downloads
20
+
21
+ .. image:: https://pypip.in/wheel/pyramid_localize/badge.png
22
+ :target: https://pypi.python.org/pypi/pyramid_localize/
23
+ :alt: Wheel Status
24
+
25
+ .. image:: https://pypip.in/egg/pyramid_localize/badge.png
26
+ :target: https://pypi.python.org/pypi/pyramid_localize/
27
+ :alt: Egg Status
28
+
29
+ .. image:: https://pypip.in/license/pyramid_localize/badge.png
30
+ :target: https://pypi.python.org/pypi/pyramid_localize/
31
+ :alt: License
32
+
33
+ Package provides translation methods for pyramid, and means to reload translations
34
+ without stopping the application.
35
+
36
+
37
+ Package status
38
+ --------------
39
+
40
+ .. image:: https://travis-ci.org/fizyk/pyramid_localize.png?branch=master
41
+ :target: https://travis-ci.org/fizyk/pyramid_localize
42
+ :alt: Tests
43
+
44
+ .. image:: https://coveralls.io/repos/fizyk/pyramid_localize/badge.png?branch=master
45
+ :target: https://coveralls.io/r/fizyk/pyramid_localize?branch=master
46
+ :alt: Coverage Status
47
+
48
+ .. image:: https://requires.io/github/fizyk/pyramid_localize/requirements.png?branch=master
49
+ :target: https://requires.io/github/fizyk/pyramid_localize/requirements/?branch=master
50
+ :alt: Requirements Status
51
+
52
+
53
+
54
+ Package resources
55
+ -----------------
56
+
57
+ * Bug tracker: https://github.com/fizyk/pyramid_localize/issues
58
+ * Documentation: http://pyramid-localize.readthedocs.org/
59
+ * PyPI: https://pypi.python.org/pypi/pyramid_localize
60
+
61
+
62
+ Instalation:
63
+ ============
64
+
65
+ ``pip install pyramid_localize``
66
+
67
+ or add **pyramid_localize** to your **setup.py** requirements.
68
+
69
+
70
+ Tests:
71
+ ======
72
+
73
+ You'll need: packages defined in extra_requires[tests] to run tests, and then:
74
+
75
+ ``python setup.py nosetests``
76
+
77
+
78
+ =======
79
+ CHANGES
80
+ =======
81
+
82
+
83
+ 0.1.0
84
+ -----
85
+
86
+ - weaker pyramid_yml requirements. Use ``registry['config']`` instead of ``request.config`` which gets added only when explicitly including tzf.pyramid_yml package.
87
+ - deprecated request.locale in favour of request.locale_name delivered by Pyramid 1.5
88
+ - moved locale negotiator into it's own submodule
89
+
90
+ backward incompatible
91
+ +++++++++++++++++++++
92
+ - required cookie name changed to _LOCALE_ to be consistent with other places
93
+ - fixed a typo from catalog to catalogue
94
+
95
+ tests
96
+ +++++
97
+ - refactor tests to pytest
98
+ - introduced pylama checks for:
99
+ - pep8
100
+ - pyflakes
101
+ - pep257
102
+ - mccabe
103
+
104
+ - license information
105
+ - requires at least pyramid 1.5a1 (rely on default localizer reify method)
106
+ - py3 compatibility (require at least babel 1.0)
107
+ - locale negotiator looks first for request attribute _LOCALE_
108
+ - added pyramid_mako dependency (required by pyramid 1.5a2 changes)
109
+
110
+ 0.0.5
111
+ -----
112
+ - fixes in catalog/index template [zusel, fizyk]
113
+ - destination path added in translation_dirs as a translation source as well [fizyk]
114
+
115
+ 0.0.4
116
+ -----
117
+ - fix issue with translation files path beeing not related to cwd [fizyk]
118
+
119
+ 0.0.2
120
+ -----
121
+ - fixed MANIFEST.in [fizyk]
122
+
123
+ 0.0.1
124
+ -----
125
+ - initial release [fizyk]
126
+
127
+ Keywords: python template
128
+ Platform: UNKNOWN
129
+ Classifier: Development Status :: 5 - Production/Stable
130
+ Classifier: Environment :: Web Environment
131
+ Classifier: Intended Audience :: Developers
132
+ Classifier: License :: OSI Approved :: MIT License
133
+ Classifier: Natural Language :: English
134
+ Classifier: Operating System :: OS Independent
135
+ Classifier: Programming Language :: Python
136
+ Classifier: Programming Language :: Python :: 2.7
137
+ Classifier: Programming Language :: Python :: 3.3
138
+ Classifier: Programming Language :: Python :: 3.4
139
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
EGG-INFO/SOURCES.txt ADDED
@@ -0,0 +1,50 @@
1
+ AUTHORS.rst
2
+ CHANGES.rst
3
+ MANIFEST.in
4
+ README.rst
5
+ setup.cfg
6
+ setup.py
7
+ docs/Makefile
8
+ docs/make.bat
9
+ docs/source/advanced.rst
10
+ docs/source/api.rst
11
+ docs/source/authors.rst
12
+ docs/source/basic.rst
13
+ docs/source/changelog.rst
14
+ docs/source/conf.py
15
+ docs/source/index.rst
16
+ docs/source/api/models.rst
17
+ docs/source/api/negotiator.rst
18
+ docs/source/api/request.rst
19
+ docs/source/api/tools.rst
20
+ docs/source/api/views.rst
21
+ pyramid_localize/__init__.py
22
+ pyramid_localize/models.py
23
+ pyramid_localize/negotiator.py
24
+ pyramid_localize/request.py
25
+ pyramid_localize/tools.py
26
+ pyramid_localize.egg-info/PKG-INFO
27
+ pyramid_localize.egg-info/SOURCES.txt
28
+ pyramid_localize.egg-info/dependency_links.txt
29
+ pyramid_localize.egg-info/not-zip-safe
30
+ pyramid_localize.egg-info/requires.txt
31
+ pyramid_localize.egg-info/top_level.txt
32
+ pyramid_localize/config/config.yml
33
+ pyramid_localize/resources/locale/pyramid_localize.pot
34
+ pyramid_localize/resources/templates/_list.mako
35
+ pyramid_localize/resources/templates/index.mako
36
+ pyramid_localize/resources/templates/layout.mako
37
+ pyramid_localize/routing/__init__.py
38
+ pyramid_localize/routing/predicates.py
39
+ pyramid_localize/subscribers/__init__.py
40
+ pyramid_localize/subscribers/fake.py
41
+ pyramid_localize/subscribers/i18n.py
42
+ pyramid_localize/views/__init__.py
43
+ pyramid_localize/views/catalogue.py
44
+ tests/__init__.py
45
+ tests/conftest.py
46
+ tests/test_negotiator.py
47
+ tests/test_predicates.py
48
+ tests/test_request.py
49
+ tests/test_subscribers.py
50
+ tests/test_tools.py
@@ -0,0 +1 @@
1
+
EGG-INFO/not-zip-safe ADDED
@@ -0,0 +1 @@
1
+
EGG-INFO/requires.txt ADDED
@@ -0,0 +1,15 @@
1
+ pyramid_basemodel
2
+ tzf.pyramid_yml >=0.2
3
+ pyramid >=1.5a1
4
+ pyramid_mako
5
+
6
+ [babel]
7
+ Babel >= 1.0
8
+
9
+ [docs]
10
+ sphinx
11
+
12
+ [tests]
13
+ pytest_pyramid
14
+ pytest-cov
15
+ mock
EGG-INFO/top_level.txt ADDED
@@ -0,0 +1,2 @@
1
+ tests
2
+ pyramid_localize
@@ -0,0 +1,62 @@
1
+ # Copyright (c) 2013-2014 by pyramid_localize authors and contributors <see AUTHORS file>
2
+ #
3
+ # This module is part of pyramid_localize and is released under
4
+ # the MIT License (MIT): http://opensource.org/licenses/MIT
5
+ """pyramid_localize configuration module."""
6
+
7
+ try: # pragma: no cover
8
+ import babel
9
+ except ImportError: # pragma: no cover
10
+ babel = False
11
+
12
+ from tzf.pyramid_yml import config_defaults
13
+
14
+ from pyramid_localize.request import (
15
+ locale, database_locales, locales, locale_id
16
+ )
17
+
18
+ __version__ = '0.1.0'
19
+
20
+
21
+ def includeme(configurator):
22
+ """pyramid_localize configuration method."""
23
+ # let's check if we have any configuration, or not
24
+ if babel:
25
+ configurator.scan('pyramid_localize.subscribers.i18n')
26
+ configuration = configurator.registry.get('config', {}).get('localize')
27
+ if configuration:
28
+ configurator.include('pyramid_mako')
29
+ # once user allowed for localization, lets set up default values!
30
+ config_defaults(configurator, 'pyramid_localize:config')
31
+
32
+ configurator.set_locale_negotiator('pyramid_localize.negotiator.locale_negotiator')
33
+ translation_dirs = configuration.translation.dirs
34
+ # if it's not a list, lets make it a list.
35
+ # This is to allow creating both single, and list-like config entry
36
+ if not isinstance(translation_dirs, list):
37
+ translation_dirs = [translation_dirs]
38
+
39
+ # let's add destination folder to the list
40
+ if 'destination' in configuration.translation:
41
+ translation_dirs.append(configuration.translation.destination)
42
+
43
+ configurator.add_translation_dirs(*translation_dirs)
44
+ # let scan all subscribers
45
+ configurator.scan('pyramid_localize.views')
46
+
47
+ configurator.add_route(name='localize:index', pattern='catalogue')
48
+ configurator.add_route(name='localize:update', pattern='catalogue/update')
49
+ configurator.add_route(name='localize:compile', pattern='catalogue/compile')
50
+ configurator.add_route(name='localize:reload', pattern='catalogue/reload')
51
+
52
+ # getting requests methods
53
+ configurator.add_request_method(locale, name='locale', reify=True)
54
+ configurator.add_request_method(database_locales, name='_database_locales', reify=True)
55
+ configurator.add_request_method(locales, name='locales')
56
+ configurator.add_request_method(locale_id, name='locale_id', reify=True)
57
+
58
+ # if configured
59
+ return
60
+
61
+ # including fake subscribers
62
+ configurator.scan('pyramid_localize.subscribers.fake')
@@ -0,0 +1,13 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Copyright (c) 2013-2014 by pyramid_localize authors and contributors <see AUTHORS file>
4
+ #
5
+ # This module is part of pyramid_localize and is released under
6
+ # the MIT License (MIT): http://opensource.org/licenses/MIT
7
+ localize:
8
+ pybabel: pybabel
9
+ locales: # available and default locale for your app
10
+ available: [en, de, pl]
11
+ default: en
12
+ translation:
13
+ dirs: []
@@ -0,0 +1,37 @@
1
+ # Copyright (c) 2013-2014 by pyramid_localize authors and contributors <see AUTHORS file>
2
+ #
3
+ # This module is part of pyramid_localize and is released under
4
+ # the MIT License (MIT): http://opensource.org/licenses/MIT
5
+ """Language model."""
6
+
7
+
8
+ from sqlalchemy import Column
9
+ from sqlalchemy import Sequence
10
+ from sqlalchemy import Integer
11
+ from sqlalchemy import String
12
+ from sqlalchemy import Unicode
13
+ from sqlalchemy import DateTime
14
+ from sqlalchemy import func
15
+
16
+ from pyramid_basemodel import Base
17
+
18
+
19
+ class Language(Base):
20
+
21
+ """Language table model definition."""
22
+
23
+ __tablename__ = 'languages'
24
+
25
+ id = Column(Integer, Sequence(__tablename__ + '_sq'), primary_key=True)
26
+ updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), nullable=False)
27
+ name = Column(Unicode(45), nullable=False)
28
+ native_name = Column(Unicode(45), nullable=False)
29
+ language_code = Column(String(2), unique=True, nullable=False) # ISO 639-1 (Alpha2)
30
+
31
+ def __unicode__(self): # pragma: no cover
32
+ """Language to unicode conversion."""
33
+ return self.name
34
+
35
+ def __str__(self): # pragma: no cover
36
+ """Language to string conversion."""
37
+ return self.name.encode('utf8')
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2013-2014 by pyramid_localize authors and contributors <see AUTHORS file>
2
+ #
3
+ # This module is part of pyramid_localize and is released under
4
+ # the MIT License (MIT): http://opensource.org/licenses/MIT
5
+ """Locale negotiator."""
6
+
7
+
8
+ def locale_negotiator(request):
9
+ """
10
+ Locale negotiator.
11
+
12
+ It sets best suited locale variable for given user:
13
+
14
+ 1. Check for presence and value of **request._LOCALE_** value
15
+ 2. Then tries the address url, if the first part has locale indicator.
16
+ 3. It checks cookies, for value set here
17
+ 4. Tries to best match accepted language for browser user is visiting
18
+ website with
19
+ 5. Defaults to **localize.locales.default** configuration setting value
20
+
21
+ :param pyramid.request.Request request: a request object
22
+ :returns: locale name
23
+ :rtype: str
24
+ """
25
+ available_languages = request.registry['config'].localize.locales.available
26
+ locale = request.registry['config'].localize.locales.default
27
+ # We do not have a matchdict present at the moment, lets get our own split
28
+ # (request.path is always a /, so we'll get two elements)
29
+ route_elements = request.path.split('/')
30
+ if hasattr(request, '_LOCALE_') and request._LOCALE_ in available_languages:
31
+ locale = request._LOCALE_
32
+ # we check if route_element[1] is a locale indicator for path
33
+ elif len(route_elements[1]) == 2 and route_elements[1] in available_languages:
34
+ locale = route_elements[1]
35
+ elif request.cookies and '_LOCALE_' in request.cookies and\
36
+ request.cookies['_LOCALE_'] in available_languages:
37
+ locale = request.cookies['_LOCALE_']
38
+ elif request.accept_language:
39
+ locale = request.accept_language.best_match(available_languages)
40
+
41
+ return locale
@@ -0,0 +1,124 @@
1
+ # Copyright (c) 2013-2014 by pyramid_localize authors and contributors <see AUTHORS file>
2
+ #
3
+ # This module is part of pyramid_localize and is released under
4
+ # the MIT License (MIT): http://opensource.org/licenses/MIT
5
+ """Request related code."""
6
+
7
+ import warnings
8
+
9
+ from pyramid.compat import text_type
10
+ import pyramid_basemodel
11
+
12
+ from pyramid_localize.models import Language
13
+
14
+
15
+ class LocalizeRequestMixin(object):
16
+
17
+ """Mixin adding overwriting Request methods."""
18
+
19
+ def default_locale(self, **kw):
20
+ """
21
+ Set up default locale for path kwargs.
22
+
23
+ Can be used in custom route_url overwrites.
24
+
25
+ :param kwargs kw: list of route parts
26
+
27
+ :returns: kw
28
+ """
29
+ if '__LOCALE__' not in kw \
30
+ or kw['__LOCALE__'] not in self.registry['config'].localize.locales.available:
31
+ kw['__LOCALE__'] = self.locale_name
32
+
33
+ return kw
34
+
35
+ def route_url(self, route_name, *elements, **kw):
36
+ """
37
+ Overwrite original route_url to handle default locale within route.
38
+
39
+ .. note:: see :meth:`pyramid.request.Request.route_url`
40
+ """
41
+ return super(LocalizeRequestMixin, self).route_url(
42
+ route_name, *elements, **self.default_locale(**kw)
43
+ )
44
+
45
+
46
+ def locale(request):
47
+ """
48
+ Return locale name.
49
+
50
+ .. warning::
51
+
52
+ Since pyramid 1.5 this function is obsolete and will be deprecated
53
+ in future versions of pyramid_localize
54
+
55
+ When called for the first time, it ask environment for language code,
56
+ which is later available as a pure property
57
+ overriding this method
58
+
59
+ :returns: language code needed for translations
60
+ :rtype: string
61
+ """
62
+ warnings.warn(
63
+ 'request.locale is deprecated as of pyramid_localize 0.1. '
64
+ 'Please use request.locale_name delivered by Pyramid 1.5.',
65
+ DeprecationWarning,
66
+ 2
67
+ )
68
+ return request.locale_name
69
+
70
+
71
+ def locale_id(request):
72
+ """
73
+ Return database id of a current locale name.
74
+
75
+ :returns: database id of a language code needed for translations
76
+ :rtype: int
77
+ """
78
+ if request.locale_name not in request._database_locales:
79
+ _create_locale(request.locale_name, request)
80
+
81
+ return request._database_locales[request.locale_name].id
82
+
83
+
84
+ def database_locales(request):
85
+ """
86
+ Return list of all database locales available.
87
+
88
+ :returns: dictionary of Language objects language_code: Language
89
+ :rtype: dict
90
+ """
91
+ locales = {}
92
+ for language in pyramid_basemodel.Session.query(Language).all():
93
+ locales[language.language_code] = language
94
+
95
+ return locales
96
+
97
+
98
+ def locales(request, config=False):
99
+ """
100
+ Return a list of locales.
101
+
102
+ :param bool config: Whether to restrict list with config
103
+
104
+ :returns: dictionary of Language objects language_code: Language
105
+ :rtype: dict
106
+ """
107
+ if config:
108
+ locales = {}
109
+ for locale in request.registry['config'].localize.locales.available:
110
+ if locale not in request._database_locales:
111
+ _create_locale(locale, request)
112
+ locales[locale] = request._database_locales[locale]
113
+
114
+ return locales
115
+
116
+ return request._database_locales
117
+
118
+
119
+ def _create_locale(locale, request):
120
+ new_locale = Language(name=text_type(locale),
121
+ native_name=text_type(locale),
122
+ language_code=text_type(locale))
123
+ pyramid_basemodel.Session.add(new_locale)
124
+ request._database_locales = database_locales(request)
@@ -0,0 +1,58 @@
1
+ # Translations template for pyramid_localize.
2
+ # Copyright (C) 2013 ORGANIZATION
3
+ # This file is distributed under the same license as the pyramid_localize
4
+ # project.
5
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2013.
6
+ #
7
+ #, fuzzy
8
+ msgid ""
9
+ msgstr ""
10
+ "Project-Id-Version: pyramid_localize 0.0.1\n"
11
+ "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
12
+ "POT-Creation-Date: 2013-06-06 22:20+0200\n"
13
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
15
+ "Language-Team: LANGUAGE <LL@li.org>\n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=utf-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Generated-By: Babel 0.9.6\n"
20
+
21
+ #: pyramid_localize/resources/templates/_list.mako:5
22
+ msgid "Language"
23
+ msgstr ""
24
+
25
+ #: pyramid_localize/resources/templates/_list.mako:6
26
+ msgid "Translation domain"
27
+ msgstr ""
28
+
29
+ #: pyramid_localize/resources/templates/_list.mako:7
30
+ #: pyramid_localize/resources/templates/_list.mako:8
31
+ #: pyramid_localize/resources/templates/_list.mako:9
32
+ msgid "${type} modification time"
33
+ msgstr ""
34
+
35
+ #: pyramid_localize/resources/templates/index.mako:4
36
+ msgid "Translations"
37
+ msgstr ""
38
+
39
+ #: pyramid_localize/resources/templates/index.mako:6
40
+ msgid "Update catalog"
41
+ msgstr ""
42
+
43
+ #: pyramid_localize/resources/templates/index.mako:7
44
+ msgid "Compile catalog"
45
+ msgstr ""
46
+
47
+ #: pyramid_localize/resources/templates/index.mako:8
48
+ msgid "Reload catalog"
49
+ msgstr ""
50
+
51
+ #: pyramid_localize/resources/templates/layout.mako:3
52
+ msgid "Welcome, to pyramid_localize!"
53
+ msgstr ""
54
+
55
+ #: pyramid_localize/views/catalog.py:166
56
+ msgid "Localizators has been reloaded"
57
+ msgstr ""
58
+
@@ -0,0 +1,33 @@
1
+ <%doc>
2
+ Copyright (c) 2013-2014 by pyramid_localize authors and contributors <see AUTHORS file>
3
+
4
+ This module is part of pyramid_localize and is released under
5
+ the MIT License (MIT): http://opensource.org/licenses/MIT
6
+ </%doc>
7
+ <table class="table table-hover">
8
+ <thead>
9
+ <tr>
10
+ <th>${_('Language', domain='pyramid_localize')}</th>
11
+ <th>${_('Translation domain', domain='pyramid_localize')}</th>
12
+ <th>${_('${type} modification time', domain='pyramid_localize', mapping={'type': 'pot'})}</th>
13
+ <th>${_('${type} modification time', domain='pyramid_localize', mapping={'type': 'po'})}</th>
14
+ <th>${_('${type} modification time', domain='pyramid_localize', mapping={'type': 'mo'})}</th>
15
+ </tr>
16
+ </thead>
17
+ <tbody>
18
+ % for language in translations:
19
+ <tr>
20
+ <td rowspan="${len(translations[language]) if len(translations[language]) > 1 else 1}">${language}</td>
21
+ % for domain in translations[language]:
22
+ <td>${domain}</td>
23
+ <td>${translations[language][domain]['pot']}</td>
24
+ <td>${translations[language][domain]['po']}</td>
25
+ <td>${translations[language][domain]['mo']}</td>
26
+ % if len(translations[language]) > 1:
27
+ </tr><tr>
28
+ % endif
29
+ % endfor
30
+ </tr>
31
+ % endfor
32
+ </tbody>
33
+ </table>
@@ -0,0 +1,19 @@
1
+ <%doc>
2
+ Copyright (c) 2013-2014 by pyramid_localize authors and contributors <see AUTHORS file>
3
+
4
+ This module is part of pyramid_localize and is released under
5
+ the MIT License (MIT): http://opensource.org/licenses/MIT
6
+ </%doc>
7
+ <%inherit file="pyramid_localize:resources/templates/layout.mako" />
8
+ <div class="row">
9
+ <div class="span9">
10
+ <h1>${_('Translations', domain='pyramid_localize')}</h1>
11
+ <p>
12
+ <a href="${request.route_path('localize:update')}" class="btn">${_('Update catalog', domain='pyramid_localize')}</a>
13
+ <a href="${request.route_path('localize:compile')}" class="btn">${_('Compile catalog', domain='pyramid_localize')}</a>
14
+ <a href="${request.route_path('localize:reload')}" class="btn">${_('Reload catalog', domain='pyramid_localize')}</a>
15
+ </p>
16
+ <%include file="_list.mako" />
17
+
18
+ </div>
19
+ </div>
@@ -0,0 +1,12 @@
1
+ <%doc>
2
+ Copyright (c) 2013-2014 by pyramid_localize authors and contributors <see AUTHORS file>
3
+
4
+ This module is part of pyramid_localize and is released under
5
+ the MIT License (MIT): http://opensource.org/licenses/MIT
6
+ </%doc>
7
+ <html>
8
+ <body>
9
+ <h1>${_('Welcome, to pyramid_localize!', domain='pyramid_localize')}</h1>
10
+ ${next.body()}
11
+ </body>
12
+ </html>
@@ -0,0 +1,5 @@
1
+ # Copyright (c) 2013-2014 by pyramid_localize authors and contributors <see AUTHORS file>
2
+ #
3
+ # This module is part of pyramid_localize and is released under
4
+ # the MIT License (MIT): http://opensource.org/licenses/MIT
5
+ """Routing related modules."""
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2013-2014 by pyramid_localize authors and contributors <see AUTHORS file>
2
+ #
3
+ # This module is part of pyramid_localize and is released under
4
+ # the MIT License (MIT): http://opensource.org/licenses/MIT
5
+ """Localize route predicate."""
6
+
7
+
8
+ def language(field):
9
+ """Create language predicate for given url match field."""
10
+ def predicate(info, request):
11
+ """Check whether language is one of the defaults."""
12
+ if field in info['match'] and\
13
+ info['match'][field] in request.registry['config'].localize.locales.available:
14
+ return True
15
+ return False
16
+ return predicate
17
+
18
+ language.__text__ = 'language predicate, to determine allowed languages in route'
@@ -0,0 +1,5 @@
1
+ # Copyright (c) 2013-2014 by pyramid_localize authors and contributors <see AUTHORS file>
2
+ #
3
+ # This module is part of pyramid_localize and is released under
4
+ # the MIT License (MIT): http://opensource.org/licenses/MIT
5
+ """Event subscribers, fake and real."""