Is it possible to use craft multilanguage capabilities without locale url segments?


German: domain.com/wetter

English: domain.com/weather

I know this is pretty dangerous. If one forgets to translate the url everything will fall apart. But I wonder if it would be possible theoretically :)

  • In your mind the German language version will live at domain.com/wetter instead of domain.com/de, In tandem the English version will live at domain.com/wether instead of domain.com/en_us? Or are you trying to eliminate both segments and when the user changes language the url is still just domain.com? – aran Oct 26 '15 at 16:40

You can pull data from entries by specifying a locale.

{% craft.entries.section('yourSection').locale('en_us') %}

Determine the locale you need by the custom segment.

{% set locales = {  'wetter': 'de', 'weather' : 'en_us' } %}
{% set segment = craft.request.firstSegment() %}
{% set entries = craft.entries.section('yourSection').locale(locales[segment]) %}

The big issue you will have is translating strings for each language. If you are not at domain.com/de, I believe, you won't receive the benefits of the translation files in Craft/Translations. You will need to build in your own mechanism to translate strings depending on the segment.

|improve this answer|||||
  • Okay, thanks for the insight. I guess I can live with locale url segments then :) – KSPR Oct 28 '15 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.