Improvements in Google Maps plugin translation

Elite
  • 42 points
    Starting to get into this DEV thing
    I'm new here
    blogspnte

    Member  —  4th August 2011 07:32         

    I think some changes in code could be useful, in order to improve Google Maps plugin translation to other languages (spanish, in my case).

    Look at /lib/class_agm_admin_form_renderer.php file (lines 28-41). Instead of:

    function create_map_type_box () {
    $opt = get_option('agm_google_maps');
    $items = array(
    'ROADMAP',
    'SATELLITE',
    'HYBRID',
    'TERRAIN'
    );
    echo "<select id='map_type' name='agm_google_maps[map_type]'>";
    foreach($items as $item) {
    $selected = ($opt['map_type'] == $item) ? 'selected="selected"' : '';
    echo "<option value='$item' $selected>$item</option>";
    }
    echo "</select>";

    we can write something like:

    function create_map_type_box () {
    $opt = get_option('agm_google_maps');
    $items = array(
    'ROADMAP' => __('ROADMAP', 'agm_google_maps'),
    'SATELLITE' => __('SATELLITE', 'agm_google_maps'),
    'HYBRID' => __('HYBRID', 'agm_google_maps'),
    'TERRAIN' => __('TERRAIN', 'agm_google_maps')
    );
    echo "<select id='map_type' name='agm_google_maps[map_type]'>";
    foreach($items as $item=>$label) {
    $selected = ($opt['map_type'] == $item) ? 'selected="selected"' : '';
    echo "<option value='{$item}' {$selected}>{$label}</option>";
    }
    echo "</select>";

    This way, the items of "map_type" array could be easily translatable. In this file there's another array ("image_size") in which a similar improvement can be done. In fact, my inspiration comes from the array "zoom" of last version of this plugin, where the array items are ready to be translated.