WordPress.org

Ready to get started?Download WordPress

Forums

WP Flexible Map
[resolved] localize language of directions text ? (10 posts)

  1. wongkasep
    Member
    Posted 1 year ago #

    Is it possible to localize the language of directions? I mean, not only the word of "Directions" or "Get Directions", but also all the directions text which appear below map (turn left, turn right, etc..).

    Regards,

    wong

    http://wordpress.org/extend/plugins/wp-flexible-map/

  2. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    G'day Wong,

    That's a function of Google Maps and depends on your browser's language settings. If you set your browser to preference, say, French above English, Google Maps will show you maps and directions in French.

    cheers,
    Ross

  3. wongkasep
    Member
    Posted 1 year ago #

    Hi Ross,

    I think it doesn't so. I have try another plugin, like Google Routeplanner, and it has a function to change the language of route output. However, for other functions, I prefer Wp Flexible Map plugin.

    Regards,

    Wong

  4. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    G'day Wong,

    If I set Firefox or Google Chrome to have, say, French at the top of my list of accepted languages, I get directions in French. What browser are you using?

    If you want to force the language used by Google Maps, irrespective of what the browser is set for, you can do it with a filter (add it to a simple plugin, or your theme's functions.php file):

    // force Google Maps to use French
    add_filter('flexmap_google_maps_api_args', function($args) {
    
        $args['language'] = 'fr';
        return $args;
    
    });

    NB: code above is for PHP 5.3+

    cheers,
    Ross

  5. wongkasep
    Member
    Posted 1 year ago #

    Hi Ross,

    Yes, I need to localize Google Maps language, irrespective of what the browser is set for. I try the code, but got an error syntax. If the function can be added as parameters for the plugin, I am very pleased.

    Regards,

    Wong

  6. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    G'day Wong,

    I'll be revisiting the whole approach to localisation in a future version so I'll address that then.

    In the meantime, here's a version of the snippet above that should work on PHP 5.2; if you host is using anything older than that, well... move!

    // force Google Maps to use French
    add_filter('flexmap_google_maps_api_args', 'force_flexmap_directions_lang');
    
    function force_flexmap_directions_lang($args) {
        $args['language'] = 'fr';
        return $args;
    }

    cheers,
    Ross

  7. wongkasep
    Member
    Posted 1 year ago #

    Hi Ross,

    Yes, it works now! Thank you very much. Your support is excellent.. !

    Best Regards

    Wong

  8. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    G'day Wong,

    NB: I missed the single quotes around the function name in the filter above; please add them to your copy.

    add_filter('flexmap_google_maps_api_args', 'force_flexmap_directions_lang');

    cheers,
    Ross

  9. weiluri
    Member
    Posted 1 year ago #

    thank you Ross!
    this is exactly what i needed.
    i join to wongkasep, your support is excellent!
    i'll give your plugin 5 stars....:))
    uri

  10. webaware
    Member
    Plugin Author

    Posted 1 year ago #

    Many thanks to both of you, it's nice to hear that :)

    cheers,
    Ross

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags