This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 4 replies, has 2 voices.

Last updated by eric-janv 4 months, 3 weeks ago.

Assigned support staff: Yvette.

Author Posts
May 24, 2019 at 6:18 am #3881373

eric-janv

We have a menu that contain different regions and for some regions we need to redirect the user to the same language, for example:

Germany
Austria
Switzerland

Redirected to: /de/ folder

US
UK
Australia
Singapore
India

Redirected to /en/ folder

How do we achieve the above? For now, each languge create a separate folder e.g. /ch/ for Switzerland, etc.. would be great if we can minimize the directories for the regions that have a main language.

Thank you,

May 24, 2019 at 8:15 am #3882249

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Do your geo-locations have different content? Or are the contents for each geo-location exactly the same?

WPML will not do geo-targeting and only provides a way to separate content by language. If you need a menu item that redirects geo-locations to a common langauge, then I would suggest using a custom link to do that within your menu.

If you require that the geo-locations have distinct URLs even if they are sharing the same content, then I would suggest that you create "new" languages for each location and then duplicate the post content between common languages.
e.g. de-ch, de-at, de-de posts are all duplciates of each other.

Does this answer your question?

May 24, 2019 at 8:43 am #3882495

eric-janv

The content for each geo-location is the same so grouping them to a single redirect would be great.

Is there an option to create regular expression for the custom links? Our goal is to redirect the user to a translated page they are currently viewing, for example:
/en/internal-page redirect to /de/internal-page...

Creating a custom link for all our pages will be cumbersome without regular expressions.

I look forward to your recommendations.

May 24, 2019 at 8:54 am #3882575

Yvette
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

You mentioned "menu" and this is the only place you woudl include a custom link.

I think the easiest would be that your URLs all have distinct geo-location URLs like this.
your-site/de-at/post
your-site/de-ch/post
your-site/de-de/post

To achieve this,
1. you would then define some new languages each with a different locale
https://wpml.org/documentation/support/editing-wpmls-languages-table/

2. Set your default language as EN
3. Then translate your EN post to one of the DE languages (de-de).
4. You will then duplicate this de-de translation to all other DE based languages.
https://wpml.org/documentation/translating-your-contents/displaying-untranslated-content-on-pages-in-secondary-languages/using-content-duplication/
5. You will also then duplicate the EN post to all other remaining languages.

If you set it up as above, then when you use the WPML language switcher, it will automatically find the correct version for each location.

I hope this makes sense to you.

May 27, 2019 at 5:44 am #3893549

eric-janv

My issue is resolved now. Thank you!