Search

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 to mywebsite.com/en instead of mywebsite.com/hr.

Any ideas?

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?

Nope. It's set to Croatian for testing.

Strange.

Can I hardcode default language in the extension?

Language detection is here. Fallback to default language is here. Pretty straight forward. Just uses the first item in the array.

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.

Attachments:
language-screen.png and extension.driver.php

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.

Attachments:
extension.driver.php

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.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details