Skip to content

Commit

Permalink
Set the app locale to the sites lang (#4715)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcorieser authored Nov 12, 2021
1 parent c322825 commit be11b59
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Http/Middleware/Localize.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ public function handle($request, Closure $next)
// installed on your actual server. You can check by running `locale -a`).
setlocale(LC_TIME, $site->locale());

// The short locale is used for your translations. (eg. if you set your site's locale
// to "fr_FR", the translator will look for "fr" files rather than "fr_FR" files.)
app()->setLocale($site->shortLocale());
// The sites lang is used for your translations. (eg. if you set your site's lang
// to "fr_FR", the translator will look for "fr_FR" files rather than "fr" files
// but if not set the translator will look for "fr" files rather than "fr_FR" files.)
app()->setLocale($site->lang());

Carbon::setToStringFormat(Statamic::dateFormat());

Expand Down

2 comments on commit be11b59

@ebeauchamps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to create the fr_FR files? Clearly, the current fr files are fr_FR and not fr_CA. Nobody has ever complained right now, but...I know from experience that maintaining fr files alongside fr_CA and fr_BE can be a real pain. What are your thoughts?

@jasonvarga
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will use the fr files unless you explicitly put lang in your site config.

Please sign in to comment.