Default language for Multilingual
This is an open discussion with 12 replies, filed under Extensions.
Search
But regardless of how I switch places of those two when ever I enter my webistes name e.g. mywebsite.com I get redirected to mywebsite.com/en instead of mywebsite.com/hr.
I guess your browser language is en
? Multilingual is supposed to detect the browser language and redirect to that if no language code is provided in the URL and the browser language is in your language settings.
The default language is used when your browser language isn't available or a translation for the current language is missing (empty field for that language).
Nope. It's set to Croatian for testing.
Can I hardcode default language in the extension?
That did the trick. Thanks @jensscherbl
That did the trick. Thanks @jensscherbl
Can you tell me what exactly you changed to make it work?
I just went the lazy way (line 102):
// detect language from browser self::$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); turned it into self::$language = self::$languages[0];
Can you tell me what's in your $_SERVER['HTTP_ACCEPT_LANGUAGE']
?
Sorry for the late reply @jensscherbl, I had some mess to fix over the weekend. Anyway, here's what I have in language string : en-US,en;q=0.8,hr;q=0.6
. Language code for Croatian
is hr
. It does exist in there but not on the expected position.
I have attached screen so you can see that browser language is Croatian. Also, I have modified your extension a bit, so now I have a checkbox to force default language regardless of browser settings.
I have marked my modifications with //Reygoch Was Here
:D in case you want to include them.
Just a note. Screen is from the site that has no Croatian language my problem was on another one.
And feature to force language regardless of browser settings is in my opinion quite useful, because quite a lot of people in my country prefer to use their web browser with English interface on so it's not definitive indication of what language should be served first.
If some company has primary focus on say "Croatian market" but also wants to offer their site in English language for professional reasons, than you can see how that might be a problem if Croatian customer comes to the page and get English version of the page.
Ok, so I have a problem with my modification. It's between line 72
and 77
. Damn checkbox doesn't want to uncheck and I'm not finding API documentation particularly helpful on that topic.
en-US,en;q=0.8,hr;q=0.6
Mhhh...
Also, I have modified your extension a bit, so now I have a checkbox to force default language regardless of browser settings.
From a conceptual point of view, I'd rather make the language detection optional instead of forcing the default language. Result would be the same.
Ok, so I have a problem with my modification. It's between line 72 and 77. Damn checkbox doesn't want to uncheck and I'm not finding API documentation particularly helpful on that topic.
Fixed a similar issue for maintenance mode recently. Symphony 2.4 had some breaking changes (before our switch to semantic versioning).
Create an account or sign in to comment.
I'm having trouble with setting up default language for multilingual extension.
I recall it saying that default language will be first language defined in the settings and I have following string in my settings page :
hr, en
.But regardless of how I switch places of those two when ever I enter my webistes name e.g.
mywebsite.com
I get redirected tomywebsite.com/en
instead ofmywebsite.com/hr
.Any ideas?