{"id":37002100,"url":"https://github.com/someson/phalcon-i18n","last_synced_at":"2026-01-14T00:27:37.931Z","repository":{"id":57679677,"uuid":"370123443","full_name":"someson/phalcon-i18n","owner":"someson","description":"Extended translation module","archived":false,"fork":false,"pushed_at":"2024-10-29T18:14:27.000Z","size":61,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"5.0","last_synced_at":"2025-10-28T17:30:31.384Z","etag":null,"topics":["i18n","internationalization","phalcon","phalcon3","phalcon4","phalcon5","php","translations"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/someson.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}},"created_at":"2021-05-23T18:05:32.000Z","updated_at":"2024-10-29T18:01:52.000Z","dependencies_parsed_at":"2023-01-31T19:15:42.271Z","dependency_job_id":null,"html_url":"https://github.com/someson/phalcon-i18n","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/someson/phalcon-i18n","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someson%2Fphalcon-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someson%2Fphalcon-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someson%2Fphalcon-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someson%2Fphalcon-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/someson","download_url":"https://codeload.github.com/someson/phalcon-i18n/tar.gz/refs/heads/5.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someson%2Fphalcon-i18n/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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","internationalization","phalcon","phalcon3","phalcon4","phalcon5","php","translations"],"created_at":"2026-01-14T00:27:35.159Z","updated_at":"2026-01-14T00:27:37.917Z","avatar_url":"https://github.com/someson.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multi-lingual Support\n\n![GitHub License](https://img.shields.io/github/license/someson/phalcon-i18n)\n[![CircleCI](https://circleci.com/gh/someson/phalcon-i18n/tree/5.0.svg?style=shield)](https://circleci.com/gh/someson/phalcon-i18n/tree/circleci-project-setup)\n[![codecov](https://codecov.io/gh/someson/phalcon-i18n/branch/5.0/graph/badge.svg?token=AW5T4WU56Q)](https://codecov.io/gh/someson/phalcon-i18n)\n![Packagist Version (including pre-releases)](https://img.shields.io/packagist/v/someson/phalcon-i18n)\n[![Made in Ukraine](https://img.shields.io/badge/made_in-ukraine-ffd700.svg?labelColor=0057b7)](https://supportukrainenow.org/)\n[![Russian Warship Go Fuck Yourself](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/RussianWarship.svg)](https://stand-with-ukraine.pp.ua)\n\nExtending [Phalcon Framework v5 Translations Module](https://docs.phalcon.io/5.0/en/translate)\n\n## Install\n\n```bash\n$ composer require someson/phalcon-i18n\n```\n\n## Example\n\ne.g. `login.json` File:\n```json\n{\n    \"form\": {\n        \"label\": {\n            \"identity\": \"Benutzername\",\n            \"password\": \"Passwort\",\n            \"rememberMe\": \"Ich möchte angemeldet bleiben\"\n        },\n        \"placeholder\": {\n            \"identity\": \"Bitte geben Sie ihren Benutzernamen ein\",\n            \"password\": \"Bitte geben Sie ihr Passwort ein\"\n        },\n        \"button\": \"Anmelden\"\n    },\n    \"title\": {\n        \"h1\": \"Main Title\",\n        \"h2\": \"some subtitle\"\n    }\n}\n```\ntranslating path like `login:form.label.identity` returns `Benutzername`\n\nwhich start with `login:` means file name and the rest of it is a pure json path.\n\n## Usage\n\n### 1. Simple usage\n```php\n// component using a singleton pattern, so we can instantiate it before the framework itself\n// or wrap it into some global function\n$t = \\Phalcon\\I18n\\Translator::instance();\n\n// using the \"de\" directory, \"en\" by default\n$t-\u003esetLang('de');\n\n// equal to \"global:a\", hence \"global\" is a default scope\necho $t-\u003e_('a');\n\n// placeholder \"key\" replaced through \"value\"\necho $t-\u003e_('b', ['key' =\u003e 'value']);\n\n// nested key\necho $t-\u003e_('c.d.e', ['key' =\u003e 'value']);\n\n// nested key from the \"api\" scope (filename === scope, if files used)\necho $t-\u003e_('api:c.d.e', ['key' =\u003e 'value']);\n```\n\n### 2. Advanced usage\nin any bootstrap file (i.e. `index.php`) define:\n```php\nuse \\Phalcon\\I18n\\Translator;\n\nif (! function_exists('__')) {\n    function __(string $key, array $params = [], bool $pluralize = true): string {\n        return $key ? Translator::instance()-\u003e_($key, $params, $pluralize) : '[TRANSLATION ERROR]';\n    }\n}\n```\n\ninside your code:\n```php\n$translation = __('a.b.c');\n```\nor in any view:\n```html\n\u003ch1\u003e\u003c?= __('a.b.c') ?\u003e\u003c/h1\u003e\n```\n```twig\n\u003ch1\u003e{{ __('a.b.c') }}\u003c/h1\u003e\n```\n\n## Configure\n\ndefault config `\\Phalcon\\I18n\\Config\\Default.php`:\n\n```php\nreturn [\n    'defaultLang' =\u003e 'en',\n    'defaultScope' =\u003e 'global',\n\n    // loads data from chosen source (e.g. Json) by chosen loader (e.g. Files)\n    // can be e.g. \"Mysql\" by \"Database\" (feel free to implement)\n    'loader' =\u003e [\n        'className' =\u003e \\Phalcon\\I18n\\Loader\\Files::class,\n        'arguments' =\u003e ['path' =\u003e $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'locale'],\n    ],\n\n    // reads the source and translates it into chosen type of handler (@see key \"handler\")\n    'adapter' =\u003e [\n        'className' =\u003e \\Phalcon\\I18n\\Adapter\\Json::class,\n    ],\n\n    // implements \\Phalcon\\Translate\\AdapterInterface\n    // returns an object of all translations of the specific language\n    // provides functionality for placeholder replacing\n    'handler' =\u003e [\n        'options' =\u003e [\n            'flatten' =\u003e ['shift' =\u003e 1],\n        ],\n    ],\n\n    // replaces user-defined (or '%' by default) placeholders\n    'interpolator' =\u003e [\n        'className' =\u003e \\Phalcon\\I18n\\Interpolator\\AssocArray::class,\n        'arguments' =\u003e ['{{', '}}'],\n    ],\n\n    // bool only\n    'collectMissingTranslations' =\u003e true,\n\n    // - false\n    // - sprintf pattern e.g. [# %s #]\n    // - \\Phalcon\\I18n\\Interfaces\\DecoratorInterface object\n    'decorateMissingTranslations' =\u003e new \\Phalcon\\I18n\\Decorator\\HtmlCode,\n];\n```\nyou may want to override it with your own config (by default used in `config` container having `i18n` scope):\n```php\nreturn [\n    // ...\n\n    'i18n' =\u003e [\n        'loader' =\u003e [\n            'arguments' =\u003e ['path' =\u003e '/my/own/path/to/locale/'],\n        ],\n        'interpolator' =\u003e [\n            'arguments' =\u003e ['[[', ']]'],\n        ],\n        'collectMissingTranslations' =\u003e false,\n        'decorateMissingTranslations' =\u003e '[# %s #]',\n    ],\n\n    // ...\n];\n```\n\n## Running Tests\n\n[Codeception](https://codeception.com/) used\n\n```\n$ docker-compose exec i18n ./vendor/bin/codecept build\n```\n\nTo run tests, run the following command:\n```\n$ docker-compose exec i18n ./vendor/bin/codecept run [-vv]\n```\n\nFor code coverage info run\n```\n$ docker-compose exec i18n ./vendor/bin/codecept run --coverage --coverage-html\n```\nand open `tests/_output/coverage/index.html` in your browser\n\n### Static analyzer\n\n`$ docker-compose exec i18n ./vendor/bin/phpstan analyse src --level max`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomeson%2Fphalcon-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsomeson%2Fphalcon-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomeson%2Fphalcon-i18n/lists"}