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

All of the package’s own exceptions extend TranslatableException, so you can catch the whole family with the base class. Only a misconfigured setting throws the toolkit’s InvalidConfigurationException instead:

ExceptionThrown when
TranslatableExceptionBase class (a RuntimeException). Thrown directly when a locale map can’t be JSON-encoded (e.g. invalid UTF-8) or a search field isn’t a plain identifier.
NotATranslatableAttributeExceptionA translation method or scope was called for an attribute not listed in $translatable.
InvalidLocaleExceptionA locale key on a write path, a scope or Translatable::ensureLocale() is malformed — or isn’t supported while strict_locales (or strict: true) is on.
InvalidTranslationValueExceptionA value isn’t a string, int or float — a nested array, object or boolean.
RoundlyConsulting\PackageToolkit\Exceptions\InvalidConfigurationExceptionA config value is unusable — fallback outside none/fallback/any, strict_locales outside the boolean words, a malformed fallback_locale, or locales that isn’t a list of well-formed locale keys. The message names the key.
use RoundlyConsulting\Translatable\Exceptions\InvalidLocaleException;
use RoundlyConsulting\Translatable\Exceptions\TranslatableException;

try {
    $topic->setTranslations('name', $payload);
} catch (InvalidLocaleException $e) {
    // malformed key, or an unsupported locale while strict_locales is on
} catch (TranslatableException $e) {
    // any other package error
}

To avoid write-path exceptions from user input altogether, normalise request maps with Translatable::fromInput() or validate them with Translatable::rules() first (see Input and validation). A single locale from a query parameter or route segment goes through Translatable::ensureLocale() or Translatable::isSupported().

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.