Support » Plugin: amr users » Language change of meta field First Role

  • Resolved johnths2

    (@johnths2)


    I have a little problem with the plugin “amr users”.

    I have translated the plugin into Dutch and it works almost fine, but there is a little bug.

    When i rebuild the cache of my users list, the fields “First Role” are in Dutch language, but after i logged off and i logged on again to my WordPress site the language in the “First Role” fields is in English and i have to rebuild the cache again to have it in Dutch.

    Do you now what good be the problem ?

    Greetings John Visbeen
    The Netherlands

Viewing 7 replies - 1 through 7 (of 7 total)
  • After rebuilding cache the fields are in Dutch
    First Role
    ———-
    Schrijver
    Abonnee
    Schrijver
    Beheerder

    After logout en login to the website, the field are in English
    First Role
    ———-
    Contributor
    Subscriber
    Contributor
    Administrator

    Plugin Author anmari

    (@anmari)

    Hi,

    Shew – finally figured it out. WordPress does not load the admin text domain in the frontend.

    Plugin applies wordpress function translate_user_role to the role names. But since wp has not loaded the translation strings, when one does a refresh in front end, the roles are not translated. If it gets it from data cached in the backend, then it is translated!

    https://wordpress.org/support/topic/user-roles-are-not-translated-on-the-frontend/

    Quick Fix: add code some where – theme functions.php or custom site specific plugin? until I figure where best to add this. It is only needed when roles are being shown on frontend, so I have to decide whether to just load for everyone all the time, or put some conditional code in.

    add_action( 'init', 'load_admin_textdomain_in_front' )
    function load_admin_textdomain_in_front() {
        if ( ! is_admin() ) {
            load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' );
        }
    }

    Thanks for flagging this!

    It’s not working for me.
    I have put the code on different places in my themes functions.php and when i start wordpress the page will not load.

    Plugin Author anmari

    (@anmari)

    version 4.4 with fix – working for me – just uploaded

    It works finaly.

    I put it direct after the theme setup in the function.php

    —————————
    And i put “;” after
    add_action( ‘init’, ‘load_admin_textdomain_in_front’ ) ;

    It was not in the presented code.

    Thanks…!

    • This reply was modified 4 months, 4 weeks ago by  johnths2.

    anmari,

    Great version 4.4 with fix – working for me also!

    Thanks for the very fast response!!

    Problem solved!

    Greetings, John

    Plugin Author anmari

    (@anmari)

    Dang ! lost a semi-colon when pasting… thanks for picking up.

    My daughter has just started info systems as part of a commerce degree – she says to me ‘SQL is so hard – you have to have everything exactly right else it doesn’t work”

    Too right – unlike your mother who can intuit what you might mean!

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.