{"id":23537517,"url":"https://github.com/py-package/masonite-localization","last_synced_at":"2025-04-23T14:14:47.747Z","repository":{"id":58017118,"uuid":"529667302","full_name":"py-package/masonite-localization","owner":"py-package","description":"Add multi-language support in your application.","archived":false,"fork":false,"pushed_at":"2023-09-11T03:16:48.000Z","size":115,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T14:14:47.334Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/py-package.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-27T18:33:10.000Z","updated_at":"2022-10-10T11:02:49.000Z","dependencies_parsed_at":"2024-12-26T03:16:17.289Z","dependency_job_id":"8e0878a9-3169-4bc1-beac-b0aab7d698ff","html_url":"https://github.com/py-package/masonite-localization","commit_stats":{"total_commits":19,"total_committers":2,"mean_commits":9.5,"dds":0.1578947368421053,"last_synced_commit":"e1b7f2979a00bb0f3eb78c9be78e638f952a482e"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/py-package%2Fmasonite-localization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/py-package%2Fmasonite-localization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/py-package%2Fmasonite-localization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/py-package%2Fmasonite-localization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/py-package","download_url":"https://codeload.github.com/py-package/masonite-localization/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250447979,"owners_count":21432165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-26T03:16:13.310Z","updated_at":"2025-04-23T14:14:47.727Z","avatar_url":"https://github.com/py-package.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# masonite-localization\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://banners.beyondco.de/Masonite%20Localization.png?theme=light\u0026packageManager=pip+install\u0026packageName=masonite-localization\u0026pattern=charlieBrown\u0026style=style_2\u0026description=Add+locale+support+in+your+application.\u0026md=1\u0026showWatermark=1\u0026fontSize=100px\u0026images=adjustments\u0026widths=50\u0026heights=50\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://docs.masoniteproject.com\"\u003e\n    \u003cimg alt=\"Masonite Package\" src=\"https://img.shields.io/static/v1?label=Masonite\u0026message=package\u0026labelColor=grey\u0026color=blue\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAIRlWElmTU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABIAAAAAQAAAEgAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAA6gAwAEAAAAAQAAAA4AAAAATspU+QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS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dX0zq3GjMPG5NKBtv5qiPEPekK2U51j1451BZoc3i+1ohSQ/UzzG5uYFFn2mwVUnO4O3JblXA91T51l3pB3QweDl7sNXMyEjbguSjrPcQNmwDkNc8CbCvDd0+xCC7RFi9wFulD3mJeXqxQevB4prrqgc0TmQ85NG/K43e2UwnMVAJIEBNfWRYR3HfnvivrIzMyo4Hgy+hfscvLo53jItAAAAABJRU5ErkJggg==\"\u003e\n  \u003c/a\u003e\n  \u003cimg alt=\"GitHub Workflow Status (branch)\" src=\"https://github.com/py-package/masonite-localization/actions/workflows/pythonapp.yml/badge.svg\"\u003e\n  \u003cimg src=\"https://codecov.io/gh/py-package/masonite-localization/branch/main/graph/badge.svg?token=\"/\u003e\n  \u003cimg alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/masonite-localization\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/python-3.7+-blue.svg\" alt=\"Python Version\"\u003e\n  \u003cimg alt=\"GitHub release (latest by date including pre-releases)\" src=\"https://img.shields.io/github/v/release/py-package/masonite-localization?include_prereleases\"\u003e\n  \u003cimg alt=\"License\" src=\"https://img.shields.io/github/license/py-package/masonite-localization\"\u003e\n  \u003ca href=\"https://github.com/psf/black\"\u003e\u003cimg alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Introduction\n\nAdd multi-language support in your application.\n\n## Installation\n\n```bash\npip install masonite-localization\n```\n\n## Configuration\n\nAdd LocalizationProvider to your project in `config/providers.py`:\n\n```python\n# config/providers.py\n# ...\nfrom localization import LocalizationProvider\n\n# ...\nPROVIDERS = [\n    # ...\n    # Third Party Providers\n    LocalizationProvider,\n    # ...\n]\n```\n\nThen you can publish the package resources (if needed) by doing:\n\n```bash\npython craft package:publish localization\n```\n\n## Usage\n\nThe setup is very simple. Once you publish the package verify if there's a `lang` directory in the root of your project or not, if not then create one and then create a json file named `en.json` put in some values in it or you can copy/paste following contents.\n\n```json\n{\n  \"message\": \"Hello\"\n}\n```\n\nBy default you'll have `english` language setup in `config` which you can change. The locale can be changed on the fly as well.\n\nYou can add as many language json files as you wish. For eg; if need `Japanese` locale then, I will just copy everything from `en.json` file and then create new file named `jp.json` and then update the values in those json.\n\n**Getting Current Locale**\n\n```python\nfrom localization.facades import Localization\n\n# Returns current locale\nLocalization.current_locale()\n```\n\n**Changing Locale**\n\n```python\nfrom localization.facades import Localization\n\n# Returns nothing\nLocalization.set_locale('jp')\n```\n\n**Checking if current local matches**\n\n```python\nfrom localization.facades import Localization\n\n# returns either True or False\nLocalization.is_locale('jp')\n```\n\n**Retrieving Translations in Template**\n\nImagine you have following translations in `en.json` locale file.\n\n```json\n{\n  \"message\": \"Hello, World!\",\n  \"notification\": {\n    \"message\": \"This is notification message.\"\n  }\n}\n```\n\nThen you can retrieve translation strings as below in template.\n\n```jinja\n{{ __(\"message\") }}\n\u003c!-- OR --\u003e\n{{ __(\"notification.message\") }}\n```\n\n## License\n\nmasonite-localization is open-sourced software licensed under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpy-package%2Fmasonite-localization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpy-package%2Fmasonite-localization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpy-package%2Fmasonite-localization/lists"}