WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
non unique slugs, and an other question (18 posts)

  1. JustMeSander
    Member
    Posted 1 year ago #

    Hello,

    Thanks for the plugin, i have a few questions.

    When i create a pages called "Home" and i give that page the same title in another language the permalink changes to:

    http://www.example.com/nl/home
    http://www.example.com/en/home-2

    Is it possible to have
    http://www.example.com/nl/home
    http://www.example.com/en/home

    If this isn't implemented yet in polylang, i really want to contribute by fixing it, in that case i really appreciate some information about where to start, and thoughts for a little kickstart.

    And an other question:
    Why are the methods ppl__(); and pll_e() there?

    Because wordpress gives us the __() and _e() method? does it have a special reason?

    Thanks!

    http://wordpress.org/extend/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    For the 1st question, see:
    http://wordpress.org/support/topic/plugin-polylang-identical-page-names-in-different-languages?replies=8

    pll__() and pll_e() translate strings registered with pll_register_string. The translation is done in the Polylang backend and is stored in the database. This is useful for translating user defined strings such as plugins or themes options or just the site title.

    __() and _e() translate static strings stored in .mo files.

  3. JustMeSander
    Member
    Posted 1 year ago #

    First of all thanks =)

    What are the advantages of pll__? or is it just a preference.
    Because the default translation system works pretty good. Only disadvantage in my opinion is all the stuff that comes with plugins to translate the .mo files (Wich is pretty good done in polylang no non needed additional stuff etc).

    I'm gave that script a try from the other topic, but it's not working in WP 3.5 (I will fix it and post it here)

    I also have one other problem.
    When i hit http://www.example.com/ i get nicely redirected to
    http://www.example.com/en/home but http://www.example.com/en/ doesn't seem to work and i get a blank page while i expect the home page without redirect.

    Or a redirect from http://www.example.com to http://www.example.com/en/

    I solved it for now by adjusting the index.php, but that is just a quick fix.

  4. JustMeSander
    Member
    Posted 1 year ago #

    Got a solution for the redirect with static pages,
    http://www.example.com redirects now to http://www.example.com/en/ instead http://www.example.com/en/home

    In core.php

    On line 386
    is_string($redirect = $this->get_home_url($this->curlang))
    Changed to
    is_string($redirect = $this->get_home_url($this->curlang, false, true))

    On line 854
    get_home_url($language = '', $is_search = false)
    Changed it to:
    get_home_url($language = '', $is_search = false, $is_frontpage = false)

    And on line 867
    (!$is_search ....
    Changed it to: (where $is_frontpage means it is the frontpage of the frontend)
    (!$is_frontpage && !$is_search ....

    Still getting an empty page, but solved that in the index.php
    (still looking for a nice solution)

    get_header();
    echo apply_filters('the_content', get_page(pll_get_post(71))->post_content)
    get_footer();

  5. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Got a solution for the redirect with static pages,
    http://www.example.com redirects now to http://www.example.com/en/ instead http://www.example.com/en/home

    This is the goal of the option: "When using static front page, redirect the language page to the front page in the right language." Did you check it?

  6. JustMeSander
    Member
    Posted 1 year ago #

    You are right, don't know how i could miss that.

    I'm making a little progress with the slugs, I will post it here when it's done.

  7. gian-ava
    Member
    Posted 1 year ago #

    JustMeSender, I posted a topic about this problem (not the solution):
    http://wordpress.org/support/topic/url-structure-question?replies=3

    So I am very interested in finding a solution. I hope that this will be integrated into the Plugin core by Chouby, instead of just represent a hack.

    I'll be hoping for the best…

  8. JustMeSander
    Member
    Posted 1 year ago #

    Thanks for the notice =)

    I didn't have much time to look into the code for a solution, but i really need it so i need to make time for it soon, hopefully I/we can find a solution that's good enhoug instead of a hack.

    My first idea was to create a slug (actually post_name) with a prefix, but i just don't like the idea of that and i think it will create other problems in wordpress (and it's just ugly).

    Also i need to walkthroug the code of polylang so i can come up with a solution.

  9. gian-ava
    Member
    Posted 1 year ago #

    Can't you work together with Chouby, the plugin's author, on this?

    This is a major future when it comes to language management…

  10. JustMeSander
    Member
    Posted 1 year ago #

    Well I don't know Chouby, and I guess he's busy too.
    And I really don't know the code, so I have to go through it anyway =P

    BUT: I noticed that when i go to
    http://www.example.com/es/contact/
    that my browser redirects me to
    http://www.example.com/nl/contact/

    (the contact page for ES is "contact-2")

    So i'm going to look into it today =)

  11. gian-ava
    Member
    Posted 1 year ago #

    Well, I hope your investigation will lead to the solution…
    Keep it up, and thanks for your efforts!
    ;-)

  12. JustMeSander
    Member
    Posted 1 year ago #

    Ok that was a dead end.

    What the problem is, is that wp loads the page from the slug.
    And polylang extracts the language from the permalinks (or something else) and compares that to the post language. Otherwise the page is redirected to the right language. But on that point it's to late to alter the main WPQuery that loads the page.

    I need to find the right action/filter to alter the incoming request (main WP Query). if you remove the redirect and navigate to /es/contact you get the contact page but not in the right language.

  13. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    http://www.example.com/es/contact/
    that my browser redirects me to
    http://www.example.com/nl/contact/

    That is an intentionnal canonical redirection done by Polylang.

    If you need to remove it, this should do the work (not tested):

    add_action('setup_theme', 'remove_polylang_canonical');
    function remove_polylang_canonical() {
      global $polylang;
      remove_action('wp', array(&$polylang, 'check_language_code_in_url'));
    }
  14. TheDarkD
    Member
    Posted 1 year ago #

    Chouby, the code works and not works :D
    Now I have the desired url but the content is the same.

    website.com/contact
    website.com/fr/contact

    But the same content(the content from the default language page) on both pages.

  15. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    You can't have the same slug for two different pages. That's a limitation of WordPress that Polylang does not remove. This starts to be a frequent request. I will however not include this feature in v1.1. Maybe later.

  16. fraenzn
    Member
    Posted 7 months ago #

    Sorry for digging up an old thread, but has there been any progress with this feature? We really need this for a big site. I guess I could hack together a really simple mod_rewrite RewriteRule for this so that the public URL is different from the internal one, but that doesn't feel right.

  17. Chouby
    Member
    Plugin Author

    Posted 7 months ago #

    Nothing new. And v1.4 won't include that too. One of the problem I see is that the solution proposed by Andydegroo (which certainly needs adaptations now) can work for posts but not for taxonomies. I need that #20783 goes into core to make this happen.

  18. RavanH
    Member
    Posted 7 months ago #

    Guys, what about changing these kinds of overlapping slugs manually so it would look (for example) like:
    website.com/contact
    website.com/fr-contact (instead website.com/fr/contact)

    If you absolutely want the same slugs for translations then I guess you should go with qTranslate instead of Polylang... But why would you? It's not good for SEO.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.