NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

name, description and slug are per-locale JSON maps via the in-package Concerns\HasTranslations trait — no third-party dependency. Reading resolves the active locale, then fallback_locale, then any stored value:

$ad->setTranslation('name', 'de', 'Vintage Fahrrad')->save();

app()->setLocale('de');
$ad->name;                          // "Vintage Fahrrad"
$ad->getTranslation('name', 'en');  // "Vintage Bike"
$ad->getTranslations('name');       // ['en' => 'Vintage Bike', 'de' => 'Vintage Fahrrad']

Assigning a bare string ($ad->name = 'Bike') stores it under the current locale, so single-locale code keeps working. When neither the active nor the fallback locale has a value, the lowest-sorted locale wins — the same result on PostgreSQL, MySQL and SQLite.

Full API

$ad->setTranslations('description', ['en' => 'Lightly used.', 'sk' => 'Málo používaný.'])->save();
$ad->hasTranslation('name', 'sk');              // bool — exact locale, no fallback
$ad->forgetTranslation('name', 'de')->save();

$ad->name = 'Road bike';                        // stored under the active locale only
  • getTranslation($attribute, ?$locale) — one locale, with the fallback chain.
  • getTranslations($attribute) — the whole locale => value map.
  • setTranslation() / setTranslations() — write one locale or replace the map; both chain.
  • forgetTranslation() — drop one locale.
  • hasTranslation($attribute, ?$locale) — whether that exact locale has a value.

Placements and categories translate their name the same way. A new locale in an ad’s name also gets its own slug (see Slugs & routing).

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.