Wordpress WPML how to print translation - php

I'm trying to translate texts in a WordPress template file:
_e('Sport Events Organizing', 'theme-text-domain');
I've setup the translation for spanish on WPML String Translation. Checked "Finished Translation" and clicked "Save". Then I browse my site and change the language to "Spanish". But the text still appears in english. URL shows the ?lang=es parameter.
To get WPML to make the translations for this text available I had to register it with:
icl_register_string('theme-text-domain', 'Sports', 'Sport Events Organizing')
Why is the spanish translation not showing? Is there a way to debug this?

First you have to translate the strings from the admin panel , the strings wrapped in __() or _e() will appear in the wpadmin panel under the String translation module if you haven't install this plugin then first install this wpml plugin below is the snapshot in which you can see the list of strings need to be translated and from there you can edit the translations from default language to other languages
When ever you add new strings in your theme you have to refresh the translation module to get the new strings in the translation module see below attached snaps
Under Theme and plugins localization menu
And in same module you will see the plugins and there strings you can rescan them and they appear in string translation module
Hope it makes a good sense for the cycle of translation

Related

How to resolve the WPML translation issue on website?

I have one site in WordPress + DIVI + WooCommerce + WPML and other plugins.
I am facing one issue on site while WPML Translation.
Website is in 3 languages:
Dutch (Main)
Franch
English
I need to keep different string for different language for the button text in one module of the DIVI.
I selected English language from adminbar
When I go to Theme Builder -> Global Header and I change the button text to "XYZ", it is reflecting only on English page, that is fine.
Now when I change the language to Dutch
and When I go to Theme Builder -> Global Header and I change the button text to "ABC", then it is reflecting on Dutch and French pages (English page is fine with "XYZ"), this must reflect on Dutch page only If I change the button by selecting the Dutch language
Now when I change the language to French
and When I go to Theme Builder -> Global Header and I change the button text to "DEF", then it is reflecting on Dutch and French pages (English page is fine with "XYZ"), this must reflect on French page only If I change the button by selecting the French language
I checked for String Translation, and updated translation for Dutch and French but it is not reflecting on front side.
When you're switching languages and modifying it manually like this, you are messing up the WPML logic that's handling translations. Page builders are tricky to translate. That's why you need to follow the recommended process.
From documentation:
To translate the Divi site header or footer you created using the Divi
Theme Builder, follow these steps:
Go to WPML > Translation Management. Choose Header Layout, Footer Layout, or Body Layout from the Type dropdown, then click the Filter
button.
Choose which headers or footers you want to translate, the languages you want to translate them into, and click Translate
selected content.
Go to WPML > Translations to take and translate the global header using the Advanced Translation Editor.
Try this with a fresh site with a new global Divi header/footer from scratch.

Loco Translate not shows all translations

I am using Loco Translate to translate wordpress and woocommerce. Great plugin, but unfortunately some string translations are not visible/working on the frontend at the checkout page and cart. Could this be a child team problem?
Strings are know in Loco Translate and correctly translated, they are only not showing up at frontend.
Translation String issues:
Have a coupon? Click here to enter your code.
Flat rate:
Subscribe to our newsletter
Site www.narwal.shop/checkout
Help is appreciated.
Go to wp-content and uploads directory. create a new directory and name it as same as the plugin name. then create a new directory and name it languages.
now upload your .po and .mo files in it.
the problem is solved!
Force WP to load the language file from languages/loco/themes/.. directory, like this inside functions.php:
add_action ( 'wp', 'load_translations' );
function load_translations() {
load_theme_textdomain( 'theme-name-here' );
}
Update: you should contact the creator of the (child) theme.
Every single component that displays text (i.e.: almost all of them), including themes and plugins, need to have included multilingual support for it to work.
Woocommerce does it, but you might have other components that do not. If you have a custom theme, that would be the first thing I'd check.
Unfortunately, if this is the case there is nothing you can do about it other than not use it, accept that that part of the site will not be translated or ask the developer who made them to put in the extra work to add multilingual support.
See also: https://localise.biz/wordpress/plugin/child-themes
In my case it was a wordpress language problem. I resolved this by changing it from English to my target translation language. To achive this in your wordpress panel go to: Settings -> General -> find language and change it.

WordPress WooCommerce words not translated

I am trying to translate woo-commerce using WPML. I am translating woo-commerce in Chinese languages using .mo and .po files. Everything is translating fine but some words is not translted like quantity, Paypal, view cart etc. I try to translate it using string translator but not effected.
Any suggestion please.
Thanks
In WPML -> Theme and plugin localization please select the option "Translate the theme and plugins using WPML's String Translation" option. After that, scrolldown and click the Scan buttons for both themes and for plugins.
Finally, after the operation completes, please go to WPML -> String translation and search for the strings you want to translate.

Wordpress theme with second language

I didn't find any learn for Multi-Lingual !
1.How to use function _e() ?
2.What's text_domain ? How can i set text_domain ?
e.g:
_e('Mine','text_domain')
in english returns "Mine"
in example language is "imja"
How to set "imja" ?
text_domain is a distinction inside WordPress that allows you to see which plugin or theme text comes from. The text domain can be any string that you want but as a best practice it should be a machine name of the theme or plugin you are building.
So if I had a plugin named MyPlugin I would translate text using any of the WordPress translation functions like:
print __("Translateable Text", "MyPlugin");
_e("Text that is translated then echoed", "MyPlugin");
For WordPress to render these strings in another language, in WordPress 4.0 and above, you can change the language at Settings > General > Site Language and your site will show the text in that language if available.
You will need language files for the language that you wish to change to, and if a plugin or theme doesn't offer a translation for your chosen language it will be rendered in the default language.
There are many tools and plugins for editing the .po/.mo files that hold the translations in WordPress. Some of those can be found in the WordPress translation handbook.

How to make a wordpress theme that supports only 1 .po file to support 2

i am trying to make my website support 2 languages that users can switch between them, i bought a theme that has a language directory with .po files such as en_US.po fr_FR.po and more. i copied the english file and translated it into Arabic, in order to apply the Arabic translation i have to rename the ar_EG.po to en_US.po which leaves me with 1 language option and i need to have both Arabic and English. Is there a way that i can make my website switch between 2 .PO files instead of 1 or can i make a new folder inside my word press installation with the same website but with the other language file working and both of the websites linked to the same database?
There are various plugins to manage multilanguage sites; I would personally recommend Polylang since it's free, very easy to use and makes a smart use of WordPress APIs so it's developer friendly, if you would need that. Also, every content gets its own URL, which it's good for SEO.
After installation, go into Settings → Languages to define the languages of your site. The plugin provides a widget that will enable your visitors to change the language of the site, as well as an special nav menu item.
You should keep the theme translation as ar_EG.po; the plugin and language switcher that comes with it will take care of loading the appropiate language file for the theme.
ya elipelavinz is right that plugins name is polylnag
if you want to tranlate your theme caption use codingstyleloalization
codingstylelocalization translate only __() caption or _e() function

Categories