Tagged: custom code, metabox title, suggestion, translate
- This topic has 7 replies, 3 voices, and was last updated 6 years, 6 months ago by
bicho44.
-
AuthorPosts
-
-
March 6, 2015 at 7:12 pm #3392
Darlan ten CatenMemberHello!
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. -
March 6, 2015 at 7:20 pm #3394
Darlan ten CatenMemberUps, 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;
}
-
March 7, 2015 at 11:33 am #3395
SteveKeymasterGood idea! Can you generate a PO file with this technique? How have you translated the comment blocks?
-
March 7, 2015 at 10:50 pm #3396
Darlan ten CatenMemberHi 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. -
March 7, 2015 at 10:56 pm #3397
SteveKeymasterZip files aren’t allowed to be uploaded. Can you email it to [email protected]?
Can’t wait to see it!
-
March 7, 2015 at 11:01 pm #3398
Darlan ten CatenMemberSent! 🙂
-
March 7, 2015 at 11:10 pm #3399
Darlan ten CatenMemberSent a new one Steve. The first one contains a variable name error and didn’t work, sorry!
-
July 25, 2015 at 4:28 pm #4076
bicho44MemberHey any news about this?
I really apreciatte a follow up 😀
Thanks in advance
Fede
-
-
AuthorPosts
- You must be logged in to reply to this topic.