{"id":13624146,"url":"https://github.com/cakephp/i18n","last_synced_at":"2025-06-25T23:07:08.518Z","repository":{"id":25753453,"uuid":"29191425","full_name":"cakephp/i18n","owner":"cakephp","description":"[READ-ONLY] Provides support for message translation and localization for dates and numbers. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp","archived":false,"fork":false,"pushed_at":"2025-06-21T03:37:05.000Z","size":692,"stargazers_count":28,"open_issues_count":0,"forks_count":7,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-06-21T04:29:10.193Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cakephp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2015-01-13T13:37:44.000Z","updated_at":"2024-12-16T06:53:21.000Z","dependencies_parsed_at":"2023-01-14T03:21:04.005Z","dependency_job_id":"93a53e2b-ce41-4f44-8ef0-c83b1a444534","html_url":"https://github.com/cakephp/i18n","commit_stats":{"total_commits":553,"total_committers":65,"mean_commits":8.507692307692308,"dds":0.7522603978300181,"last_synced_commit":"1a23df063e573699f82285f513b84a9d1fefea82"},"previous_names":[],"tags_count":305,"template":false,"template_full_name":null,"purl":"pkg:github/cakephp/i18n","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fi18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fi18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fi18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fi18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cakephp","download_url":"https://codeload.github.com/cakephp/i18n/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fi18n/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261967132,"owners_count":23237663,"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":[],"created_at":"2024-08-01T21:01:39.309Z","updated_at":"2025-06-25T23:07:08.487Z","avatar_url":"https://github.com/cakephp.png","language":"PHP","readme":"[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/i18n.svg?style=flat-square)](https://packagist.org/packages/cakephp/i18n)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE.txt)\n\n# CakePHP Internationalization Library\n\nThe I18n library provides a `I18n` service locator that can be used for setting\nthe current locale, building translation bundles and translating messages.\n\nAdditionally, it provides the `Time` and `Number` classes which can be used to\noutput dates, currencies and any numbers in the right format for the specified locale.\n\n## Usage\n\nInternally, the `I18n` class uses [Aura.Intl](https://github.com/auraphp/Aura.Intl).\nGetting familiar with it will help you understand how to build and manipulate translation bundles,\nshould you wish to create them manually instead of using the conventions this library uses.\n\n### Setting the Current Locale\n\n```php\nuse Cake\\I18n\\I18n;\n\nI18n::setLocale('en_US');\n```\n\n### Setting path to folder containing po files.\n\n```php\nuse Cake\\Core\\Configure;\n\nConfigure::write('App.paths.locales', ['/path/with/trailing/slash/']);\n```\n\nPlease refer to the [CakePHP Manual](https://book.cakephp.org/4/en/core-libraries/internationalization-and-localization.html#language-files) for details\nabout expected folder structure and file naming.\n\n### Translating a Message\n\n```php\necho __(\n    'Hi {0,string}, your balance on the {1,date} is {2,number,currency}',\n    ['Charles', '2014-01-13 11:12:00', 1354.37]\n);\n\n// Returns\nHi Charles, your balance on the Jan 13, 2014, 11:12 AM is $ 1,354.37\n```\n\n### Creating Your Own Translators\n\n```php\nuse Cake\\I18n\\I18n;\nuse Cake\\I18n\\Package;\n\nI18n::translator('animals', 'fr_FR', function () {\n    $package = new Package(\n        'default', // The formatting strategy (ICU)\n        'default', // The fallback domain\n    );\n    $package-\u003esetMessages([\n        'Dog' =\u003e 'Chien',\n        'Cat' =\u003e 'Chat',\n        'Bird' =\u003e 'Oiseau'\n        ...\n    ]);\n\n    return $package;\n});\n\nI18n::getLocale('fr_FR');\n__d('animals', 'Dog'); // Returns \"Chien\"\n```\n\n### Formatting Time\n\n```php\n$time = Time::now();\necho $time; // shows '4/20/14, 10:10 PM' for the en-US locale\n```\n\n### Formatting Numbers\n\n```php\necho Number::format(100100100);\n```\n\n```php\necho Number::currency(123456.7890, 'EUR');\n// outputs €123,456.79\n```\n\n## Documentation\n\nPlease make sure you check the [official I18n\ndocumentation](https://book.cakephp.org/4/en/core-libraries/internationalization-and-localization.html).\n\nThe [documentation for the Time\nclass](https://book.cakephp.org/4/en/core-libraries/time.html) contains\ninstructions on how to configure and output time strings for selected locales.\n\nThe [documentation for the Number\nclass](https://book.cakephp.org/4/en/core-libraries/number.html) shows how to\nuse the `Number` class for displaying numbers in specific locales.\n","funding_links":[],"categories":["国际化和本地化 Internationalisation and Localisation","目录","Table of Contents","PHP","国际化和本地化(Internationalisation and Localisation)"],"sub_categories":["国际化和本土化 Internationalisation and Localisation","Internationalisation and Localisation"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcakephp%2Fi18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcakephp%2Fi18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcakephp%2Fi18n/lists"}