{"id":26253950,"url":"https://github.com/2mal3/yet-another-i18n","last_synced_at":"2026-03-01T12:02:02.096Z","repository":{"id":271224823,"uuid":"905311641","full_name":"2mal3/yet-another-i18n","owner":"2mal3","description":"A lightweight and developer-friendly Python translation library designed for simplicity and flexibility. ","archived":false,"fork":false,"pushed_at":"2025-02-26T16:33:43.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-21T14:56:04.591Z","etag":null,"topics":["i18n","json","localization","python","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/2mal3.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2024-12-18T15:14:48.000Z","updated_at":"2025-02-26T16:33:47.000Z","dependencies_parsed_at":"2025-01-06T12:00:33.002Z","dependency_job_id":"fbf1cf16-fa1f-476d-a92d-016b9a632fec","html_url":"https://github.com/2mal3/yet-another-i18n","commit_stats":null,"previous_names":["2mal3/yet-another-i18n"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/2mal3/yet-another-i18n","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2mal3%2Fyet-another-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2mal3%2Fyet-another-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2mal3%2Fyet-another-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2mal3%2Fyet-another-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2mal3","download_url":"https://codeload.github.com/2mal3/yet-another-i18n/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2mal3%2Fyet-another-i18n/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29969243,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T11:43:06.159Z","status":"ssl_error","status_checked_at":"2026-03-01T11:43:03.887Z","response_time":124,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","json","localization","python","translation"],"created_at":"2025-03-13T18:18:46.370Z","updated_at":"2026-03-01T12:02:02.082Z","avatar_url":"https://github.com/2mal3.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yet another i18n\n\nA lightweight and developer-friendly Python translation library designed for simplicity and flexibility.\n\n## Features\n\n- 🌐 json-based translation: easy-to-use translations powered by simple JSON files.\n- 🔄 fallback language support: automatically provides translations in a fallback language when a specific translation is unavailable.\n- 🧩 nested values and placeholders: fully supports nested structures and dynamic placeholders within translations.\n- 🎛️ flexible translation styles: offers both preconfigured translations and on-the-fly translation generation.\n- 🛠️ developer experience focused api: designed with developers in mind, drawing inspiration from other projects.\n- ⚡ lightweight and simple: under 150 lines of code with no dependencies beyond Python's standard library.\n\n## Usage\n\n### 0. Installation\n\nInstall the package via pip:\n\n```bash\npip install yet-another-i18n\n```\n\n### 1. Initialization\n\nCreate a `Translator` instance by specifying at least the fallback locale.\n\n```python\nfrom yai18n import Translator\n\ntranslator = Translator(\n    fallback_locale=\"en\",\n)\n```\n\n- **fallback_locale** (required): The locale to use if the requested key is not found in any other locale.\n- **default_locale** (optional): The primary locale used when none is explicitly provided.\n- **locale_folder_path** (optional): Directory containing your JSON locale files. (default: `\"locales\"`)\n- **debug** (optional): If `True`, locale files are reloaded before each translation (useful for development).\n\n### 2. Locale Files\n\nEach locale file should be a JSON file named `\u003clocale\u003e.json` within the specified `locale_folder_path`. Example:\n\n`en.json`:\n\n```json\n{\n  \"greeting\": {\n    \"hello\": \"Hello, {name}!\"\n  }\n}\n```\n\n### 3. Translation\n\nTo translate a key, simply call the `Translator` instance:\n\n```python\nmessage = translator(\"greeting.hello\", locale=\"en\", args={\"name\": \"Alice\"})\nprint(message)  # Outputs: \"Hello, Alice!\"\n```\n\n- **key**: A string path (e.g., `\"section.subsection.key\"`) to the translated text.\n- **locale** (optional): Override the default locale for this translation.\n- **args** (optional): A dictionary to format dynamic placeholders in the translated text.\n\n### 4. Fallback Behavior\n\nIf a key does not exist in the requested locale, the translator automatically uses the `fallback_locale`.\nIf the key is not found there either, a `KeyError` is raised.\n\n### 5. Error Handling\n\n- **ValueError**: Raised if a requested locale or default locale is not found.\n- **TypeError**: Raised if arguments to methods are of incorrect types.\n- **KeyError**: Raised if a translation key cannot be found in both the given and fallback locales.\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/2mal3\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/56305732?v=4?s=100\" width=\"100px;\" alt=\"2mal3\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003e2mal3\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/2mal3/yet-another-i18n/commits?author=2mal3\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/2mal3/yet-another-i18n/commits?author=2mal3\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#platform-2mal3\" title=\"Packaging/porting to new platform\"\u003e📦\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/LuisSchuimer\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/85784931?v=4?s=100\" width=\"100px;\" alt=\"Luis Schuimer\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eLuis Schuimer\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/2mal3/yet-another-i18n/issues?q=author%3ALuisSchuimer\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e \u003ca href=\"#userTesting-LuisSchuimer\" title=\"User Testing\"\u003e📓\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/programmer-44\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/129310925?v=4?s=100\" width=\"100px;\" alt=\"E44\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eE44\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/2mal3/yet-another-i18n/commits?author=programmer-44\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#ideas-programmer-44\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2mal3%2Fyet-another-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2mal3%2Fyet-another-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2mal3%2Fyet-another-i18n/lists"}