How do I translate this string – PHP syntax question
Don’t wrap the entire section in __(), just wrap the part you need to translate: <?php next_post_link( ‘%link’, ‘<span class=”meta-nav”>←</span> ‘ . __( ‘Nästa nyhet’, ‘mytheme’ ) ); ?>
Don’t wrap the entire section in __(), just wrap the part you need to translate: <?php next_post_link( ‘%link’, ‘<span class=”meta-nav”>←</span> ‘ . __( ‘Nästa nyhet’, ‘mytheme’ ) ); ?>
Thank you for all the help Toscho! The issue was actually quite obvious after a night of sleep. I am using WP Native Dashboard. In case you don’t know what that is, it allows you to change the language of the Admin section of the site. Considering WP Ajax is considered to be admin, it’s … Read more
First of all, mind your language please. If there are swear words in your code, please remove it before you post your code. OK, to get to your question, there is nothing wrong with your code. It looks sound. Which parent theme are you using? I have a child theme which is not localized You … Read more
Here’s how the Timber plugin handles this: $twig->addFunction( ‘__’, new Twig_SimpleFunction( ‘__’, function ( $text, $domain = ‘default’ ) { return __( $text, $domain ); } ) ); I’m guessing you’re doing something similar, in which case the reason these are being skipped is that you’re using a variable for the text domain. Have you … Read more
The order of the functions being called is wrong. With this code: sprintf( __( ‘%s’, ‘my_text_domain’ ), $title ); You are trying to translate the string ‘%s’ in the domain ‘my_text_domain’. you are then replacing the translated string for ‘%s’ (which is ‘%s’), by the content of the variable $title. Therefore your code is similar … Read more
Summary: Perhaps like me, you just need to rename, relocate and/or manually load your script/JSON translations files? So I created a block using the npx @wordpress/create-block gutenpride command, then I created the translation stuff (POT, PO, MO and JSON/JED files) and my plugin structure was like so (but some files like src/* were not included): … Read more
The function paginate_links() can return “plain”, “list” and “array” (http://codex.wordpress.org/Function_Reference/paginate_links). Just define the type as array then you’ll be to display it as you want: <?php global $wp_query; $big = 999999999; // need an unlikely integer $paginate_links = paginate_links( array( ‘base’ => str_replace( $big, ‘%#%’, get_pagenum_link( $big ) ), ‘format’ => ‘?paged=%#%’, ‘current’ => max( … Read more
Looking at the source load_plugin_textdomain takes three arguments: load_plugin_textdomain( $domain, $abs_rel_path = false, $plugin_rel_path = false ) It seems you are passing the absolute path to your language domain, as a relative path. Try: load_plugin_textdomain( ‘myplugin’, ABS_PATH_TO_LANGS_DIR);
It’s interesting idea and I think that such approach will work for you. What I would recommend you is that it will be better to use constructions like this: // $singular = 1 – for ‘me’, 2 – for ‘us’ $like_on = _n(‘Like me on %s’, ‘Like us on %s’, $singular, ‘my-plugin’); In this case … Read more
The request parsing is handled in WP::parse_request(). After that, there’s a action hook parse_request which gives you the instance of the wp object. We assume that http://www.example.com/my-custom-post-type/this-is-a-cool-article is your permalink and http://www.example.com/mon-type-de-poste-personnalise/cest-un-article-sympa ends up in a 404. So the first thing to check in your callback should be, if the wp object is in a … Read more