yhttp-i18n 1.0.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 yhttp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: yhttp-i18n
3
+ Version: 1.0.0
4
+ Summary: A very micro http framework.
5
+ Home-page: http://github.com/yhttp/yhttp-i18n
6
+ Author: Vahid Mardani
7
+ Author-email: vahid.mardani@gmail.com
8
+ License: MIT
9
+ Classifier: Environment :: Console
10
+ Classifier: Environment :: Web Environment
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Natural Language :: English
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: License :: Other/Proprietary License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Topic :: Software Development
18
+ Classifier: Topic :: Internet :: WWW/HTTP
19
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
20
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: yhttp<8,>=7.8
26
+ Dynamic: author
27
+ Dynamic: author-email
28
+ Dynamic: classifier
29
+ Dynamic: description
30
+ Dynamic: description-content-type
31
+ Dynamic: home-page
32
+ Dynamic: license
33
+ Dynamic: license-file
34
+ Dynamic: requires-dist
35
+ Dynamic: summary
36
+
37
+ # yhttp-i18n
38
+
39
+ [![PyPI](https://img.shields.io/pypi/v/yhttp-i18n.svg)](https://pypi.python.org/pypi/yhttp-i18n)
40
+ [![Build](https://github.com/yhttp/yhttp-i18n/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/yhttp/yhttp-i18n/actions/workflows/build.yml)
41
+ [![Coverage Status](https://coveralls.io/repos/github/yhttp/yhttp-i18n/badge.svg?branch=master)](https://coveralls.io/github/yhttp/yhttp-i18n?branch=master)
42
+
43
+
44
+ Internationalization and localization extension for
45
+ [yhttp](https://github.com/yhttp/yhttp).
@@ -0,0 +1,9 @@
1
+ # yhttp-i18n
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/yhttp-i18n.svg)](https://pypi.python.org/pypi/yhttp-i18n)
4
+ [![Build](https://github.com/yhttp/yhttp-i18n/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/yhttp/yhttp-i18n/actions/workflows/build.yml)
5
+ [![Coverage Status](https://coveralls.io/repos/github/yhttp/yhttp-i18n/badge.svg?branch=master)](https://coveralls.io/github/yhttp/yhttp-i18n?branch=master)
6
+
7
+
8
+ Internationalization and localization extension for
9
+ [yhttp](https://github.com/yhttp/yhttp).
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,57 @@
1
+ import os.path
2
+ import re
3
+
4
+ from setuptools import setup, find_namespace_packages
5
+
6
+
7
+ # reading package's version (same way sqlalchemy does)
8
+ with open(
9
+ os.path.join(
10
+ os.path.dirname(__file__),
11
+ 'yhttp/ext/i18n/', '__init__.py'
12
+ )
13
+ ) as v_file:
14
+ package_version = \
15
+ re.compile('.*__version__ = \'(.*?)\'', re.S)\
16
+ .match(v_file.read())\
17
+ .group(1)
18
+
19
+
20
+ dependencies = [
21
+ 'yhttp >= 7.8, < 8',
22
+ ]
23
+
24
+
25
+ setup(
26
+ name='yhttp-i18n',
27
+ version=package_version,
28
+ author='Vahid Mardani',
29
+ author_email='vahid.mardani@gmail.com',
30
+ url='http://github.com/yhttp/yhttp-i18n',
31
+ description='A very micro http framework.',
32
+ long_description=open('README.md').read(),
33
+ long_description_content_type='text/markdown', # This is important!
34
+ license='MIT',
35
+ install_requires=dependencies,
36
+ packages=find_namespace_packages(
37
+ where='.',
38
+ include=['yhttp.ext.i18n'],
39
+ exclude=['tests'],
40
+ ),
41
+ classifiers=[
42
+ 'Environment :: Console',
43
+ 'Environment :: Web Environment',
44
+ 'Intended Audience :: Developers',
45
+ 'Natural Language :: English',
46
+ 'Development Status :: 5 - Production/Stable',
47
+ 'License :: Other/Proprietary License',
48
+ 'Operating System :: OS Independent',
49
+ 'Programming Language :: Python :: 3.8',
50
+ 'Topic :: Software Development',
51
+ 'Topic :: Internet :: WWW/HTTP',
52
+ 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
53
+ 'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
54
+ 'Topic :: Software Development :: Libraries',
55
+ 'Topic :: Software Development :: Libraries :: Python Modules',
56
+ ]
57
+ )
@@ -0,0 +1,26 @@
1
+ import os
2
+
3
+ from bddrest import status, response
4
+ from yhttp.core import text
5
+
6
+ from yhttp.ext.i18n import install
7
+
8
+
9
+ def test_extension(httpreq, app, tempdir):
10
+ install(app)
11
+ i18ndirectory = os.path.join(tempdir, 'i18n')
12
+ app.settings.i18n.directory = i18ndirectory
13
+ app.ready()
14
+
15
+ assert app.i18n
16
+ assert app.i18n.settings.directory == i18ndirectory
17
+
18
+ @app.route()
19
+ @app.i18n
20
+ @text
21
+ def get(req):
22
+ return req.translator.gettext('foo')
23
+
24
+ with httpreq():
25
+ assert status == 200
26
+ assert response == 'foo'
@@ -0,0 +1,2 @@
1
+ from .install import install
2
+ __version__ = '1.0.0'
@@ -0,0 +1,23 @@
1
+ import functools
2
+ import gettext
3
+
4
+
5
+ class I18n:
6
+ def configure(self, settings):
7
+ self.settings = settings
8
+
9
+ def gettranslator(self, req):
10
+ return gettext.translation(
11
+ domain=self.settings.domain,
12
+ localedir=self.settings.directory,
13
+ languages=req.locales,
14
+ fallback=True,
15
+ )
16
+
17
+ def __call__(self, handler):
18
+ @functools.wraps(handler)
19
+ def wrapper(req, *a, **kw):
20
+ req.translator = self.gettranslator(req)
21
+ return handler(req, *a, **kw)
22
+
23
+ return wrapper
@@ -0,0 +1,17 @@
1
+ from .i18n import I18n
2
+
3
+
4
+ DEFAULT_SETTINGS = '''
5
+ domain: messages
6
+ directory: i18n
7
+ '''
8
+
9
+
10
+ def install(app):
11
+ app.settings.merge('i18n: {}')
12
+ app.settings.i18n.merge(DEFAULT_SETTINGS)
13
+ app.i18n = I18n()
14
+
15
+ @app.when
16
+ def ready(app):
17
+ app.i18n.configure(app.settings.i18n)
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: yhttp-i18n
3
+ Version: 1.0.0
4
+ Summary: A very micro http framework.
5
+ Home-page: http://github.com/yhttp/yhttp-i18n
6
+ Author: Vahid Mardani
7
+ Author-email: vahid.mardani@gmail.com
8
+ License: MIT
9
+ Classifier: Environment :: Console
10
+ Classifier: Environment :: Web Environment
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Natural Language :: English
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: License :: Other/Proprietary License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Topic :: Software Development
18
+ Classifier: Topic :: Internet :: WWW/HTTP
19
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
20
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: yhttp<8,>=7.8
26
+ Dynamic: author
27
+ Dynamic: author-email
28
+ Dynamic: classifier
29
+ Dynamic: description
30
+ Dynamic: description-content-type
31
+ Dynamic: home-page
32
+ Dynamic: license
33
+ Dynamic: license-file
34
+ Dynamic: requires-dist
35
+ Dynamic: summary
36
+
37
+ # yhttp-i18n
38
+
39
+ [![PyPI](https://img.shields.io/pypi/v/yhttp-i18n.svg)](https://pypi.python.org/pypi/yhttp-i18n)
40
+ [![Build](https://github.com/yhttp/yhttp-i18n/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/yhttp/yhttp-i18n/actions/workflows/build.yml)
41
+ [![Coverage Status](https://coveralls.io/repos/github/yhttp/yhttp-i18n/badge.svg?branch=master)](https://coveralls.io/github/yhttp/yhttp-i18n?branch=master)
42
+
43
+
44
+ Internationalization and localization extension for
45
+ [yhttp](https://github.com/yhttp/yhttp).
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ tests/test_extension.py
5
+ yhttp/ext/i18n/__init__.py
6
+ yhttp/ext/i18n/i18n.py
7
+ yhttp/ext/i18n/install.py
8
+ yhttp_i18n.egg-info/PKG-INFO
9
+ yhttp_i18n.egg-info/SOURCES.txt
10
+ yhttp_i18n.egg-info/dependency_links.txt
11
+ yhttp_i18n.egg-info/requires.txt
12
+ yhttp_i18n.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ yhttp<8,>=7.8
@@ -0,0 +1 @@
1
+ yhttp