Translate arguments of a user added custom code [closed]

Because you are hardcoding the link, you will need to use icl_link_to_element() function and wrap any text you want to translate inside a gettext function: <?php icl_link_to_element( ‘ID_of_your_news_page’, ‘page’, ‘<h4>’ . __(‘News’) . ‘</h4>’ ); ?> This way you will get the correct version of the link based on the current language with the text … Read more

Post types translation

Use get_post_types( [‘public’ => TRUE ], ‘objects’ );. This will return the already translated post type labels and other information. Example for tests: add_action( ‘wp_footer’, function() { $post_types = get_post_types( [ ‘public’ => TRUE, ‘_builtin’ => TRUE ], ‘objects’ // complete information, not just the name ); foreach ( $post_types as $slug => $arguments ) … Read more

How to translate wordpress backend to another language

Just so you know, a Sinhala translation is already in progress. https://si.wordpress.org/ http://wpcentral.io/internationalization/si/ Maybe it would be a good idea to join that team. First, you need to create .po files for the Sinhala translation of WordPress. You’re going to need four of these files. They will be called si_LK.po admin-si_LK.po admin-network-si_LK.po continents-cities-si_LK.po If all … Read more

Programmatically choose language for translation

After looking at the l10n.php I found a way to switch the textdomain using the unload_textdomain function. So I created a simple switch function switch_textdomain( $domain, $newLocale){ /* This will only change the textdomain, not the locale. It will only affect what kind of language will be used for the _e(), _(), __() commands for … Read more

How to use esc_attr__ with custom translation function?

As your function returns the translated string, you could pass the translation function as parameter for esc_attr() and esc_attr_e(): esc_attr__( __myfunction( ‘no_comments’ ) ); esc_attr_e( __myfunction( ‘no_comments’ ) ); But esc_attr__() and esc_attr_e() will perform translation tasks that you don’t need because you handle the translation at your own, so I think it is better … Read more

Trying to localize a Underscores starter theme [duplicate]

Please note how the translation works: The Text Domain should be same in all the places of your theme. On this page you can see the Theme’s text domain setup: load_theme_textdomain( ‘_s’, get_template_directory() . ‘/languages’ ); And on this page (and many in this theme), you can see the implementation of the Text Domain: _e( … Read more

Override translation of 1 word

Since your problem resolves around the fact that the WP theme developers used a function that doesn’t have any hooks so we could easily alter the output, you’re going to have to copy & paste the following code in your functions.php file function human_time_diff( $from, $to = ” ) { if ( empty( $to ) … Read more

WordPress Translations

.po and .mo files are for translating strings in code files. For translating post content use a translation plugin. I’ve used a few and find WPML to be the best in many aspects. Incidentally, they have a built-in workflow for translating both content and strings in code files.