`_ javascript library.\n\n\nUsing translations within a library\n-----------------------------------\n\nThe easiest way to use the translations is to utilize the ``Manager`` class, which\nencapsulates the lookups and ``gettext`` methods, and which provides a way of loading\na new messages file after instantiation (allowing the language to be changed after\ninitialization).\n\nAs an example, let's say you're creating a translation-enabled library named 'mylib'.\nThe following might be used to initialize and load the translations for use. Details\nabout the \"locales registry\" can be found below.\n\n.. code-block:: python\n :name: extensions.py\n\n # import the translation library\n from morphi.messages import Manager\n from morphi.registry import default_registry\n\n # instantiate the translations manager\n translation_manager = Manager(package_name='mylib')\n\n # register the manager with the default locales registry\n default_registry.subscribe(translation_manager)\n\n # initialize shorter names for the gettext functions\n gettext = translation_manager.gettext\n lazy_gettext = translation_manager.lazy_gettext\n lazy_ngettext = translation_manager.lazy_ngettext\n ngettext = translation_manager.ngettext\n\n\nNote that, in general, this code should be executed only a single time for a given\npackage. It is recommended that this code be added to an ``extensions.py`` or similar\nfile, from which the gettext functions can be loaded as singletons.\n\n.. code-block:: python\n\n from mylib.extensions import gettext as _\n\n print(_('My translatable text'))\n\n\nFormat variables\n----------------\n\nThe gettext functions all permit additional named parameters, to be used in\nformatting the translated string. The library currently supports new-style ``.format``\ntype formatting.\n\n.. code-block:: python\n\n print(_('Hello, {name}!', name='World'))\n\n\nLocales Registry\n----------------\n\nParticularly when being used with package-specific translations, the\n``Manager`` will need to be able to be notified when the application's language\nsettings (particularly the locales) are changed, so that the correct messages\ncan be loaded and displayed. In order to simplify this notification,\n``morphi.registry.Registry`` (with a default singleton registry\nnamed ``default_registry``) can be used. Managers can then be subscribed or\nunsubscribed to the registry, which will then notify all managers when\nthe locale information has changed.\n\n.. code-block:: python\n\n from morphi.registry import default_registry as locales_registry\n\n locales_registry.locales = 'es'\n\n\nTypically, a manager should be registered with the registry immediately after\nit has been instantiated.\n\n\nJinja Environment\n-----------------\n\nIf using Jinja templates, the Jinja environment should be initialized to add the\ntranslation functions.\n\n.. code-block:: python\n\n from morphi.helpers.jinja import configure_jinja_environment\n\n configure_jinja_environment(app.jinja_env, manager)\n\n.. code-block:: jinja\n\n {{ _('Hello, world!') }}\n\n\nJavaScript translations\n-----------------------\n\nAs mentioned above, a ``compile_json`` ``distutils`` command is added by the library,\nwhich will compile the messages to a ``messages.js``-compatible JSON file. The library\ncan be initialized and used as follows\n\n.. code-block:: html\n :name: index.html\n\n \n \n\n . . .\n\n _('Hello, world!', 'mylib')
\n\n\nNote the presence of the ``find_mo_filename`` function; this function is made available\nby calling the ``configure_jinja_environment`` manager method as described above.\n\n\nInstallation\n============\n\n``morphi`` can be installed via ``pip``:\n\n.. code:: bash\n\n pip install morphi\n\nTo install for development, simply add the ``develop`` tag:\n\n.. code:: bash\n\n pip install morphi[develop]\n\n\nDevelopment\n===========\n\nTesting\n-------\n\nTesting currently uses `pytest `_:\n\n.. code:: bash\n\n pytest morphi\n\n\n\nCHANGELOG\n#########\n\nAll notable changes to this project will be documented in this file.\n\nThe format is based on `Keep a Changelog `_, and this project\nadheres to `Semantic Versioning `_.\n\nUnreleased\n==========\n\n\nv0.1.2\n======\n\n2019-02-11\n\nFix errors when using invalid user-supplied resource paths with the resource loader\n\n\nv0.1.1\n======\n\n2018-09-20\n\nFix pkg_resources support under pyinstaller\n\n\nv0.1.0\n======\n\n2018-08-22\n\nAdded\n-----\n\nAdd initial translations implementation\n\n\n",
"description_content_type": "",
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/level12/morphi",
"keywords": "",
"license": "BSD",
"maintainer": "",
"maintainer_email": "",
"name": "morphi",
"package_url": "https://pypi.org/project/morphi/",
"platform": "",
"project_url": "https://pypi.org/project/morphi/",
"project_urls": {
"Homepage": "https://github.com/level12/morphi"
},
"release_url": "https://pypi.org/project/morphi/0.1.2/",
"requires_dist": [
"Babel",
"six",
"speaklater",
"flake8 ; extra == 'develop'",
"mock ; extra == 'develop'",
"pytest ; extra == 'develop'",
"pytest-cov ; extra == 'develop'",
"tox ; extra == 'develop'",
"flake8 ; extra == 'testing'",
"mock ; extra == 'testing'",
"pytest ; extra == 'testing'",
"pytest-cov ; extra == 'testing'",
"tox ; extra == 'testing'"
],
"requires_python": "",
"summary": "i18n services for libraries and applications",
"version": "0.1.2"
},
"last_serial": 4806571,
"releases": {
"0.0.0": [
{
"comment_text": "",
"digests": {
"md5": "341326a8c6c5467aacd2220ad2340222",
"sha256": "25b058768abc90d71db5ac5660c0acd2536604b95f99853dc4e14d68ec0c5738"
},
"downloads": -1,
"filename": "morphi-0.0.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "341326a8c6c5467aacd2220ad2340222",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 14046,
"upload_time": "2018-08-15T21:49:02",
"url": "https://files.pythonhosted.org/packages/42/28/ca4a9d5b5a44d423754725ea6bd6fc46b5f9b744c81252727eae361f5019/morphi-0.0.0-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "bf6d49ea529d6dc531b44ea08940c045",
"sha256": "977a59a74d9d02e5ce038acfb3b0c001c637ac9924bc6c0111c2ea6f91196ed0"
},
"downloads": -1,
"filename": "morphi-0.0.0.tar.gz",
"has_sig": false,
"md5_digest": "bf6d49ea529d6dc531b44ea08940c045",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11468,
"upload_time": "2018-08-15T21:49:04",
"url": "https://files.pythonhosted.org/packages/c1/a2/4f1acd500aa8bcc572191e604c272267a77bbc6715f959bc99dabca86f30/morphi-0.0.0.tar.gz"
}
],
"0.1.0": [
{
"comment_text": "",
"digests": {
"md5": "2ee7d466e8456c8949d2b61ccc20509f",
"sha256": "81194172c0bbc866ed8c080be7bc137c097a7963b9f8caaa45b5ba582b11b473"
},
"downloads": -1,
"filename": "morphi-0.1.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "2ee7d466e8456c8949d2b61ccc20509f",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 14301,
"upload_time": "2018-08-22T16:33:30",
"url": "https://files.pythonhosted.org/packages/15/0e/f6bb0a5d77e609b8d5b564444bb01ed0d73040fd929fa6a6ad9525a72979/morphi-0.1.0-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "1e090436e8f303ad90ee709975710ca5",
"sha256": "f1eb7daef75e298adc3b5537364e312a4b60575da32d5ca5c11fc78b7874d98f"
},
"downloads": -1,
"filename": "morphi-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "1e090436e8f303ad90ee709975710ca5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11777,
"upload_time": "2018-08-22T16:33:33",
"url": "https://files.pythonhosted.org/packages/ea/d5/4eb9565d0ac732365cc79eefa88c30bf7eb0c2e504bae442abe74e3c6e89/morphi-0.1.0.tar.gz"
}
],
"0.1.1": [
{
"comment_text": "",
"digests": {
"md5": "400e33e039b7d72b8ee1c935e13030dd",
"sha256": "a6c64438798a0a2d19141eb11789310854881100d96c617303a62e0264ed6a1b"
},
"downloads": -1,
"filename": "morphi-0.1.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "400e33e039b7d72b8ee1c935e13030dd",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 14466,
"upload_time": "2018-09-20T23:55:53",
"url": "https://files.pythonhosted.org/packages/1a/69/7d389007d2baefa81e671f279c66bf41dbeb0f75e26b50c2a24cc0bff0b7/morphi-0.1.1-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "1d32f549b44bf7a7e1b22e6b593879e7",
"sha256": "a0ebba46766d7605c5371b003e8e9d14c196ba6da9f12756461d5bf884812f16"
},
"downloads": -1,
"filename": "morphi-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "1d32f549b44bf7a7e1b22e6b593879e7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11940,
"upload_time": "2018-09-20T23:55:55",
"url": "https://files.pythonhosted.org/packages/09/a1/070d9079f0cb8300662c7f1a1bcecdfac8f453cf09a4bbd58de032404df0/morphi-0.1.1.tar.gz"
}
],
"0.1.2": [
{
"comment_text": "",
"digests": {
"md5": "1c52e934229aaeda12a24c242046fc27",
"sha256": "0ec741a5b349f917e3923c0dbbd383ecea6eb48450f8b8285e6ff2ac70bb2a3f"
},
"downloads": -1,
"filename": "morphi-0.1.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "1c52e934229aaeda12a24c242046fc27",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 15570,
"upload_time": "2019-02-11T15:27:13",
"url": "https://files.pythonhosted.org/packages/44/cd/299a0945720699a0c1311fed6e5d7096a529b16608a067e7c5204d36295d/morphi-0.1.2-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "eb475ba6feef30636d522b050ad9c51c",
"sha256": "fa0185e72921bbb7c7b0335217b9ad895f36b8c2b890d80cd67af40f8d2be66d"
},
"downloads": -1,
"filename": "morphi-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "eb475ba6feef30636d522b050ad9c51c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 14036,
"upload_time": "2019-02-11T15:27:14",
"url": "https://files.pythonhosted.org/packages/09/8d/01604ff7c13d84b014abbcc051bf46d1bebc493108e9502c70aa21dd5e1f/morphi-0.1.2.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "1c52e934229aaeda12a24c242046fc27",
"sha256": "0ec741a5b349f917e3923c0dbbd383ecea6eb48450f8b8285e6ff2ac70bb2a3f"
},
"downloads": -1,
"filename": "morphi-0.1.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "1c52e934229aaeda12a24c242046fc27",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 15570,
"upload_time": "2019-02-11T15:27:13",
"url": "https://files.pythonhosted.org/packages/44/cd/299a0945720699a0c1311fed6e5d7096a529b16608a067e7c5204d36295d/morphi-0.1.2-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "eb475ba6feef30636d522b050ad9c51c",
"sha256": "fa0185e72921bbb7c7b0335217b9ad895f36b8c2b890d80cd67af40f8d2be66d"
},
"downloads": -1,
"filename": "morphi-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "eb475ba6feef30636d522b050ad9c51c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 14036,
"upload_time": "2019-02-11T15:27:14",
"url": "https://files.pythonhosted.org/packages/09/8d/01604ff7c13d84b014abbcc051bf46d1bebc493108e9502c70aa21dd5e1f/morphi-0.1.2.tar.gz"
}
]
}