3

I started to develop my new Craft site in two languages (French & German). Once done here, I have to put the website online temporarily in one of these two languages (French).

So I turned off all sections and entries to disable the language (German) but:

  • This was tedious and time consuming to do this manually via the CP
  • domain.com/de/ now redirects to the homepage with empty content instead of redirect to the 404 page

Questions :

  • Is there a faster and safer way to temporarily disable a website language with the General Config Settings?
  • Is it possible to disable some website languages depending on the environment and / or if devMode is enabled?
2

How about hiding the language switcher on the front-end?

| improve this answer | |
  • This is what I finally did (in addition to disable the entries and sections in this language), but this is not the perfect solution because : — By only disabling the language switcher, direct URLs to the entries are still accessible; — What if only one language of the languages switcher should be disabled? – Romain Poirier Jun 30 '16 at 8:38
  • I understand - however, if the language switcher is hidden, then the visitor should only be able to browse the French 'version' of the site, yes? Q: Is it likely that you are the only one who actually knows the direct URLs for German? – Matt P Jun 30 '16 at 9:19
  • Most of the time I will be the only one to know those URLs. But suppose these URLs were indexed in search engines or that I had used these URLs in newsletters, these links could remain accessible. That's why I was looking for a more reliable and practical solution, assuming that this would be possible from the General Config Settings, but it seems not... – Romain Poirier Jun 30 '16 at 12:03
2

What I would probably do is to create a new branch in version control that you can deploy to production as long as you have to disable the locales. The reason for this is that there are probably too many things you have to change in code and I wouldn’t want to clutter it with a lot of conditionals.

In that new branch you would have to delete the index.php for the locales you want to disable to make all these URLs respond with a 404.

And then remove all the references to the locale from your templates. Remove the language switcher altogether or remove just the locales you want to disable from the switcher code, e.g. remove the 'de' from {% for locale in ['en', 'fr', 'de'] %}.

With the above changes in place, you wouldn’t have to disable on a per entry basis.

| improve this answer | |

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.