WordPress.org

Ready to get started?Download WordPress

Forums

Transposh WordPress Translation
Traslation of URLs (2 posts)

  1. Georg Ludwig
    Member
    Posted 1 year ago #

    I had problems with href's defined within my theme's special items (cyberchims iFeature). I could resolve this via jQuery - perhaps it's of any use for future releases:

    jQuery(document).ready(function ($) {
      $('a[href^="/"]').each(
        function() {
          $(this).attr('href',
            function(index, value) {
              if (value.substr(0,1) == "/") {
                var a = value.split("/");
                if (a.length > 1 && a[1].length != 2)
                {
                  var b = location.pathname.split("/");
                  if (b.length > 1 && b[1].length == 2)
                  {
                    value = '/' + b[1] + value;
                  }
                }
              }
              return value;
            }
          )
        })
    });

    I searches for relative links and checks whether they are already prefixed with a language code like '/de/' - if the current page has one (e.g. '/en/') it adds the missing one...
    http://wordpress.org/extend/plugins/transposh-translation-filter-for-wordpress/

  2. Georg Ludwig
    Member
    Posted 1 year ago #

    Small correction - as the translation of images and so on should NOT be performed:

    function(index, value) {
              if (value.toUpperCase().match (".JPG$") || value.toUpperCase().match (".PNG$")) {
                 return value;
              }
              if (value.substr(0,1) == "/") {

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.