• I’m a little confused with using translate_user_role() in a plugin to display role names translated on the frontend of a site. The Text domain loads find on the admin side using the ‘plugins_loaded’ hook and a dump of the labels that come to the front of the site for a custom post type is the following…

    object(stdClass)[2083]
      public 'name' => string 'Administrator<<< ??? Notes' (length=26)
      public 'singular_name' => string 'Administrator<<< ??? Note' (length=25)
      public 'add_new' => string 'Ajouter' (length=7)
      public 'add_new_item' => string 'Add New Administrator<<< ??? Note' (length=33)
      public 'edit_item' => string 'Edit Administrator<<< ??? Note' (length=30)
      public 'new_item' => string 'New Administrator<<< ??? Note' (length=29)
      public 'view_item' => string 'View Administrator<<< ??? Note' (length=30)
      public 'search_items' => string 'Search Administrator<<< ??? Notes' (length=33)
      public 'not_found' => string 'No Administrator<<< ??? Notes found' (length=35)
      public 'not_found_in_trash' => string 'No Administrator<<< ??? Notes found in Trash' (length=44)
      public 'parent_item_colon' => string '' (length=0)
      public 'all_items' => string 'Administrator<<< ??? ' (length=21)
      public 'featured_image' => string 'Image à la Une' (length=15)
      public 'set_featured_image' => string 'Mettre une image à la Une' (length=26)
      public 'remove_featured_image' => string 'Supprimer l&rsquo;image à la Une' (length=33)
      public 'use_featured_image' => string 'Utiliser comme image à la Une' (length=30)
      public 'menu_name' => string 'Administrator<<< ??? ' (length=21)
      public 'name_admin_bar' => string 'Administrator<<< ??? Note' (length=25)

    as you can see some standard strings are translated (e.g. remove_featured_image) where not explicitly set by the plugin to register strings.

    The strings I’ve set through the cpt registration include the role name and these are not showing as translated.

    Just wondering if anyone has translate_user_role() working on the frontend?

    cheers,

Viewing 1 replies (of 1 total)
  • Thread Starter Justin Fletcher

    (@justinticktock)

    it appears that the

    /**
    * @param Translation_Entry $entry
    */
    function translate_entry(&$entry) {
       $key = $entry->key();
        return isset($this->entries[$key])? $this->entries[$key] : false;
    }

    function in translations.php is providing the translations for the admin side but not the frontend so the loaded textdomains are not the same for admin/frontend ? is there any reason why they would be different for the ‘User Role’ context?

Viewing 1 replies (of 1 total)
  • The topic ‘Using translate_user_role on site frontend’ is closed to new replies.