1

Is it possible to add to add the following code into a string such as below. I need to give the "Terms" a text-domain such as below.

<?php _e('Terms','footer-text'); ?>

Need to essentially do string interpolation with the php code where the "Terms" string is.

  echo '<div class="col-xs-6 col-md-2 col-md-push-8 social-buttons">
  <div class="row">

          <a class="pull-right" href="'. $instance['facebook'] .'" target="_blank">
            <span class="icon-facebook-icon"></span>
          </a>
          <!--<a class="pull-right" href="'. $instance['tripadvisor'] .'" target="_blank">
            <span class="icon-tripadvisor-icon"></span>
          </a>-->
          <a class="pull-right" href="'. $instance['twitter'] .'" target="_blank">
            <span class="icon-twitter-icon"></span>
          </a>

  </div>
  <div class="row pull-right terms-links">
    <ul>
      <li><a href="'. $instance['tac-url'] .'">Terms</a></li>
      <li><a href="'. $instance['priv-url'] .'">Privacy</a></li>
      <li><a href="'. $instance['sitemap-url'] .'">Sitemap</a></li>
    </ul>
  </div>
</div>';

}

Sorry PHP not my language. Working with translator plugin and need to give the word a text domain for it to find it. Thanks.

1 Answer 1

1

I think what you're looking for is a shortcode: https://codex.wordpress.org/Shortcode_API.

Within the shortcode you can do the translations with _e() if needed, or use conditional statements depending on the current language (use the ICL_LANGUAGE_CODE constant for that).

Sign up to request clarification or add additional context in comments.

3 Comments

So it's not as easy as just adding the code via some sort of interpolation? The Shortcode_API is a confusing read for somebody who does not know PHP. hmm
Not that I'm aware of. I don't think WPML offers a way to change the _e method's output. What you're trying to do seems more complicated to me then using the shortcode API or a custom implementation.. :)
I'll have another look Sjors. I'm literally translating a site somebody else had built. So i'll probably rework their code once I figure out why they've got the links pulling in that way. Thanks dude.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.