Localization
Introduction
Headlines and nouns may use translation keys from your app's lang files. Storyfeed translates them when retrieving the feed, using the application's current locale. Set it for each request as described in Laravel's locale configuration; Storyfeed does not choose the reader's locale.
Translating Headlines
Define the template for each supported locale, starting with the default:
return [
// Without this line, English readers see "feed.order_placed".
'order_placed' => ':actor placed :object with :target',
];return [
'order_placed' => ':actor a passé :object auprès de :target',
];Pass the translation key to FeedHeadline::trans():
use App\Models\Order;
use Storyfeed\Facades\Story;
use Storyfeed\FeedHeadline;
Story::for(Order::class)
->verb('place')
->headline(FeedHeadline::trans('feed.order_placed'));With the locale set to French:
Translated templates keep linked tokens and optional segments. You may reorder tokens in each translation. Undefined keys are displayed as written.
anonymousHeadline() and missingHeadline() take a FeedHeadline too.
Translating Nouns
Pass a translation key to FeedNoun::trans() for a group's noun:
use App\Models\Order;
use Storyfeed\Facades\Story;
use Storyfeed\FeedNoun;
Story::for(Order::class)->fallback()->noun(FeedNoun::trans('nouns.order'));Separate singular and plural forms with a pipe:
return [
'order' => 'order|orders',
];return [
'order' => 'commande|commandes',
];See Aggregation for where nouns appear.