{"id":13790725,"url":"https://github.com/kongulov/nova-tab-translatable","last_synced_at":"2025-05-16T18:10:08.231Z","repository":{"id":39891979,"uuid":"286453235","full_name":"kongulov/nova-tab-translatable","owner":"kongulov","description":"This package contains a NovaTabTranslatable class you can use to make any Nova field type translatable with tabs.","archived":false,"fork":false,"pushed_at":"2025-04-21T13:43:38.000Z","size":455,"stargazers_count":79,"open_issues_count":10,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-21T14:16:56.003Z","etag":null,"topics":["laravel","laravel-nova","nova","tabs","translatable"],"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/kongulov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":"kongulov","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"custom":null}},"created_at":"2020-08-10T11:12:50.000Z","updated_at":"2025-04-21T13:40:49.000Z","dependencies_parsed_at":"2024-06-19T17:12:47.572Z","dependency_job_id":"637a7191-c89f-4762-b0ac-7a7aecfabe19","html_url":"https://github.com/kongulov/nova-tab-translatable","commit_stats":{"total_commits":54,"total_committers":5,"mean_commits":10.8,"dds":"0.35185185185185186","last_synced_commit":"a54c963a848ec5ed857e610a6de714c0fbfb6ce2"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kongulov%2Fnova-tab-translatable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kongulov%2Fnova-tab-translatable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kongulov%2Fnova-tab-translatable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kongulov%2Fnova-tab-translatable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kongulov","download_url":"https://codeload.github.com/kongulov/nova-tab-translatable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254582907,"owners_count":22095518,"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":["laravel","laravel-nova","nova","tabs","translatable"],"created_at":"2024-08-03T22:00:50.552Z","updated_at":"2025-05-16T18:10:08.209Z","avatar_url":"https://github.com/kongulov.png","language":"PHP","funding_links":["https://github.com/sponsors/kongulov"],"categories":["Packages"],"sub_categories":[],"readme":"# Making Laravel Nova Tab Translatable Nova 5 ready\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/kongulov/nova-tab-translatable?style=flat-square)](https://packagist.org/packages/kongulov/nova-tab-translatable)\n![Licence](https://img.shields.io/github/license/kongulov/nova-tab-translatable?style=flat-square)\n[![Total Downloads](https://poser.pugx.org/kongulov/nova-tab-translatable/downloads?format=flat-square)](https://packagist.org/packages/kongulov/nova-tab-translatable)\n\n\nThis package contains a `NovaTabTranslatable` class you can use to make any Nova field type translatable with tabs. Use the master branch for Nova 5 and the 1.x branch for Nova 4.\n\nImagine you have this `fields` method in a Post Nova resource:\n\n```php\nuse Kongulov\\NovaTabTranslatable\\NovaTabTranslatable;\n\n...\n\npublic function fields(Request $request)\n{\n    return [\n        ID::make()-\u003esortable(),\n\n        NovaTabTranslatable::make([\n            SluggableText::make('Title')-\u003eslug('Slug'),\n            Slug::make('Slug')-\u003ereadonly(),\n            Trix::make('text'),\n            Text::make('Keywords'),\n            Text::make('Description'),\n        ]),\n    ];\n}\n```\n\nThat Post Nova resource will be rendered like this.\n\n![screenshot](https://kongulov.github.io/sitescreenshots/kongulov_nova-tab-translatable_1.png?v=4)\n![screenshot](https://kongulov.github.io/sitescreenshots/kongulov_nova-tab-translatable_2.png?v=4)\n\n## Requirements\n\n- `php: \u003e=7.1.0`\n- `spatie/laravel-translatable: ^4.0`\n\n## Installation\n\nInstall the package in a Laravel Nova project via Composer:\n\n```bash\n# Install nova-tab-translatable\ncomposer require kongulov/nova-tab-translatable\n\n# Publish configuration\nphp artisan vendor:publish --tag=\"tab-translatable-config\"\n```\n\nThis is the contents of the file which will be published at `config/tab-translatable.php`\n```php\n\u003c?php\n\nreturn [\n    /*\n     * The source of supported locales on the application\n     * Available selection \"array\", \"database\". Default array\n     */\n    'source' =\u003e 'array',\n\n    /*\n     * If you choose array selection, you should add all supported translation on it as \"code\"\n     */\n    'locales' =\u003e [\n        'en', 'fr', 'es'\n    ],\n\n    /*\n     * If you choose database selection, you should choose the model responsible for retrieving supported translations\n     * And choose the 'code_field' for example \"en\", \"fr\", \"es\"...\n     */\n    'database' =\u003e [\n        'model' =\u003e 'App\\\\Models\\\\Language',\n        'code_field' =\u003e 'lang',\n        'sort_by' =\u003e 'id',\n        'sort_direction' =\u003e 'asc'\n    ],\n\n    /*\n     * If you want to save the tab in the last selected language for the whole project, set this \"true\".\n     * But if you want to use in one place call the saveLastSelectedLang(true|false) method\n     */\n    'save_last_selected_lang' =\u003e false,\n];\n```\n\n## Usage\n\nYou must prepare your model [as explained](https://github.com/spatie/laravel-translatable#making-a-model-translatable) in the readme of laravel-translatable. In short: you must add `json` columns to your model's table for each field you want to translate. Your model must use the `Spatie\\Translatable\\HasTranslations` on your model. Finally, you must also add a `$translatable` property on your model that holds an array with the translatable attribute names.\n\nNow that your model is configured for translations, you can use `NovaTabTranslatable` in the related Nova resource. Any fields you want to display in a multilingual way can be passed as an array to `NovaTabTranslatable`. \n\n```php\n\nuse Kongulov\\NovaTabTranslatable\\NovaTabTranslatable;\n\n...\n\npublic function fields(Request $request)\n{\n    return [\n        ID::make()-\u003esortable(),\n\n        NovaTabTranslatable::make([\n            SluggableText::make('Title')-\u003eslug('Slug'),\n            Slug::make('Slug')-\u003ereadonly(),\n            Trix::make('text'),\n            Text::make('Keywords'),\n            Text::make('Description'),\n        ]),\n    ];\n}\n```\n\nIf you want to make the field required only in certain languages, then you can use the `required_lang` rule,\n\n```php\nNovaTabTranslatable::make([\n    Text::make('Title')-\u003erules('required_lang:en,fr'),\n    Trix::make('text')-\u003erules('required_lang:en,fr'),\n    Text::make('Keywords'),\n    Text::make('Description'),\n]),\n```\n\nBut if you want to make the field required in all languages, then use the laravel rules\n```php\nNovaTabTranslatable::make([\n    Text::make('Title')-\u003erules('required'),\n]),\n```\n\n* Replace field name\n```php\nNovaTabTranslatable::make([\n    Text::make('Title')-\u003erules('required'),\n])-\u003esetTitle('Own Title'),\n```\n\n* If you want to save the tab in the last selected language, call the `saveLastSelectedLang()` method or in the config replace `'save_last_selected_lang' =\u003e false` with `'save_last_selected_lang' =\u003e true`\n```php\nNovaTabTranslatable::make([\n    Text::make('Title'),\n])-\u003esaveLastSelectedLang(true|false),\n```\n\n* If on the index and detail pages you want to turn off the tab and show it each as a row, use trait `TranslatableTabToRowTrait` in your resource\n```php\nclass YourResource extends Resource\n{\n    use TranslatableTabToRowTrait;\n    ...\n}\n```\n\n## Credits\n\n- [Ramiz Kongulov](https://github.com/kongulov)\n\n## License\n\nThis project is open-sourced software licensed under the [MIT license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkongulov%2Fnova-tab-translatable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkongulov%2Fnova-tab-translatable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkongulov%2Fnova-tab-translatable/lists"}