{"id":19273793,"url":"https://github.com/delfimov/translate","last_synced_at":"2025-04-21T22:33:13.960Z","repository":{"id":2361551,"uuid":"3325239","full_name":"delfimov/Translate","owner":"delfimov","description":"PHP translation library","archived":false,"fork":false,"pushed_at":"2023-06-21T19:13:43.000Z","size":104,"stargazers_count":16,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T15:57:29.950Z","etag":null,"topics":["i18n","multi-language","php","plural","plurals","psr-3","psr-6","translate","translation"],"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/delfimov.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":"2012-02-01T13:58:26.000Z","updated_at":"2023-05-29T04:42:36.000Z","dependencies_parsed_at":"2024-06-19T13:20:27.647Z","dependency_job_id":"7f95236c-3c38-4c5f-8628-c922555acb90","html_url":"https://github.com/delfimov/Translate","commit_stats":{"total_commits":45,"total_committers":4,"mean_commits":11.25,"dds":"0.37777777777777777","last_synced_commit":"e38f1cbbb0ee06cefe1180de25887be3330a0462"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delfimov%2FTranslate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delfimov%2FTranslate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delfimov%2FTranslate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delfimov%2FTranslate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/delfimov","download_url":"https://codeload.github.com/delfimov/Translate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250145129,"owners_count":21382353,"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","multi-language","php","plural","plurals","psr-3","psr-6","translate","translation"],"created_at":"2024-11-09T20:44:07.488Z","updated_at":"2025-04-21T22:33:08.941Z","avatar_url":"https://github.com/delfimov.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/delfimov/translate/v/stable)](https://packagist.org/packages/delfimov/translate)\n[![Build Status](https://travis-ci.org/delfimov/Translate.svg?branch=master)](https://travis-ci.org/delfimov/Translate)\n[![StyleCI](https://styleci.io/repos/3325239/shield?branch=master)](https://styleci.io/repos/3325239)\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/26b7cfce-3636-4385-be29-54f51b6dfe42/mini.png)](https://insight.sensiolabs.com/projects/26b7cfce-3636-4385-be29-54f51b6dfe42)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/delfimov/GDImage/blob/master/LICENSE)\n\n\n# Translate\n\nEasy to use i18n translation PHP class for multi-language websites \nwith language auto detection and plurals.\n\nPSR-6 translation containers. PSR-3 logger.\n\n## Requirements\n\n * [PHP \u003e= 5.6](http://www.php.net/)\n\n## How to install\n\nAdd this line to your composer.json file:\n\n```json\n\"delfimov/translate\": \"~2.0\"\n```\n\nor\n\n```sh\ncomposer require delfimov/translate\n```\n\nAlternatively, copy the contents of the Translate folder into one of \nyour project's directories and `require 'src/Translate.php';`, \n`require 'src/Loader/LoaderInterface.php';`, `require 'src/Loader/PhpFilesLoader.php';`\nIf you don't speak git or just want a tarball, click the 'zip' button \nat the top of the page in GitHub.\n\n## A Simple Example\n\nSee [`example`](example) directory for sources.\n\n`example\\example.php`\n```php\n\u003cpre\u003e\u003c?php\n\nuse DElfimov\\Translate\\Translate;\nuse DElfimov\\Translate\\Loader\\PhpFilesLoader;\nuse Monolog\\Logger; // PSR-3 logger, not required  \nuse Monolog\\Handler\\StreamHandler;\n\n$log = new Logger('Translate');\n$log-\u003epushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));\n\n$t = new Translate(\n    new PhpFilesLoader(__DIR__ . \"/messages\"),\n    [\n        \"default\" =\u003e \"en\",\n        \"available\" =\u003e [\"en\", \"ru\"],\n    ],\n    $log // optional\n);\n\n$num = rand(0, 100);\n\n$t-\u003esetLanguage(\"en\"); // this is not required, language will be auto detected with Accept-Language HTTP header\necho $t-\u003et('some string') . \"\\n\\n\"; // or $t('some string');\necho $t-\u003eplural('%d liters', $num) . \"\\n\\n\";\necho $t-\u003eplural(\"The %s contains %d monkeys\", $num, ['tree', $num]) . \"\\n\\n\";\n\n$num = rand(0, 100);\n\n$t-\u003esetLanguage(\"ru\");\necho $t-\u003et('some string').\"\\n\\n\"; // or $t('some string');\necho $t-\u003eplural('%d liters', $num) . \"\\n\\n\";\necho $t-\u003eplural(\"The %s contains %d monkeys\", $num, ['tree', $num]) . \"\\n\\n\";\n\n?\u003e\u003c/pre\u003e\n```\n\n`example\\messages\\en\\messages.php`\n```php\n\u003c?php\nreturn [\n    'some string' =\u003e 'Some string',\n    '%d liters' =\u003e ['%d liter', '%d liters'],\n    '%d liters alt' =\u003e '%d liter|%d liters',\n    'The %s contains %d monkeys' =\u003e ['The %s contains %d monkey', 'The %s contains %d monkeys'],\n    'The %s contains %d monkeys alt' =\u003e 'The %s contains %d monkey|The %s contains %d monkeys',\n];\n```\n\n`example\\messages\\ru\\messages.php`\n```php\n\u003c?php\nreturn [\n    'some string' =\u003e 'Просто строка',\n    '%d liters' =\u003e '%d литр|%d литра|%d литров',\n    'The %s contains %d monkeys' =\u003e ['На %s сидит %d обезьяна', 'На %s сидят %d обезьяны', 'На %s сидят %d обезьян'],\n    'The %s contains %d monkeys alt' =\u003e 'На %s сидит %d обезьяна|На %s сидят %d обезьяны|На %s сидят %d обезьян',\n    'tree' =\u003e 'дереве'\n];\n```\n\n## TODO\n\n * Better code coverage\n \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelfimov%2Ftranslate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdelfimov%2Ftranslate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelfimov%2Ftranslate/lists"}