Transelate custom marker fields with WPML

New home Forums Pro Add-on Transelate custom marker fields with WPML

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #79973
    [email protected]
    Participant

    I tried scanning the plugin files, scanning the rendering of WPML. But in no way its possible to transelate the Marker ‘custom’ fields. Can you please help me with a code or some sort asap.

    Thanks in advance.

    Attachments:
    You must be logged in to view attached files.
    #80003
    Matthew
    Moderator

    Hi there,

    Thank you for getting in touch wtih us, we do appreciate your time.

    Thank you for the screenshot, please may you confirm if you are wanting to translate the backend of the plugin on the Custom fields page?

    If you are wanting to translate the frontend where your map is displayed and your marker custom fields are displayed, please may you provide me with the link to your map page?

    Kindest Regards,
    Matthew

    #80009
    [email protected]
    Participant

    No on the front-end please.

    Example : https://www.buzon-home.com/nl/vind-ons/

    also visual in screenshot

    “Adress”
    “Pays”
    “Tél”

    These are marker fields names i need to transelate.

    Thank you very much.

    Attachments:
    You must be logged in to view attached files.
    #80031
    Matthew
    Moderator

    Hi there,

    Thank you for your response.

    Thank you for the confirmation, thus please may you save the below code into the “Custom JS” setting block (Maps -> Settings -> Custom Scripts) and confirm if this helps:

    jQuery(function($){
      const customFieldTranslation = {
        '1' : "Adress",
        '2' : "Pays",
        '3' : "Tél",
      }
      
      $(document).on('markerlistingupdated.wpgmza', function(){
        $('.wpgmaps_mlist_row').each(function(){
          let row = $(this);
    
          row.find('div[data-custom-field-id]').each(function(){
            let customFieldEl = $(this);
            let customFieldId = customFieldEl.attr('data-custom-field-id');
            customFieldEl.find('.custom-field-label').html(customFieldTranslation.customFieldId);
          });
        })
      })
    
      $(document).on('infowindowopen.wpgmza', function(event){
        let infowindow = $(event.target.element);
    
        infowindow.find('div[data-custom-field-id]').each(function(){
          let customFieldEl = $(this);
          let customFieldId = customFieldEl.attr('data-custom-field-id');
          customFieldEl.find('.custom-field-label').html(customFieldTranslation.customFieldId);
        })
      })
    })

    I look forward to hearing back from you.

    Kindest Regards,
    Matthew

    #80040
    [email protected]
    Participant

    And than?

    – I rescanned with WPML
    – I tried adding strings
    – tried to function which recognises live strings

    I’m a bit lost what the code does

    #80073
    Matthew
    Moderator

    Hi there,

    Thank you for your response.

    The custom JS code that I have provided you with is a work-around solution if WPML is not detecting those custom field strings as they are dynamic data that is created.

    Thus the custom JS code is used to translate the custom field labels.

    Please take a look at your map on the frontend and you should see that the custom field labels are translated.

    I hope this makes sense?

    Kindest Regards,
    Matthew

    #80091
    [email protected]
    Participant

    It’s not working embedded beneath map or inside custom code section in the plugin…

    I’ll try to write myself some code because we have time schedule we are on..

    I hoped that the plugin itself would be translatable, this is a pity tbf.

    #80117
    Matthew
    Moderator

    Hi there,

    Before sending my previous response, I had checked your site and the custom field labels were translated to the strings that you mentioned:

    “Adress”
    “Pays”
    “Tél”

    However, I see now that you have implemented your code that you mentioned and it translates the strings to the following:

    “Land”
    “Email”
    “Tel”

    Please may you advise?

    Kindest Regards,
    Matthew

    #80157
    [email protected]
    Participant

    jQuery(document).on(‘markerlistingupdated.wpgmza’, function(){

    jQuery(“div [data-custom-field-id=’1′] .custom-field-label”).html(“Country:”);
    jQuery(“div [data-custom-field-id=’2′] .custom-field-label”).html(“Tel:”);
    });

    jQuery(document).on(‘infowindowopen.wpgmza’, function(event){
    jQuery(“div [data-custom-field-id=’1′] .custom-field-label”).html(“Country:”);
    jQuery(“div [data-custom-field-id=’2′] .custom-field-label”).html(“Tel:”);
    });

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.