{"id":17947694,"url":"https://github.com/tomasr8/messageformat2","last_synced_at":"2025-06-28T13:37:57.543Z","repository":{"id":240303724,"uuid":"796926302","full_name":"tomasr8/messageformat2","owner":"tomasr8","description":"Python implementation of the Unicode Message Format 2.0 specification","archived":false,"fork":false,"pushed_at":"2024-05-26T08:45:12.000Z","size":49,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-31T08:45:15.130Z","etag":null,"topics":["i18n","icu","internationalization","localization","messageformat","translation"],"latest_commit_sha":null,"homepage":"","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/tomasr8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2024-05-06T22:00:16.000Z","updated_at":"2025-05-07T23:35:45.000Z","dependencies_parsed_at":"2024-05-17T22:30:10.531Z","dependency_job_id":"1a046a4a-7a0f-4835-b23d-9e0ebbd47a45","html_url":"https://github.com/tomasr8/messageformat2","commit_stats":null,"previous_names":["tomasr8/messageformat2"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tomasr8/messageformat2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasr8%2Fmessageformat2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasr8%2Fmessageformat2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasr8%2Fmessageformat2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasr8%2Fmessageformat2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomasr8","download_url":"https://codeload.github.com/tomasr8/messageformat2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasr8%2Fmessageformat2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262438838,"owners_count":23311228,"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":["i18n","icu","internationalization","localization","messageformat","translation"],"created_at":"2024-10-29T08:06:28.226Z","updated_at":"2025-06-28T13:37:57.504Z","avatar_url":"https://github.com/tomasr8.png","language":"Python","readme":"\n\n# MessageFormat2 [![Documentation Status](https://readthedocs.org/projects/messageformat2/badge/?version=latest)](https://messageformat2.readthedocs.io/en/latest/?badge=latest) [![CI](https://github.com/tomasr8/messageformat2/workflows/CI/badge.svg)](https://github.com/tomasr8/messageformat2/workflows/CI/badge.svg) [![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)\n\nThis is a Python implementation of the [Unicode Message Format 2.0\nspecification](https://www.unicode.org/reports/tr35/tr35-72/tr35-messageFormat.html).\n\nMessage Format 2.0 (MF2) is a new iteration of Message Format which aims to be\nmore expressive and flexible than both Message Format 1.0 and, in the context of\nPython, gettext.\n\nIf you would like to learn more about MF2 itself head over to the [Unicode technical\nspecification](https://www.unicode.org/reports/tr35/tr35-72/tr35-messageFormat.html).\n\n## Features\n\nThe library includes:\n\n- A message parser and a formatter\n- Several builtin formatters and selectors described by the\n  [spec](https://www.unicode.org/reports/tr35/tr35-72/tr35-messageFormat.html#function-registry)\n  and the possibility to write custom formatters/selectors\n- Helper classes to inspect and transform the message [data\n  model](https://www.unicode.org/reports/tr35/tr35-72/tr35-messageFormat.html#interchange-data-model)\n\n## [Documentation](https://messageformat2.readthedocs.io/en/latest/)\n\n## Installation\n\nVia pip for Python `\u003e= 3.12`\n\n```sh\npip install messageformat2\n```\n\n## Examples\n\n### Simple messages\n\n```python\nfrom messageformat2 import format_message\n\nformat_message(\"Hello, {$name}!\", {\"name\": \"Alice\"})  # -\u003e \"Hello, Alice!\"\n```\n\nMessages can be reused with different inputs.\n\n```python\nfrom messageformat2 import Message\n\nmessage = Message(\"Hello, {$name}!\")\nmessage.format({\"name\": \"Alice\"})  # -\u003e \"Hello, Alice!\"\nmessage.format({\"name\": \"Bob\"})  # -\u003e \"Hello, Bob!\"\n```\n\n### Built-in formatters\n\nThere are several builtin locale-aware formatters available.\n\n```python\nfrom datetime import datetime\nfrom messageformat2 import Message\n\nmessage = Message(\"Today's date is {$now :date}\")\nnow = datetime.now()\nmessage.format({\"now\": now}, locale='en_US')\n# -\u003e Today's date is 5/10/2024\nmessage.format({\"now\": now}, locale='en_GB')\n# -\u003e Today's date is 10/05/2024\n```\n\n### Plural support\n\nMF2 supports pluralization using built-in or custom selectors.\n\n```python\nfrom messageformat2 import Message\n\nmsg = Message (\"\"\"\\\n.match {$count :number}\none {{You have {$count} notification.}}\n*   {{You have {$count} notifications.}}\n\"\"\")\n\nmsg.format({\"count\": 42}, locale='en_US') # -\u003e \"You have 42 notifications.\"\nmsg.format({\"count\": 1}, locale='en_US') # -\u003e \"You have 1 notification.\"\n```\n\nComplete documentation is available [here](https://messageformat2.readthedocs.io/en/latest/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasr8%2Fmessageformat2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomasr8%2Fmessageformat2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasr8%2Fmessageformat2/lists"}