{"id":41011436,"url":"https://github.com/ahmetbarut/php-translation","last_synced_at":"2026-01-22T09:05:24.578Z","repository":{"id":46863553,"uuid":"404135692","full_name":"ahmetbarut/php-translation","owner":"ahmetbarut","description":"A convenience package for php multilingual web applications","archived":false,"fork":false,"pushed_at":"2021-09-27T07:41:02.000Z","size":32,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-06T16:50:12.711Z","etag":null,"topics":["php","php-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/ahmetbarut.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":"2021-09-07T22:09:34.000Z","updated_at":"2022-07-07T09:36:07.000Z","dependencies_parsed_at":"2022-09-23T06:51:40.572Z","dependency_job_id":null,"html_url":"https://github.com/ahmetbarut/php-translation","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ahmetbarut/php-translation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetbarut%2Fphp-translation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetbarut%2Fphp-translation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetbarut%2Fphp-translation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetbarut%2Fphp-translation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahmetbarut","download_url":"https://codeload.github.com/ahmetbarut/php-translation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetbarut%2Fphp-translation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28659939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"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-translation"],"created_at":"2026-01-22T09:05:24.511Z","updated_at":"2026-01-22T09:05:24.569Z","avatar_url":"https://github.com/ahmetbarut.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"- [PHP Translation](#php-translation)\n  - [Install](#install)\n  - [Lifecycle](#lifecycle)\n  - [Configuration](#configuration)\n      - [Content of PHP File](#content-of-php-file)\n      - [Content of Json File](#content-of-json-file)\n      - [Content Of Database Table](#content-of-database-table)\n- [Use Of](#use-of)\n  - [Array Or Json](#array-or-json)\n  - [Database](#database)\n# PHP Translation\nIt is a php package that enables multi-language capability very easily. Also, the package accepts formats as `array`, `json` and `Database`.\n## Install \n```bash\n    composer require ahmetbarut/translation\n```\n\n## Lifecycle\n![diagram](./lifecycle.png)\n\n## Configuration\nThe directory structure of the language files should be as follows and it should return an array. The location of the directory is not important, but the content is!\n\n---\n- lang\n  - en\n    - menu.php / menu.json\n  - tr\n    - menu.php / menu.json\n  - de\n    - menu.php / menu.json\n---\n#### Content of PHP File\n```php\n    return [\n    'home' =\u003e 'Home',\n];\n```\n#### Content of Json File\n```json\n    {\n        \"home\": \"Home\",\n        \"deneme\": \"TEST\"\n    }\n```\n\n#### Content Of Database Table\nYou can change the table name as you wish. If the table name is different, you must give the table name to the `$table` parameter in the constructor of the `Translation` class.\n```sql\nCREATE TABLE translation (\n    id serial PRIMARY KEY,\n    key varchar (255),\n    value VARCHAR (255),\n    language VARCHAR(255)\n    )\n```\n\n# Use Of\n## Array Or Json\n```php\nuse ahmetbarut\\Translation\\Translation;\n\nrequire \"./vendor/autoload.php\";\n\n$translation = new Translation(__DIR__ . '/lang', 'array');\n$translation-\u003esetLocale('en');\n\ntrans('menu.home')\n```\nThe `trans` function accepts a `string` and the first word before the period represents the file, and the word after the period is the key to the requested value.\n\nThe `setLocale` method also belongs to the `Translation` class.\n\n## Database \n\n```php\nuse ahmetbarut\\Translation\\Translation;\n\nrequire \"./vendor/autoload.php\";\n\ntry {\n    $connect = new PDO('pgsql:host=localhost;dbname=translation;', 'ahmetbarut', \"\");\n}catch (PDOException $th){\n    die($th-\u003egetMessage());\n}\n\n$translation = new Translation( format: 'db', connect: $connect, table: 'translation_words');\n$translation-\u003esetLocale('en');\n\ntrans('home')\n```\nThe `trans` function does not expect `.` in this case.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmetbarut%2Fphp-translation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmetbarut%2Fphp-translation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmetbarut%2Fphp-translation/lists"}