You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-20Lines changed: 24 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,9 @@
2
2
3
3
[](https://packagist.org/packages/webard/filament-translatable)
> Be sure to set field-specific methods like `required()` or `requiredDefaultLocale()`**before** calling the `translatable()` method.
219
220
220
-
221
221
### `Translations` component
222
222
223
223
By using the `Translations` component, you can easily configure your [form fields](https://filamentphp.com/docs/4.x/forms/fields/getting-started) to support multiple languages and provide translations for each locale.
#### Setting the translatable label for a particular field
253
252
254
253
You have the flexibility to customize the translation label for each field in each locale. You can use the `fieldTranslatableLabel()` method to provide custom labels based on the field instance and the current locale.
You may add actions before each container of child components using the `actions()` method:
316
315
@@ -344,7 +343,6 @@ Translations::make()
344
343
])
345
344
```
346
345
347
-
348
346
#### Injecting the locale to form field
349
347
350
348
If you wish to access the current locale instance for the field, define a `$locale` parameter:
@@ -359,11 +357,12 @@ Translations::make()
359
357
```
360
358
361
359
#### Removing the styled container
360
+
362
361
By default, the translate component and its content are wrapped in a container styled as a card. You may remove the styled container using `contained()`:
363
362
364
363
```php
365
364
use Webard\FilamentTranslatable\Forms\Component\Translations;
366
-
365
+
367
366
Translations::make()
368
367
->contained(false)
369
368
```
@@ -374,7 +373,7 @@ You can display translations as vertical tabs:
374
373
375
374
```php
376
375
use Webard\FilamentTranslatable\Forms\Component\Translations;
377
-
376
+
378
377
Translations::make()
379
378
->vertical()
380
379
```
@@ -385,27 +384,30 @@ You can customize plugin settings directly on the component:
385
384
386
385
```php
387
386
use Webard\FilamentTranslatable\Forms\Component\Translations;
388
-
387
+
389
388
Translations::make()
390
389
->displayNamesInLocaleLabels(false)
391
390
->displayFlagsInLocaleLabels(true)
392
391
->flagWidth('48px')
393
392
```
394
393
395
-
#### Exclude
394
+
#### Exclude
395
+
396
396
The `exclude` feature allows you to specify fields that you don't want to include in the translation process. This can be useful for fields that contain dynamic content or that shouldn't be translated into other languages.
397
397
398
398
```php
399
399
use Webard\FilamentTranslatable\Forms\Component\Translations;
400
-
400
+
401
401
Translations::make('translations')
402
402
->schema([
403
403
Forms\Components\TextInput::make('title'),
404
404
Forms\Components\TextInput::make('description'),
405
405
])
406
406
->exclude(['description'])
407
407
```
408
+
408
409
Without `exclude`:
410
+
409
411
```json
410
412
{
411
413
"title": {
@@ -420,7 +422,9 @@ Without `exclude`:
420
422
}
421
423
}
422
424
```
425
+
423
426
With `exclude`:
427
+
424
428
```json
425
429
{
426
430
"title": {
@@ -431,6 +435,7 @@ With `exclude`:
431
435
"description": null
432
436
}
433
437
```
438
+
434
439
## Publishing Views
435
440
436
441
To publish the views, run:
@@ -467,4 +472,3 @@ If you discover any security-related issues, please email code@webard.me instead
467
472
## License
468
473
469
474
Filament Translatable is open-sourced software licensed under the [MIT license](LICENSE.md).
0 commit comments