WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
Register taxonomy so that it's name can be translated (10 posts)

  1. bitbusters
    Member
    Posted 2 years ago #

    Hi all! (my first post at wp.org)
    Polylang is a great plugin for multilingual sites - thanks for creating it! I'm doing the r&d work to allow my taxonomy names to get translated. I have found (and lost...) a page with a script for generating the "register taxonomy" function in such a way, I think, that the names of taxonomies were put into those __('') functions, to get translated. Do you think it is possible?
    For SEO purposes, I think your plugin is great, as the slugs for taxonomies, posts, pages are translated / separate for each language.
    But for the work to be complete, generated taxonomy names, labels, plurals, and other forms should also go to the .mo and .po files to be translated. Another plugin, xili-language claims to offer similar functionality, but I'm still testing if it really does the job.

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

  2. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    Yes. you can use something like:

    register_taxonomy(
      'mytaxonomy',
      'post',
       array(
        'name'=>__('mytaxonomies in English'),
        'singular_name' => __('mytaxonomy in English'),
        'edit item'=>__('edit mytaxonomy in English)
      )
    );

    To be completed for other labels. Everything is well explained in the codex
    This does not depend on Polylang or other similar plugins. This is the right way to write an internationalized plugin which can then be translated using po and mo files.

  3. bitbusters
    Member
    Posted 2 years ago #

    OK, sorry: my post was far from precision and optimal placement (at Ultimate Taxonomy Manager's forum...), but still - thanks for answering. So let's give my wording another chance:

    If the taxonomies are registered by Ultimate Taxonomy Manager plugin - Code Styling Localisation (the plugin I use to create .po translation files and generate .mo files from them) finds no strings to scan the strings.
    Also, when I create the .po files in the child theme folder, it does not list my child theme as if there was nothing to translate...

    Puting data structure and algorithms into the theme is just intrinsically wrong for me...

    Where do I register the taxonomies, and corresponding algorithms not to lose them when changing themes? And not to open the php file at every website serving?
    Thanks for clues...

  4. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    Well, I explained things for static strings. The plugin Code Styling Localization does work only for static strings too. Here your goal is to translate user defined strings. This is technically possible with Polylang 0.6+ but you will need to modify the code inside the Ultimate Taxonomy Manager plugin to tell him to translate strings with Polylang functions. So the caveat is that each time you update the Ultimate Taxonomy Manager plugin, your modifications will be erased (except if you convince the author to include these modifications in the plugin !).

    So you will need WP 3.3+ + Polylang 0.6 or WP 3.1+ + Polylang 0.6.1 (there is a bug in 0.6 which prevents string translations to work with WP versions older than 3.3)

    The modifications refer to Ultimate taxonomy manager 1.2.

    Edit the file ultimate-taxonomy-manager.php and insert the following code at line 466 (just before register_taxonomy...)

    foreach ($xy_tax['args']['labels'] as $key=>$str){
    	if (is_admin())
    		pll_register_string('taxonomy manager', $str);
    	else
    		$xy_tax['args']['labels'][$key] = pll__($str);
    }

    Once it is done, you can create taxonomies as you usually do and translate labels in the Polylang strings translation panel.

  5. bitbusters
    Member
    Posted 2 years ago #

    Thanks! It works!
    Only for the core category and post tag I needed to recode it to use the translated labels from translation files.

  6. bitbusters
    Member
    Posted 2 years ago #

    Gosh,
    There is a serious problem with presentation of custom taxonomies of custom posts ("services") - they are not displayed in the editor. (it says "none").

    For the posts created today, all taxonomy terms in their respective taxonomy columns of the editur are shown as assigned.
    I am using some taxos to describe the services, like Prio and Detail Level, so a service can only have single priority and detail level, I have therefore chosen to display dropdowns in the editor.

    Now, for all posts marked via Polylang as Polish, the Polish taxonomies assigned to them, are shown in editor as "none". But these data/assigned taxonomies are there, because I can filter/display the content from the frontend. Also clicking "edit" (post editor) does not display proper data.
    What I have also noticed, there is a post, which has both English and Polish taxonomy terms assigned.

    I have created a post (custom), saved and afterwards:
    http://bit.ly/xXEvEx - editor
    http://bit.ly/wbKyGS - custom posts list

    If you could help a beginner out, I appreciate it.

  7. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    Probably both plugins are not compatible. It was already quite a lot of work to make categories and post tags metaboxes work correctly with Polylang. So unfortunately there are minor chances that it works with metaboxes created by other plugins without extra coding.

  8. bitbusters
    Member
    Posted 2 years ago #

    :/ I understand, there are endless combinations...
    Or maybe the problem's not in the plugin compatibility, but
    my attempts to create a child theme with its own textdomain caused the problem?
    http://wordpress.org/support/topic/translatable-child-theme-same-or-different-textdomain
    I have created a test post yesterday, and everything is OK today, I'll give it a try...

  9. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    I m not expert enough in child themes to answer your other question.

    But I do not believe it is related with the problem reported here as it is in the backend.

  10. Michel - xiligroup dev
    Member
    Posted 2 years ago #

    in xili-language, non-hierarchical taxonomy clouds are managed inside and by xili-tidy-tags (need specific instantiation). dev.xiligroup.com website uses theses features. http://dev.xiligroup.com/?cat=951&lang=en_us&post_type=xilifunctions.
    M.
    Author of trilogy - xili-language, xili-tidy-tags and xili-dictionary

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic