{"id":15027159,"url":"https://github.com/teodoroleckie/translate","last_synced_at":"2026-02-02T02:31:28.340Z","repository":{"id":57070541,"uuid":"366657576","full_name":"teodoroleckie/translate","owner":"teodoroleckie","description":"⚡ Fast, powerful, scalable and customizable php translator library","archived":false,"fork":false,"pushed_at":"2021-05-20T11:21:48.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-02T17:57:02.628Z","etag":null,"topics":["php","php-8","php-translation","php-translator","php8","translate","translation","translation-files","translation-management","translations","translator"],"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/teodoroleckie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["teodoroleckie"],"custom":["https://www.paypal.com/donate?business=ZHYA2MTGA4884\u0026currency_code=USD"]}},"created_at":"2021-05-12T09:12:14.000Z","updated_at":"2023-12-07T22:34:04.000Z","dependencies_parsed_at":"2022-08-24T10:50:16.650Z","dependency_job_id":null,"html_url":"https://github.com/teodoroleckie/translate","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/teodoroleckie/translate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Ftranslate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Ftranslate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Ftranslate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Ftranslate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teodoroleckie","download_url":"https://codeload.github.com/teodoroleckie/translate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodoroleckie%2Ftranslate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29001654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T01:32:03.847Z","status":"online","status_checked_at":"2026-02-02T02:00:07.448Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["php","php-8","php-translation","php-translator","php8","translate","translation","translation-files","translation-management","translations","translator"],"created_at":"2024-09-24T20:05:52.058Z","updated_at":"2026-02-02T02:31:28.322Z","avatar_url":"https://github.com/teodoroleckie.png","language":"PHP","funding_links":["https://github.com/sponsors/teodoroleckie","https://www.paypal.com/donate?business=ZHYA2MTGA4884\u0026currency_code=USD"],"categories":[],"sub_categories":[],"readme":"### Fast, powerful, scalable and customizable php translator library\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/teodoroleckie/translate/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/teodoroleckie/translate/?branch=main)\n[![Build Status](https://scrutinizer-ci.com/g/teodoroleckie/translate/badges/build.png?b=main)](https://scrutinizer-ci.com/g/teodoroleckie/translate/build-status/main)\n[![Code Intelligence Status](https://scrutinizer-ci.com/g/teodoroleckie/translate/badges/code-intelligence.svg?b=main)](https://scrutinizer-ci.com/code-intelligence)\n[![Total Downloads](https://img.shields.io/packagist/dt/tleckie/translate.svg?style=flat-square)](https://packagist.org/packages/tleckie/translate)\n\nYou can install the package via composer:\n\n```bash\ncomposer require tleckie/translate\n```\n\n### Usage\n\nCreate an instance of the Translator class to which you will assign a loader. \nThe loader must have the directory in which the translation files are stored, \nit must also indicate the extension of the translation files.\n\n\n```php\n\u003c?php\n\nuse Tleckie\\Translate\\Loader\\ArrayLoader;\nuse Tleckie\\Translate\\Translator;\n\n$trans = new Translator(\n    new ArrayLoader('./translations/','php'),\n    'es_ES'\n);\n\n$trans-\u003etrans('hello');\n\n$trans-\u003etrans('other.value');\n\n```\nYour translations file should look like this:\n\n```php\n\u003c?php\n\nreturn [\n  'hello' =\u003e \"Hola! Bienvenido a mi sitio web!\",\n  'other.value' =\u003e \"Otro valor\",\n  .\n  .\n  .\n];\n```\n\nThe name of the file that stores the translation should look like this:\n\n```bash\n/translations/es_ES.php\n```\nThe trans() method takes multiple arguments. The first is the key of the translation \narray, it is the value that will be searched for in its corresponding file.\n\nThe second argument (optional) is an array of values to be replaced in the translated value. \nIf you want to add values to your translated text you must indicate it with \"%s\".\nNote that the number of arguments must match the number of \"%s\".\n\n```php\n\u003c?php\n\nuse Tleckie\\Translate\\Loader\\ArrayLoader;\nuse Tleckie\\Translate\\Translator;\n\n$trans = new Translator(\n    new ArrayLoader('./translations/','php'),\n    'es_ES'\n);\n\n$trans-\u003etrans('hello',['John']);\n\n```\n\nYour translations file should look like this:\n\n```php\n\u003c?php\n\nreturn [\n  'hello' =\u003e \"Hola %s! Bienvenido a mi sitio web!\"\n];\n```\n\nEven if you configure your translator to load a specific language, \nyou can also change the language at any time if you need.\n\n```php\n\u003c?php\n\nuse Tleckie\\Translate\\Loader\\ArrayLoader;\nuse Tleckie\\Translate\\Translator;\n\n$trans = new Translator(\n    new ArrayLoader('./translations/','php'),\n    'es_ES'\n);\n\n$trans-\u003etrans('hello',['John'],null, 'en_GB');\n\n```\n\nYou can create your translation files by specifying the language and country defined \nby the provided locale. You can also decide whether to use the same language for different countries.\nRegional configuration example:\n\"en_US\" and \"en_GB\"\nIn this case, you just need to create a file that has the following name:\n\n```bash\n/translations/en.php\n```\n\nIn that case the following calls will have the same result and will load the translations from the same file.\n```php\n\u003c?php\n\nuse Tleckie\\Translate\\Loader\\ArrayLoader;\nuse Tleckie\\Translate\\Translator;\n\n$trans = new Translator(\n    new ArrayLoader('./translations/','php'),\n    'es_ES'\n);\n\n$trans-\u003etrans('hello',['John'],null, 'en_GB');\n$trans-\u003etrans('hello',['John'],null, 'en_US');\n```\n\nYou can also implement your own loader to connect to your preferred data source. \nYou simply have to implement the LoaderInterface interface.\n\n\nThat's all! I hope this helps you ;)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteodoroleckie%2Ftranslate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteodoroleckie%2Ftranslate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteodoroleckie%2Ftranslate/lists"}