Translate RVM maps into multiple languages

In this guide I’ll show how is possible to have a custom map translated into different languages.
It’s not straight forward, but following these steps would be really easy.

First of all, we need a custom map installed into your WordPress site.
In this example I’ll be using France Region 2016 map. Any region is in french. Suppose we want to change name of “Corse” into “Corsica”, its english translation.

You will also need to modify some entries in the database ( using phpMyAdmin ).

Let’s start then :-).

Map of France for my example

France Reagions 2016 map
France Reagions 2016 map

As you can see, “Corse” region/island has a red background. Now we want to create a new map with all names translated into english. I’ll update only “Corse” to “Corsica“.

Duplicate your map in your “wp-content/upolads” folder

2- Select map to translate
2- Select map to translate

 

In my case, original map folder name of France Regions 2016 is : “france-regions-2016_merc_en“.
I’ve duplicated it and renamed “france-regions-2016_merc_new_lang” ( you can choose whatever name you like, i.e. I would use france-regions-2016_merc_de in case of Deutsch version for simplicity and consistency but it’s up to you ).

Change name of javascript file

3- Change map name of javascript file
3- Change map name of javascript file

 

Assign same identical name you gave to your folder to the javascript file inside it. In this example “france-regions-2016_merc_new_lang.js

Change map name inside the javascript file

4 Change map name inside the javascript file
4 Change map name inside the javascript file

 

Open the .js file ( france-regions-2016_merc_new_lang.js in this example ) and change the map name soon after the “addMap” string: Replace france-regions-2016_merc_en with france-regions-2016_merc_new_lang in this example.

5- Change map name within js file
5- Change map name within js file

Translate subdivisions’ name

6- Change subdivisions name
6- Change subdivisions name

 

Find subdivions/regions name you need to translate.
In this example We have to find Corse and replace with Corsica.
In a real-life example this operation needs to be repeated for all subdivisions/regions need to be translated.

7- Change subdivisions name
7- Change subdivisions name

For special characters within your subdivisions probably you will need to use the UTF encoded version.

Save the file.

Move to the database ( I use phpMyAdmin ) of your wordpress site

7- Search for rvm_custom_maps_options
7- rvm_custom_maps_options in phpMyAdmin

Search for rvm_custom_maps_options in wp-options table.

Open it clicking on “Edit”.

8- Open rvm_custom_maps_options clicking on Edit
8- Open rvm_custom_maps_options clicking on Edit

In this file are listed all custom maps you’ve installed within your WordPress site.
As you can see there is a string at very start : a:7 it means there are 7 entries there, so 7 maps in my case. Pay attention to this number, will be important to change soon!

9 Add new map into database
9 Add new map into database

 

Now add your map folder name and the year/month string.
In my example I’ll add:

s:33:"france-regions-2016_merc_new_lang";s:8:"2019/11/";

s:33 means string of 33 characters ( so please adjust the number – 33 – accordingly to your total map name characters ) , which is the total characters of france-regions-2016_merc_new_lang string!

While s:8 is total characters of couple “yyyy/mm/“, this is the specific year/month of the folder where your map is located . Please change yyyy/mm accordingly to your year/month upload folder.

Update also new number of total maps ( remember a:7 ) adding total number of maps. So it was a:7 and now becomes a:8 .

Save new values ( “go” button in phpMyAdmin ).

Not given up yet? Great, as you’ve almost finished.

Back to WP dashboard…

10 New map added to the list
10 New map added to the list

You you did all your homework, you should see the new map in the list!

Wow, so glad !

11 Customize new map
11 Customize new map

 

Customize your new map. Eventually you could even import settings from the original map and import it into this new map so they would be identical in subdivisions look-and-feel.

Your map on front end

12 New map on front end
12 New map on front end

 

Use shortcodes to show translated maps

Now you have 2 identical maps, with different subdivisions’ name.
You can use the do_shortcode WP feature together with wp_lang and you’ll display the correct maps for all your languages!

Example:


<?php 
if (get_locale() == 'de_DE') { 
//if Deutsch 
echo do_shortcode('[rvm_map mapid="12345"]'); 
} 
else { 
//all other languages 
echo do_shortcode('[rvm_map mapid="56789"]'); } 
?>