I was wandering... All the translation functions (__(), _e(), _x() and so on) use the current/active language. Is there a way to get a translation from another language than the current one? For example, I'm on a French page and I want and english translation: how to?
Plugin name is a comment in WordPress. Since you can't write php code in the comments, is there a way to localize the plugin name and make it translatable?
So I need to build a pdf file starting from a php/html template (currently using mpdf library). So my-pdf-template.php file will never be shown on the website frontend, and sits on the main theme's folder. It gets loaded at some point by mpdf and used as a template to format the resulting pdf. To use wp functions on that template I'm currently importing wp-blog-header.php, and all goes fine, except l10n functions (_e, __) do not work. No errors, but simply …
I needed to translate strings on another language than the current $locale, so I need to change the locale and restore it later, and I really couldn't repeat all the code for the 30++ strings I had to translate. So I ended up with this function: function __2($string, $textdomain, $locale){ global $l10n; if(isset($l10n[$textdomain])) $backup = $l10n[$textdomain]; load_textdomain($textdomain, get_template_directory() . '/languages/'. $locale . '.mo'); $translation = __($string,$textdomain); if(isset($bkup)) $l10n[$textdomain] = $backup; return $translation; } Now, as per this famous article, I …
I am getting this error in my server error logs: [Thu Dec 11 10:06:30 2014] [error] [client 11.111.111.111] PHP Warning: Missing argument 1 for __(), called in /var/www/vhosts/mysite.org/public_html/wp-content/themes/mysite_v2.2/functions-cpt-projects.php on line 15 and defined in /var/www/vhosts/mysite.org/public_html/wp-includes/l10n.php on line 146, referer: http://www.mysite.org/wp-admin/edit.php I've never encountered this before and I'm wondering what might be causing it. The line of code it refers to in the l10n.php file is: function __( $text, $domain = 'default' ) { return translate( $text, $domain ); } I'm …
I would love to defer the loading of the script for a plugin, Simple Locator, which uses Google.maps API. However it uses wp_localize_script, which prints a wpsl_locator javascript object in the HTML page (to include options), which calls on google-maps API's google object, which isn't loaded yet. I thought that possibly I could fake it out by hacking the plugin and adding wpsl_locator = new Object() via another (deferred) script, which would include hard-coded options: wpsl_locator.map_options={[truncated]{style:google.maps.ZoomControlStyle.SMALL,}}; But one problem is …
Greetings to everyone, Is it possible to do make a single translation for many locales? Let me explain it better: Can I create a single translation file for my theme called es.po and es.mo so it matches all possible variants for locales of the Spanish language? (i.e. es_ES, es_MX, etc.) The idea here is to avoid copying the file several time to match all locales of the Spanish language.
I'm trying to improve the localization of the Bones theme. On the admin side it provides an RSS widget which uses the following code: <?php echo $item->get_date('j F Y @ g:i a'); ?> This uses SimplePie, here's the doc for the method. Which would be the best way to make this translatable?
In register_nav_menu() function is possible to pass the second parameter inside wp l10n function: register_nav_menu( 'primary', __( 'Primary Menu', 'theme-slug' ) ); but how to localize the menu items?
I'm using this method to translate strings in my template. The question is, what if some strings are dynamically loaded from the db? How can i translate them? I've been googling for days and even asked on other communities but no solutions came out. Is there any trick / workaround to achieve this?
I'm creating a new wordpress plugin dealing with the admin languages, and I'm wondering if you know how to get the list of languages provided by a specific wordpress plugin ? like this one : lang_arr = wp_get_languages("plagin-name");
If I have a library available through packagist that could be used in WordPress plugin or theme development, how should I address multilanguage support if I have a few strings that could be localized? I know that there has been some debate on composer usage in the WordPress world with very different views on it. (For example: 1, 2, 3) But my question here is not about opinions on Composer in WordPress development, rather what would be the best practice …
I am using the WordPress multisite feature with Multilingual Press Pro to create a multilingual site with linked posts. In a network activated plugin the custom post types are registered. For translating the slug I use l10n: 'rewrite' => array( 'slug' => __( 'products', 'text-domain' ) . '/%product-category%', 'with_front' => false ) This works fine. But, to link to the translated post on another site within the network, switch_to_blog() is used. As within this function no plugins are (re-)loaded, my …
I have a site which serves Ireland & England. I want to move it to Wordpress. Currently all the content is the same when you visit the site & it runs off two urls, the Irish one: mysite.ie & the english mysite.co.uk I need to show different prices based on whether the user is visiting the Irish site or the English one. Currently I do something like: $host = $_SERVER['HTTP_HOST']; if($host == "www.mysite.ie") { //show Irish prices } I don't …
Basic l10n from a .mo file generated out of PoEdit works fine. But as soon as I introduce _x, or variants, the link breaks, because as best as I can tell, PoEdit, completely ignores the context, and does not generate the corresponding msgctxt line in the .po/.mo files. _x, _ex and other variants are all added to the keywords, and PoEdit is finding and parsing _x() occurrences within my source code. It's just not capturing the context and it is …
Here is my functions.php excerpt: function get_theme_text_domain() { //Same behavior if I return the string as 'return 'whatever' $theme = wp_get_theme(); return $theme->get('TextDomain'); } function tamtando_theme_setup() { load_textdomain(get_theme_text_domain(), get_template_directory() . '/languages'); [...] } add_action('after_setup_theme', 'tamtando_theme_setup'); $theme is an array with all theme's properties: as expected. $theme->get('TextDomain') returns 'tamtando': as expected. I've noticed that the theme wasn't translating any string when using __('somestring', get_theme_text_domain()). I've then tried to see what was going on with the debugger, while executing load_textdomain(get_theme_text_domain(), get_template_directory() . …
I'm working on adding a language variable (locale) in my custom WordPress theme. I made the translation working by adding ?l=en_US to the URL. I would like to add the parameter into COOKIE, such that the site will remember the choice. Also, I would like to build a language switcher ( allow visitors to choose their own language ). How should I achieve it ? I am able to get the locale by (and load the text domain): add_action('after_setup_theme', 'DYtheme_setup'); …
I've got a few gettext() questions that are not covered anywhere in WordPress Codex but I think they are important. __('string') in THEME should be used for strings that are likely to be present also in main WordPress translation file. No textdomain necessary. Examples: one, two, submit, cancel, remove and other common words. Correct? __('string', 'textdomain') in THEME should be used for strings that are theme-specific. Examples: 'this option enables X feature'. Correct? I think it's better to make one …
I'm trying to localize the singular name of a custom post type. ... 'singular_name' => __('key', 'plugindomain') ... I created a .po and compiled it as .mo. I also loaded the translation using load_plugin_textdomain using the init action. // $directory plugin directory relative to plugins dir load_plugin_textdomain('plugindomain', false, $directory); The string are localized correctly in the backend sidebar. However, the strings are not translated in the frontend with: // $post_type returned from get_post_type_object echo $post_type->labels->singular_name; Am I doing something wrong? …
I have a multisite workpress install (v 3.3.2). I'm trying to save the WPLANG field but nothing happens. I get the confirmation message "Site options updated", but the field is still blank. And when I query it with get_locale, it get the default 'en_US'. I've tried entering in: ja_JP 'ja_JP' "ja_JP" ja-JP 'ja-JP' "ja-JP" Thanks in advance!