{"id":19074922,"url":"https://github.com/mguinea/laravel-translatable","last_synced_at":"2026-01-18T13:28:39.542Z","repository":{"id":250363483,"uuid":"831862192","full_name":"mguinea/laravel-translatable","owner":"mguinea","description":"Make Eloquent model attributes translatables using Translations table","archived":false,"fork":false,"pushed_at":"2024-07-30T09:29:13.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T09:31:58.279Z","etag":null,"topics":["languages","laravel","locale","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/mguinea.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-21T20:35:20.000Z","updated_at":"2024-07-30T09:29:17.000Z","dependencies_parsed_at":"2024-07-30T12:11:14.116Z","dependency_job_id":"dce56d47-a8dd-4aa9-afd9-7966ee9d11a2","html_url":"https://github.com/mguinea/laravel-translatable","commit_stats":null,"previous_names":["mguinea/laravel-translatable"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mguinea/laravel-translatable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguinea%2Flaravel-translatable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguinea%2Flaravel-translatable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguinea%2Flaravel-translatable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguinea%2Flaravel-translatable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mguinea","download_url":"https://codeload.github.com/mguinea/laravel-translatable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguinea%2Flaravel-translatable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28536753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T13:04:05.990Z","status":"ssl_error","status_checked_at":"2026-01-18T13:01:44.092Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["languages","laravel","locale","translation"],"created_at":"2024-11-09T01:52:48.739Z","updated_at":"2026-01-18T13:28:39.524Z","avatar_url":"https://github.com/mguinea.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Translatable\n\nMake Eloquent model attributes translatables using Translations table\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Laravel 11.x](https://img.shields.io/badge/Laravel-11.x-orange.svg)](http://laravel.com)\n\nThis package contains a trait to make Eloquent attributes translatable. Translations are stored in Translations database table.\n\nOnce the trait is installed on the model you can do these things:\n\n```php\n$customer = new Customer; // An Eloquent model\n$customer\n   -\u003esetTranslation('greeting', 'en', 'Hello')\n   -\u003esetTranslation('greeting', 'es', 'Hola')\n   -\u003esave();\n\n$customer-\u003egreeting; // Returns 'Hello' given that the current app locale is 'en'\n$customer-\u003egetTranslation('greeting', 'es'); // returns 'Hola'\n\napp()-\u003esetLocale('es');\n\n$customer-\u003egreeting; // Returns 'Hola'\n```\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require mguinea/laravel-translatable\n```\n\nIf you want to change the default model or the default tables names, you could publish the config file:\n\n```bash\nphp artisan vendor:publish --tag=translatable-config\n```\n\nYou must publish the migration file to create polymorphic and main translations tables:\n\n```bash\nphp artisan vendor:publish --tag=translatable-migrations\n```\n\n## Making a model translatable\n\nThe required steps to make a model translatable are:\n\n- First, you need to add the `Mguinea\\Translatable\\Traits\\Translatable`-trait.\n\n- Next, you should create a public static property `$translatable` which holds an array with all the names of attributes you wish to make translatable.\n\n- You have to create a field in the migration of your model type `string` and `nullable`.\n\nHere's an example of a prepared model:\n\n```php\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Mguinea\\Translatable\\Traits\\Translatable;\n\nclass NewsItem extends Model\n{\n    use Translatable;\n\n    protected $fillable = ['greeting'];\n    public static $translatable = ['greeting'];\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmguinea%2Flaravel-translatable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmguinea%2Flaravel-translatable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmguinea%2Flaravel-translatable/lists"}