How to change "Related Articles" to "Related Posts" which is translatable to multiple languages?

Answered

12 Comments

  • Vladan Jovic
    Comment actions Permalink

    Hey Chris, good question. You can do that.

    - create a DC item for this title on each lang

    - in my JS code just replace:

    .text('Related posts');

    with

    .text('{{dc 'your_dc_item_name'}}');

    This JS code should stay on the Article page, it can't be in the theme JS file.

    Hope it helps.

    2
  • Vladan Jovic
    Comment actions Permalink

    Hey Muhammad, that is doable with a help if little JS. Just copy/paste this code at the end of your theme article template.

    <script>
    $('section.related-articles h3').text('Related posts');
    </script>
    1
  • Chris Stock
    Comment actions Permalink

    @Vladan - this will work for the English title, but it won't translate when the site language is changed. Presumably you can't inject dynamic contact via JS?

    1
  • Chris Stock
    Comment actions Permalink

    @Vladan - Perfect, good work!

    1
  • Vladan Jovic
    Comment actions Permalink

    Good to hear, thanks for the feedback! :)

    1
  • Muhammad Alyas
    Comment actions Permalink

    Thanks Vladan & Chris for the help.

    That's what I was looking for.

    0
  • Russell
    Comment actions Permalink

    @vladan - I was able to implement a copy change for "Related Articles" successfully by following your instructions.

    Now I'm attempting to use similar logic to change copy for "Recently Viewed Articles" and "Articles in this Section". Can you confirm what the correct string (italicized) is for each? I've attempted the following by see no changes:

    <script>
    $('section.articles-in-section h3').text('{{dc 'articles_in_this_section'}}');
    </script>
    <script>
    $('section.recent-articles h3').text('{{dc 'recently_viewed_articles'}}');
    </script>

     

    Thank you!

    0
  • Vladan Jovic
    Comment actions Permalink

    Hey Russel, all looks good, but just instead of:

    section.articles-in-section h3

    you need to use

    h3.collapsible-sidebar-title.sidenav-title

    Hope this helps!

    0
  • Russell
    Comment actions Permalink

    Thank you @vladan! 

     

    The first line updated, but the second line did not. Do you know what edits I need to make to this code?

     

    <script>
    $('section.recent-articles h3').text('{{dc 'recently_viewed_articles'}}');
    </script>

    0
  • Vladan Jovic
    Comment actions Permalink

    Hey Russell, from this perspective, your code looks good.

    Can you provide me with a link to your HC to check directly in the code?

     

    0
  • Russell
    Comment actions Permalink

    support.juul.co.il

    0
  • Vladan Jovic
    Comment actions Permalink

    Hey Russell, this recent articles works with some delay so the js code about changing the title go before the title is created. Anyway, long story short, please try this one, it should work:

    $(document).ready(function() {
    $('section.recent-articles h3').text('{{dc 'recently_viewed_articles'}}');
    });
    0

Please sign in to leave a comment.

Powered by Zendesk