Viewing 7 reply threads
  • Author
    Posts
    • #3392

      Hello!
      This is related to this post: https://piklist.com/support/topic/translate-tab-names-in-comments-header/

      I was trying to translate the Metabox’s title but as Steve said they still aren’t ready to be translatable.

      So I wrote a code that allow it, and here is it:


      add_filter( 'piklist_get_file_data', 'allow_metabox_text_domain' );
      function allow_text_domain( $data ) {
      $data['text_domain'] = 'Text Domain';

      return $data;
      }

      add_filter( 'piklist_add_part', 'config_metabox_title_text_domain' );
      function config_metabox_title_text_domain( $data ) {
      if ( !empty( $data['text_domain'] ) ) {
      $data['name'] = __( $data['name'], $data['text_domain'] );
      }

      return $data;
      }

      Now just add the new option Text Domain in the comment header!
      See the attached screenshot.

      Attachments:
      You must be logged in to view attached files.
    • #3394

      Ups, the function’s name is wrong.


      add_filter( 'piklist_get_file_data', 'allow_metabox_text_domain' );
      function allow_metabox_text_domain( $data ) {
      $data['text_domain'] = 'Text Domain';

      return $data;
      }

      add_filter( 'piklist_add_part', 'config_metabox_title_text_domain' );
      function config_metabox_title_text_domain( $data ) {
      if ( !empty( $data['text_domain'] ) ) {
      $data['name'] = __( $data['name'], $data['text_domain'] );
      }

      return $data;
      }

    • #3395
      Steve
      Keymaster

      Good idea! Can you generate a PO file with this technique? How have you translated the comment blocks?

    • #3396

      Hi Steve!

      Well after hours of errors I found this article: http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/

      In short we can’t use variables inside of __( ) and my plan didn’t work well.

      But I found another way to do it and it is working very well!

      I finished the first version of a plugin using this technique right now and I will attach it as private here so you can review my code.

      I plan to publish this plugin as free at WordPress.org when it is ready.


      Well .zip aren’t allowed here so I will send it to your mail Steve.

    • #3397
      Steve
      Keymaster

      Zip files aren’t allowed to be uploaded. Can you email it to [email protected]?

      Can’t wait to see it!

    • #3398

      Sent! 🙂

    • #3399

      Sent a new one Steve. The first one contains a variable name error and didn’t work, sorry!

    • #4076
      bicho44
      Member

      Hey any news about this?

      I really apreciatte a follow up 😀

      Thanks in advance

      Fede

Viewing 7 reply threads
  • You must be logged in to reply to this topic.