Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter robertosalemi

    (@robertosalemi)

    Hi,
    i would translate this page: link.

    So I add my JS code:

    <script type="text/javascript">
    	function auction_nudge_loaded() {
    			//Get HTML
    			var an_html = $('div#auction-nudge-feedback.auction-nudge').html();
    
    			//Used in multiple themes
    			an_html = an_html.replace(/Positive Feedback/gi, 'Feedback Positivi');
    			an_html = an_html.replace(/months/gi, 'mesi');
    			an_html = an_html.replace(/Buyer/gi, 'Acquirente');
    			an_html = an_html.replace(/When/gi, 'Data acquisto');
    
    			$('div#auction-nudge-feedback.auction-nudge').html(an_html);
    	}
    </script>

    But the traslantionnot be applied.

    Where is the error?

    Thanks.

    Plugin Author Joe

    (@morehawes)

    Hi robertosalemi,

    Thanks for your message. There are a couple of issues with using this code: it appears you may have pasted the JavaScript directly into the content editor, which adds unwanted markup and breaks the code.

    To add custom JavaScript to a WordPress page you will need to do so by editing your theme, or by using a plugin like one of these:

    https://www.ads-software.com/plugins/css-javascript-toolbox/
    https://www.ads-software.com/plugins/html-javascript-adder/

    Secondly, the code you copied only translates the Your eBay Listings tool, and not the Your eBay Feedback, so no text is modified.

    Once you are able to add JavaScript code to your page correctly, let me know, and I will look into writing another script to work with the Your eBay Feedback tool.

    I hope that helps. Let me know if there is anything else I can assist with.

    All the best,

    Joe

    Thread Starter robertosalemi

    (@robertosalemi)

    Hi,
    thanks for your support.

    I addes my script js in a custom file js in my theme.

    And now? ??

    Plugin Author Joe

    (@morehawes)

    Hi robertosalemi,

    Great! I have come up with a script which will allow you to replace the English text with your language. Please view the source of this page:

    https://www.auctionnudge.com/temp/translate-feedback-profile.html

    The code you need to copy is between the ‘START/END Copy’ comments. Looking at the code, you need to replace the text between the ‘*’ characters with your translation. If you need to translate more text, you can just add another line in the same format.

    Please note, this method is pretty limited, but I hope it is enough to suit your needs. I am hoping to add proper multi-language support to Auction Nudge further down the road, but this will take some time to implement.

    All the best,

    Joe

    Thread Starter robertosalemi

    (@robertosalemi)

    Hi josephhawes,
    thanks for your support.

    I have a problem:
    1) in my functions.php I add:

    function wpb_adding_scripts() {
    wp_register_script('my_script', get_template_directory_uri() . '/js/my_script.js', array('jquery'),'1.1', true);
    wp_enqueue_script('my_script');
    }
    
    add_action('init', wpb_adding_scripts);

    in my file my_script.js:

    jQuery(document).ready(function() {
    
        alert('ciao');
    
        var an_html = jQuery('#auction-nudge-feedback').html();
        //Translations...
        an_html = an_html.replace(/in USA/g, '*in Italia*');
    
        jQuery('#auction-nudge-feedback').html(an_html);
    });

    The message ‘ciao’ is displayed, but not replace runs.

    Why?

    Thanks a lot!

    Plugin Author Joe

    (@morehawes)

    Hi robertosalemi,

    Thanks for the update. Looking at the code on your site, some of the script is missing. The code should look something like this (I have removed some parts here to keep it simple):

    jQuery(document).ready(function() {
     jQuery.getScript('[your_code_snippet_url]', function () {
      setTimeout(function(){
       load_auction_nudge_feedback();
    
       var an_html = jQuery('#auction-nudge-feedback').html();
    
       //Translations...
       an_html = an_html.replace(/Positive Feedback/g, '*Positive Feedback*');
       //etc...
    
       jQuery('#auction-nudge-feedback').html(an_html);
      }, 25);
     });
    });

    Try copying everything between the “//START Copy” and “//END Copy” and see how you get on.

    Joe

    Thread Starter robertosalemi

    (@robertosalemi)

    Grazie,
    it works fine, thanks a lor for your support.

    Last question: what is /g replace?

    Thanks.

    Plugin Author Joe

    (@morehawes)

    Great! I’m glad that worked for you.

    The ‘g’ is a regular expression modifier which tells the replace method to not stop at the first occurrence and perform multiple replacements (i.e. when the same word occurs multiple times). You can read more about this here:

    https://www.w3schools.com/jsref/jsref_regexp_g.asp

    And thanks for the review.

    Joe

    Thread Starter robertosalemi

    (@robertosalemi)

    Thanks again! ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Template in my language’ is closed to new replies.