3

I'm making a multilingual site where I'm using Spanish, English, German, and others.

I have already made several multi-language sites and I am familiar with the process but in this case, my client wants the user to choose the country from a dropdown selector and not the language.

In such a way that if the client chooses Spain, Spanish (es) is used, Germany uses German (de), and so on.

Until there, no problem, I've already done it.

The problem is with the countries that use the same or very similar language as the Latin countries: Argentina, Chile, Peru, Venezuela, Colombia, etc. .. that use Spanish or Germany and Austria that use German.

My client wants the URL to use the prefix of each country and not group them by language: For example, for Argentina, Spain, and Colombia the URLs would be:

www.myweb.com/ar

www.myweb.com/es

www.myweb.com/co

But I don't want to have to install all the Spanish versions, many of which don't exist, and I don't want to create a multitude of associations for menu items, articles, and modules that would be basically the same. I would like any of those prefixes: ar, co, cl, ve, pe -> to use es and es-ES internally.

The same for example would happen with Germany and Austria. The URLs would be:

www.myweb.com/de (germany)

www.myweb.com/au

But internally they both will use de-DE.

Thanks for any help or hints that you can give me to solve this problem. I can program any type of Joomla / PHP plugin in case the solution was custom programming.

3
  • Usually a user selects the language he wants to read is content. You could have a country selection, which will redirect to the corresponding language version of the site. At the other hand, if the Spanish version for Argentina requires different texting than the Spanish version for Spain, then you will need to have 2 different Spanish versions for the website. More languages, more work, higher payment... – FFrewin Feb 25 at 0:20
  • Reading through the comments, it doesn't seem like Joomla! languages is a good way to handle your issue. It CAN do it, but you've mentioned that it would be too much work to duplicate all the menus, etc. Have you looked into external translation services? Here's one, just for example: packagist.org/packages/google/cloud-translate – James Shaver Feb 25 at 16:50
  • Another approach could be a multisite implementation - where you will have different websites foreach country - Check this: alterbrains.com/joomla-extensions/administration/…. Overall, I think it's hard to get a thorough answer on your question - as there is not a straight-forward answer to this - not something that is provided out of the box from Joomla - So it will need out of the box thinking and customisations - and that requires full analysis on the requirements. – FFrewin Feb 25 at 23:29
1
+500

I have managed to reproduce your use case in a development enviromnent using docker. I can give you the Akeeba Backup zip file of the solution to what you asked for and also the system plugin I created to solve your problem. They are already done but I don't know If I can share them publicly since it's for your client. You can contact me contact@alexandre-elise.fr so I can send you the files for this solution.

Here is a short video for the demo: Video demo of how it works

Here is the link to the plugin source code, zipped extension and zipped backup reproductible dev environment showed in the video demo Link to the plugin source code and the dev environment backup

Here is the overall process:

System - Compound Language Filter

Joomla! System Plugin

This plugin is based on the core languagefilter plugin and adds the feature of using multiple sef language tag in the url associated with the same language internally.


HOW IT WORKS: This plugin is an enhancement of the language filter plugin. It enables the possibility to have one to many relationships from one source language to any other "virtual languages". I call them virtual languages because they are actually not installed in Joomla!. What I did to achieve this is to leverage the power of the Joomla! subforms and use part of the com_languages form from the admin area and add to it what I called the "source_language". The source_language is a standard form field from Joomla! which list the installed languages of the "Frontend" part of Joomla!.

The website I built to reproduce the use case is a multilingual website with 4 languages French, English, Spanish and German.

In order to use the name of the country rather than the language name we can simply change the title of the language and/or the native title accordingly. Moreover, I added the possibilty to choose the "virtual languages" and the installed languages from the mod_languages module which Helper class has been dynamically replaced by another one by my system plugin so as to have this custom functionnality.

By merging the subform results and the installed languages result using Joomla! Registry . It allows a powerful tool to address this use case.

With all this you are now able to do as you describe.

NOTE: This implementation also changes the website to be multilingual for either "virtual languages" and installed languages.

Just one side note: The url of type /ar changes the active menu item to Spain and the content is in Spanish but the menu item doesn't stay on Argentina (I think you can get around that but I didn't have much time to answer your question)


INSTRUCTIONS:

This Joomla! plugin source code is in the src/ directory of this zip file The final extension is in the build/ directory If you want to build the extension yourself, make sure you have make utility on your machine. It is generally provided by default on linux and macOS machines maybe not on Windows. Once you have make installed. You can type in your terminal: (you must be in the directory on the Makefile)


make gen

The Makefile rule will check if the php files has no syntax errors and create a zip file tagged by the current datetime in the build/ directory.

If you don't want to bother doing this. Just install the already built extension from the build/ directory


3
  • Thank you very much for your generosity, but we don't want future researchers to have to contact you for your solution. Please provide your offering without the need to include your email in this answer. – mickmackusa Mar 2 at 6:37
  • Hi, thanks for your great answer. I granted you the bounty just for your hard work and dedication. I will test your solution asap and let everybody knows if it worked for my problem. – Piero Marsilio Mar 3 at 7:11
  • Hi Thanks Mr Marsilio. Normally,it should work for you. Take care and have a great day. – alexandreelise Mar 3 at 13:54
2

I have done similar to this before, where the end user was not happy using FR for French because they use a variant of French for which a language pack doesn't exist. In the end, I duplicated the French language pack, renamed fr-FR to fr-KA and set it up as an entirely new language, to produce individual URL's for French and their localised French KA language.

As for selecting a country to determine language, that isn't a great user experience either. I would push back on that requirement if at all possible. Let's take Switzerland as an example, where official languages include German, French, Italian and Romansh. You can see the obvious problem here, which is exactly why I would leave it to use the native Joomla functionality for this (see language filter plugin), where the users browser language primarily determines the site language, then display an option to change language at the users peril.

2
  • Thanks for your help, although I don't think it applies to me. We do not want to copy all the language files because it would be too much work and even less to have to duplicate menus, menu items, and modules for the different versions of Spanish because it would be a huge work. – Piero Marsilio Feb 24 at 19:26
  • Maybe redirects with the htaccess could achieve something. The idea here is that an url like 'miweb.com/ar' behaves internally as if it were 'miweb.com/es' – Piero Marsilio Feb 24 at 19:27
0

As a native Spanish speaking person, I absoultely hate when a website assumes I would like to have their content served to me in any given language due to my current IP. Just because your IP is from Mexico, that does not mean that the visitor speaks "Mexican Spanish". There are, in fact, lots of people who are in Mexico and don't speak the language (because they are tourists, migrants, or whatever).

Now, in response to your question, I can point you to donweb.com. This company is in the web hosting business and faced the same problem: how to fake you are dealing locally, when in fact you are not. Their solution is pretty simple: write 2 different interfaces (for Spanish and English), and populate the page with localized media that do not affect the interface. The Spanish is the one who is spoken in Argentina, but the pictures and offers are taken from the local cultures.

1
  • Thank you for joining and contributing César. This may or may not be enough detail for Piero. Time will tell if this community finds your advice valuable. Please take our tour and if you have any insights to offer on our other questions, please post an answer. – mickmackusa Feb 26 at 1:09

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.