Theme's strings translation problem

May 2014 WordPress Theme
GK User
Sat Feb 27, 2016 6:22 pm
Hello.

I use WMPL plugin to make Storefront multilingual (two languages). WPML does a pretty good job translating all content but I really have troubles with translating some theme's strings. The translated strings are shown always in English. Seems like some text function doesn't work properly.

For example a "Product Details" button in Catalogue Listing (the sting itself is located in ../themes/StoreFront/gavern/wc-functions.php) with the following code:
Code: Select all
//product details button on catalog pages
if(!(get_option($gk_tpl->name . '_woocommerce_show_details_button', 'Y') == 'N')) :
   function add_product_details_button() {
   $product_id = null;
      echo '<a class="btn wc-product-details" href="'.get_permalink($product_id).'">'.__('Product details', GKTPLNAME).'</a>';
   }
   add_action( 'woocommerce_after_shop_loop_item', 'add_product_details_button' );
endif;


The WPML sees that string and I can apply the translation, but it always shows English version on frontend.
Do you guys use any text filters described [url]here: https://wpml.org/forums/topic/string-tr ... orking-12/[/url]? Because I coundn't find any. The same thing with other strings, like like %d item and %d items for the Cart widget. Is any workaround?

Thank you!
User avatar
Junior Boarder

Joshua M
Sun Feb 28, 2016 5:30 pm
Hi,
Could you please provide me with a URL to your website and back-end access via PM (click the “Private Message” text underneath my avatar) so that I may analyze it?
User avatar
Moderator

GK User
Mon Feb 29, 2016 1:49 pm
Dear Joshua,

I've sent you an PM. But seems like I fount a solution. The part of the code I've provide earlier needs to be changed a bit:

from:
Code: Select all
echo '<a class="btn wc-product-details" href="'.get_permalink($product_id).'">'.__('Product details', GKTPLNAME).'</a>';


to:
Code: Select all
echo '<a class="btn wc-product-details" href="'.get_permalink($product_id).'">'.__('Product details', 'GKTPLNAME').'</a>';


The GKTPLNAME needs to be in ''. I've changed that, deleted string from WPML and rescanned the template. And got that string translated under the GKTPLNAME domain. By default all strings are visible under the 'default' domain in WPML of the template which don't work on translation. I assume that there are lots of such lines to modify across the whole template. What should I do in this case? Maybe you guys need to update the template with the correct syntax? I don't really want to modify all of this so after the next update I loose everything.

Thanks.
User avatar
Junior Boarder

GK User
Mon Feb 29, 2016 2:03 pm
Here is the reference for the get-text calls with the correct text-domains argument:
https://wpml.org/documentation/support/ ... alization/
User avatar
Junior Boarder

GK User
Mon Feb 29, 2016 2:05 pm
User avatar
Junior Boarder

GK User
Mon Feb 29, 2016 2:24 pm
Or this line in functions.php doesn't work properly in some way:
Code: Select all
// define constant to use with all __(), _e(), _n(), _x() and _xe() usage
define('GKTPLNAME', $gk_tpl_name);


Please advise. Thank you.
User avatar
Junior Boarder

GK User
Mon Feb 29, 2016 4:00 pm
Seems like the only right way to use .mo files to translate these strings..
User avatar
Junior Boarder

Joshua M
Tue Mar 01, 2016 10:35 am
Hello,
We'll contact with wpml team and check the issue, because the StoreFront was tested recently we didn't receive any information about this kind of issues.
User avatar
Moderator


cron