{"id":17922716,"url":"https://github.com/overtrue/translator","last_synced_at":"2025-10-09T10:10:50.680Z","repository":{"id":20799650,"uuid":"24084995","full_name":"overtrue/translator","owner":"overtrue","description":"PHP多语言支持工具","archived":false,"fork":false,"pushed_at":"2019-07-15T06:52:11.000Z","size":9,"stargazers_count":38,"open_issues_count":0,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T20:09:33.754Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/overtrue.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":"2014-09-16T04:11:02.000Z","updated_at":"2023-12-23T10:21:56.000Z","dependencies_parsed_at":"2022-07-12T15:17:54.694Z","dependency_job_id":null,"html_url":"https://github.com/overtrue/translator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/overtrue/translator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Ftranslator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Ftranslator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Ftranslator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Ftranslator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/overtrue","download_url":"https://codeload.github.com/overtrue/translator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Ftranslator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001323,"owners_count":26083040,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"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":[],"created_at":"2024-10-28T20:40:35.083Z","updated_at":"2025-10-09T10:10:50.661Z","avatar_url":"https://github.com/overtrue.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Translator\n==========\n\nPHP多语言支持工具\n\n## Usage\n 1. 目录结构举例：\n\n```shell\n app/\n |-- i18n/\n |    |-- zh_CN/\n |    |    |-- all.php   # return array('key' =\u003e 'pattern');\n |    |-- en_US/\n ...\n```\n\n 2. 在字符串中使用变量:\n\n```php\n //app/i18n/en_US/all.php\n \u003c?php\n return array(\n    // key =\u003e pattern\n    'user_not_exists' =\u003e 'user {name} not exists.',\n    ...\n );\n ```\n\n 3. 使用Translator:\n\n```php\n \u003c?php\n \n require 'path/to/Overtrue/Translator.php';\n\n use Overtrue\\Translator;\n\n $translator = new Translator($appPath . '/i18n', 'zh_CN');//new Translator(语言包目录, 当前语言名)\n\n //格式化语言包里的key\n $username = 'overtrue';\n echo $translator-\u003etrans('user_not_exists.', ['name' =\u003e $username]);\n // output: 'user overtrue not exists.'\n\n //格式化指定的字符串：\n echo $translator-\u003eformat('user {name} not exists.', ['name' =\u003e $username]);\n // output: 'user overtrue not exists.'\n\n```\n\n## PHP 扩展包开发\n\n\u003e 想知道如何从零开始构建 PHP 扩展包？\n\u003e\n\u003e 请关注我的实战课程，我会在此课程中分享一些扩展开发经验 —— [《PHP 扩展包实战教程 - 从入门到发布》](https://learnku.com/courses/creating-package)\n\n##License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovertrue%2Ftranslator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovertrue%2Ftranslator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovertrue%2Ftranslator/lists"}