Two simple enhancements would be desirable.
The language switcher retrieves information from the query tag locale, with the browser request as fallback.
Instead of only offering the query tag locale, alternatives should be configurable, for example:
LanguageSwitch::configureUsing(function (LanguageSwitch $switch) {
$switch
->locales(['ar','en','fr','en_GB']) // also accepts a closure
->tag('lc');
});
Then mywebsite.com/mypage/myresource/123?locale=en_GB is reduced to mywebsite.com/mypage/myresource/123?lc=en_GB.
A mapping to more handier locale codes should be configurable, for example:
LanguageSwitch::configureUsing(function (LanguageSwitch $switch) {
$switch
->locales(['ar','en','fr','en_GB']) // also accepts a closure
->tag('lc')
->mapping(['uk' => 'en_GB', 'pt' => 'pt_PT']);
});
Then mywebsite.com/mypage/myresource/123?lc=en_GB is further reduced to mywebsite.com/mypage/myresource/123?lc=uk.
For languages that differ by territory, you should name the language directories according to the ISO 15897. For example, "en_GB" should be used for British English rather than "en-gb".
the plugin just switches the user or app local and how you handle the translatable routes is totally different.
but if that ain't the case a PR for the enhancement is always welcome.
Two simple enhancements would be desirable. The language switcher retrieves information from the query tag
locale
, with the browser request as fallback.Instead of only offering the query tag
locale
, alternatives should be configurable, for example:Then
mywebsite.com/mypage/myresource/123?locale=en_GB
is reduced tomywebsite.com/mypage/myresource/123?lc=en_GB
.A mapping to more handier locale codes should be configurable, for example:
Then
mywebsite.com/mypage/myresource/123?lc=en_GB
is further reduced tomywebsite.com/mypage/myresource/123?lc=uk
.Some links:
uk
used by Apple in URL path: https://www.apple.com/uk/iphone/