• Resolved florianmarianna

    (@florianmarianna)


    Hello,

    I have a multilingual website (3 languages) and I’d like to have my maps translated according to the language, how can I do that? I had a look at your section “Translate subdivisions’ names on front end” but it seems to be replacing the default version, not having several versions according to the language.

    Thanks!

    Florian

Viewing 1 replies (of 1 total)
  • Plugin Author Enrico Urbinati

    (@enrico-urbinati)

    Hi florianmarianna,

    probably the easiest way to achieve what you need would be creating variable for each subdivisions inside the javascript file of the map accordingly to the language used :

    1. Get lang attribute of HTML tag using document.documentElement.lang
    2. Create a variable each subdivisions with translations
    3. Change default subdivisions name in the json series ( just search for subdivisions’ names and replace them with corresponding variable )

    So, basically, at top of the javascript map file (it starts with “jquery-jvectormap-” suffix ) add something like following before “jQuery.fn.vectorMap…” :

    var getWpLang = document.documentElement.lang;
    
    if( getWpLang.length ) {
    	if( getWpLang == 'it-IT' ) {
    		var italy_var = "Italia";
    		var germany_var = "Germania";
                    //other subdivisions...
    	}
    
    	else if ( getWpLang == 'de-DE' ){
    		var italy_var = "Italien";
    		var germany_var = "Deutschland";
                    //other subdivisions...
    	}
    
    	else {//english default
    		var italy_var = "Italy";
    		var germany_var = "Germany";
                    //other subdivisions...
    	}
    }
    
    else {//english default in case no lang attribute is retrieved
    	var italy_var = "Italy";
    	var germany_var = "Germany";
            //other subdivisions...
    }

    In this case I’m using the world map. now search for “Italy” subdivions and replace it with ts corresponding variable italy_var, do the same for Deutchland with germany_var and so on for all the other subdivions.

    Just let me know if it make sense.
    Thank you for using RVM.

Viewing 1 replies (of 1 total)
  • The topic ‘Translate country names’ is closed to new replies.