{"id":21557057,"url":"https://github.com/elaborate-code/php-json-tongue","last_synced_at":"2025-04-10T10:24:24.766Z","repository":{"id":60017686,"uuid":"539491952","full_name":"elaborate-code/php-json-tongue","owner":"elaborate-code","description":"📦🌐 A Façade for loading localization data from a folder tree of JSON files","archived":false,"fork":false,"pushed_at":"2022-12-30T14:52:20.000Z","size":109,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-09-18T02:29:27.181Z","etag":null,"topics":["agnostic","internationalization","json","languages","library","locale","localization","php","php8","translation"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/elaborate-code/php-json-tongue","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/elaborate-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-21T13:03:50.000Z","updated_at":"2022-10-10T08:50:00.000Z","dependencies_parsed_at":"2023-01-31T11:40:12.222Z","dependency_job_id":null,"html_url":"https://github.com/elaborate-code/php-json-tongue","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elaborate-code%2Fphp-json-tongue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elaborate-code%2Fphp-json-tongue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elaborate-code%2Fphp-json-tongue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elaborate-code%2Fphp-json-tongue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elaborate-code","download_url":"https://codeload.github.com/elaborate-code/php-json-tongue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199088,"owners_count":21063641,"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":["agnostic","internationalization","json","languages","library","locale","localization","php","php8","translation"],"created_at":"2024-11-24T08:10:49.412Z","updated_at":"2025-04-10T10:24:24.735Z","avatar_url":"https://github.com/elaborate-code.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP JSON tongue\n\n[![Packagist Version](https://img.shields.io/packagist/v/elaborate-code/php-json-tongue?label=Version\u0026style=plastic)](https://packagist.org/packages/elaborate-code/php-json-tongue)\n![Packagist Downloads](https://img.shields.io/packagist/dt/elaborate-code/php-json-tongue?label=Downloads\u0026style=plastic)\n[![run-tests](https://github.com/elaborate-code/php-json-tongue/actions/workflows/run-tests.yml/badge.svg)](https://github.com/elaborate-code/php-json-tongue/actions/workflows/run-tests.yml)\n![Test Coverage](https://raw.githubusercontent.com/elaborate-code/php-json-tongue/main/badge-coverage.svg)\n[![Fix PHP code style issues](https://github.com/elaborate-code/php-json-tongue/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/elaborate-code/php-json-tongue/actions/workflows/fix-php-code-style-issues.yml)\n![maintained](https://img.shields.io/maintenance/yes/2022)\n\n\u003c!-- [![run-tests](https://github.com/elaborate-code/php-json-tongue/actions/workflows/run-tests.yml/badge.svg)](https://github.com/elaborate-code/php-json-tongue/actions/workflows/run-tests.yml) --\u003e\n\u003c!-- [![Fix PHP code style issues](https://github.com/elaborate-code/php-json-tongue/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/elaborate-code/php-json-tongue/actions/workflows/fix-php-code-style-issues.yml) --\u003e\n\nA Façade for loading localization data from a folder tree of JSON files.\n\n## Get started\n\nInstall the package with composer:\n\n```text\ncomposer require elaborate-code/php-json-tongue\n```\n\nRequirements:\n\n-   PHP 8.0 or higher\n\n## Usage\n\nSet the file structure.\n\n![illustration](illustration.png)\n\nThen use the facade.\n\n```php\nuse ElaborateCode\\JsonTongue\\TongueFacade;\n\n$tongue = new TongueFacade('/lang');\n\n$localization = $tongue-\u003etranscribe();\n```\n\n`$localization` will be set like:\n\n```php\n$localization = [\n    \"es\" =\u003e [\n        \"programmer\" =\u003e \"programador\",\n        \"interviewer\" =\u003e \"entrevistador\",\n        \"Hello\" =\u003e \"Hola\",\n        \"Good morning\" =\u003e \"buenos dias\",\n        //...\n    ],\n    \"fr\" =\u003e [\n        \"Hello\" =\u003e \"Salut\",\n        \"Good morning\" =\u003e \"Bonjour\",\n        //...\n    ]\n    //...\n];\n```\n\n## Testing\n\n```bash\nvendor/bin/pest\n```\n\n### JSON Faker\n\nJust like when testing Laravel apps, we populate the database temporarily and use the `RefreshDatabase` trait to rollback the database to its fresh state.\n\nThis package ships with `ElaborateCode\\JsonTongue\\JsonFaker\\JsonFaker` class that helps create a temporary tree of **locale folders** and **JSON files** filled with translations.\n\nHere is an example:\n\n```php\n$json_faker = JsonFaker::make()\n    -\u003eaddLocale('ar', [\n        'ar.json' =\u003e [],\n    ])\n    -\u003eaddLocale('en', [\n        'en.json' =\u003e [\n            'en' =\u003e 'en',\n            \"I know. They're both good. It's hard to decide. McCain is older but he has more experience. Obama seems to have a lot of good ideas, but some people say he wants to raise taxes.\" =\u003e 'Lo sé. Ambos son buenos. Es difícil decidir. McCain es mayor pero tiene más experiencia. Obama parece tener muchas buenas ideas, pero algunas personas dicen que quiere aumentar los impuestos.',\n        ],\n        'one.json' =\u003e [\n            'one' =\u003e 'one',\n        ],\n        'two.json' =\u003e [\n            'two' =\u003e 'two',\n        ],\n    ])\n    -\u003eaddLocale('multi', [\n        'greetings.json' =\u003e [\n            'en' =\u003e [\n                'Hello' =\u003e 'Hello',\n            ],\n            'fr' =\u003e [\n                'Hello' =\u003e 'Salut',\n            ],\n        ],\n    ])\n    -\u003ewrite();\n\n// Assert\n\n$json_faker-\u003erollback(); // Delete the complete file structure created for the test\n```\n\n\u003e This class can help make tests when contributing on this package or when using this package.\n\n## Changelog\n\n\u003c!-- Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. --\u003e\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felaborate-code%2Fphp-json-tongue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felaborate-code%2Fphp-json-tongue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felaborate-code%2Fphp-json-tongue/lists"}