Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yoeriboven authored and freekmurze committed Mar 19, 2023
1 parent 80f1917 commit f472fba
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/basic-usage/handling-missing-translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,22 @@ Translatable::fallback(missingKeyCallback: function (
return MyRemoteTranslationService::getAutomaticTranslation($fallbackTranslation, $fallbackLocale, $locale);
});
```

### Disabling fallbacks on a per model basis
By default, a fallback will be used when you access a non-existent translation attribute.

You can disable fallbacks on a model with the `$useFallbackLocale` property.

```php
use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;

class NewsItem extends Model
{
use HasTranslations;

public $translatable = ['name'];

protected $useFallbackLocale = false;
}
```

0 comments on commit f472fba

Please sign in to comment.