cancel
Showing results for 
Search instead for 
Did you mean: 

1 Domain - 2 Stores - both of them in English and German - How to get Language Tag in URL?

1 Domain - 2 Stores - both of them in English and German - How to get Language Tag in URL?

Stores:
- automobile
- truck

Languages:
- German
- English

StoreViews Codes:
- automobile German: auto
- automobile English: car
- truck German: laster
- truck English: truck

Desired urls:
- automobile German: example.com/de/auto
- automobile English: example.com/en/car
- truck German: example.com/de/laster
- truck English: example.com/en/truck

Problem
I am able to get the store view code in the url but I am not able to get the language tag in the url. How can I build the aforementioned urls in Magento 2?

2 REPLIES 2

Re: 1 Domain - 2 Stores - both of them in English and German - How to get Language Tag in URL?

Hi @Jens_Noma,

 

By dfault you won't get it working in that way (there are some workarounds maybe).

One of the most basic configurations for that is to use a code store that use both codes. I mean:

 

  • de_auto
  • en_auto

So then the url will be different.

Another way to solve this problem is to use different urls per store view: http://devdocs.magento.com/guides/v2.2/config-guide/multi-site/ms_websites.html

 

Maybe you can combine the last option with store codes?

Re: 1 Domain - 2 Stores - both of them in English and German - How to get Language Tag in URL?

Accept Language Header Automatically switching the language according to the header Accept-Language. A lot of users don't have this header set up correctly. This is particularly true for those who travel abroad and could be using a family member's computer, or even an internet café. I also applied it to my (badass truck names site) It's also the case for users from other countries who install an English browser and have enough English to navigate but prefer to view content in an alternative language. Googlebot can only be used to browse the default language of your website, since Googlebot doesn't send the Accept-Language head. In order to be crawled and considered for ranking in multiple languages, you should have distinct URLs for content that are that are in multiple languages. It is possible to use the Accept-Language header in order to suggest that users may prefer an alternative version of your website by showing an indication that the website that they are on does not meet the header for Accept-Language.