{"id":21259042,"url":"https://github.com/cracksalad/i18n-php","last_synced_at":"2026-03-06T07:32:06.078Z","repository":{"id":190642263,"uuid":"683128454","full_name":"cracksalad/i18n-php","owner":"cracksalad","description":"PHP library to properly handle internationalization, but in a stateless fashion - no gettext()!","archived":false,"fork":false,"pushed_at":"2024-07-13T10:33:07.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-24T21:48:05.395Z","etag":null,"topics":["i18n","php","php8","psr-15"],"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/cracksalad.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":"2023-08-25T17:05:28.000Z","updated_at":"2024-07-13T10:31:33.000Z","dependencies_parsed_at":"2023-08-25T18:46:22.988Z","dependency_job_id":"fd34fcf5-3965-47b9-9812-d3b1a52aa792","html_url":"https://github.com/cracksalad/i18n-php","commit_stats":null,"previous_names":["cracksalad/i18n-php"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/cracksalad/i18n-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cracksalad%2Fi18n-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cracksalad%2Fi18n-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cracksalad%2Fi18n-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cracksalad%2Fi18n-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cracksalad","download_url":"https://codeload.github.com/cracksalad/i18n-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cracksalad%2Fi18n-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30165625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T04:43:31.446Z","status":"ssl_error","status_checked_at":"2026-03-06T04:40:30.133Z","response_time":250,"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","php","php8","psr-15"],"created_at":"2024-11-21T04:12:11.726Z","updated_at":"2026-03-06T07:32:06.055Z","avatar_url":"https://github.com/cracksalad.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# i18n\n\n[![Latest Stable Version](https://poser.pugx.org/cracksalad/i18n/v)](https://packagist.org/packages/cracksalad/i18n)\n[![Total Downloads](https://poser.pugx.org/cracksalad/i18n/downloads)](https://packagist.org/packages/cracksalad/i18n)\n[![License](https://poser.pugx.org/cracksalad/i18n/license)](https://packagist.org/packages/cracksalad/i18n)\n[![PHP Version Require](https://poser.pugx.org/cracksalad/i18n/require/php)](https://packagist.org/packages/cracksalad/i18n)\n[![Psalm Type Coverage](https://shepherd.dev/github/cracksalad/i18n-php/coverage.svg)](https://packagist.org/packages/cracksalad/i18n)\n\nThis library depends on [php-gettext/Gettext](https://github.com/php-gettext/Gettext) and is inspired by [delight-im/PHP-I18N](https://github.com/delight-im/PHP-I18N) as well as [gettext](https://www.php.net/manual/en/function.gettext).\n\nAlthough this library is mainly compatible with delight-im/PHP-I18N, there are some differences. The main difference is that this library does not use `gettext()` and `setlocale()` but instead is stateless and thereby supports independent (concurrent) request handling as it is done with [PSR-15: HTTP Handlers](https://www.php-fig.org/psr/psr-15/) and [OpenSwoole](https://openswoole.com/). Another difference is that this library does not try to detect the users language based on the domain and path of the current URL or on some cookie.\n\n## Installation\n\nNOTE: This library requires PHP 8.0+\n\n```bash\ncomposer require cracksalad/i18n\n```\n\n## Usage\n\nFirst you need to create translation files (e.g. using `xgettext` in bash) in a folder structure like this:\n\n```\nlocale/\n├─ en/\n│  ├─ LC_MESSAGES/\n│  │  ├─ messages.mo\n│  │  ├─ messages.po\n├─ de/\n│  ├─ LC_MESSAGES/\n│  │  ├─ messages.mo\n│  │  ├─ messages.po\n```\n\n```php\nuse Cracksalad\\I18n\\I18n;\n\n$i18n = I18n::load('en');\n\n$i18n-\u003e_('Hello world!');       \n// -\u003e Hello world!\n\n// format (using sprintf() internally)\n$i18n-\u003e_f('%d items saved', 42);      \n// -\u003e 42 items saved\n\n// ICU MessageFormat\n$i18n-\u003e_fe('I first published this library on {0, date, short}', 1692982322);\n// -\u003e I first published this library on 8/23/23\n\n// singular vs. plural with format\n$i18n-\u003e_pf('%d item saved', '%d items saved', 42);\n// -\u003e 42 items saved\n$i18n-\u003e_pf('%d item saved', '%d items saved', 1);\n// -\u003e 1 item saved\n```\n\n## License\n\nThis library is licensed under the MIT License (MIT). Please see [LICENSE](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcracksalad%2Fi18n-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcracksalad%2Fi18n-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcracksalad%2Fi18n-php/lists"}