This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Tagged: String Translation
Related documentation:
This topic contains 14 replies, has 2 voices.
Last updated by Riffaz 1 year, 8 months ago.
Assigned support staff: Riffaz.
Author | Posts |
---|---|
May 11, 2019 at 2:39 pm #3790685 | |
tomasD-10 |
I have strings in functions.php which are displayed in e-shop. Here is the code: <?php add_action('woocommerce_after_shop_loop_item','show_stock', 10); function backorder_text($availability) { foreach($availability as $i) { //$availability = str_replace('Dostupné na objednávku', 'Na objednávku do 3 - 7 týdnů', $availability); $availability = str_replace('Dostupné na objednávku', 'Na objednávku do 3 - 7 týdnů', $availability); I need to translate phrases "na skladě" and "'Dostupné na objednávku', 'Na objednávku do 3 - 7 týdnů'" URL of site: hidden link |
May 12, 2019 at 11:02 am #3792845 | |
Riffaz Supporter Languages: English (English ) Timezone: Asia/Colombo (GMT+05:30) |
Hi, Thank you for contacting WPML support. Please refer : After the changes do not forget to click on WPML > Theme and Plugins Translations. Look for 'Strings in the theme' and click on the 'Scan the theme for strings' button. Let me know how it goes. Regards, |
May 12, 2019 at 3:16 pm #3793191 | |
tomasD-10 |
Hello, |
May 13, 2019 at 10:25 am #3796931 | |
Riffaz Supporter Languages: English (English ) Timezone: Asia/Colombo (GMT+05:30) |
Hi, Follow this structure : echo '<div class="remaining">' . number_format($product->stock,0,'','') . ' ' . __('na skladě', 'my-text-domain') . '</div>'; just replace 'my-text-domain' with the domain name of yours. Let me know how it goes. Regards, |
May 13, 2019 at 12:18 pm #3798029 | |
tomasD-10 |
Hello, |
May 13, 2019 at 4:38 pm #3800643 | |
Riffaz Supporter Languages: English (English ) Timezone: Asia/Colombo (GMT+05:30) |
Hi, Ok, let me know your site login details. Also, let me know how and where to check this function. Regards, |
May 14, 2019 at 10:21 am #3805849 | |
Riffaz Supporter Languages: English (English ) Timezone: Asia/Colombo (GMT+05:30) |
Hi, I escalated to this to our second tier support. Regards, |
May 15, 2019 at 6:48 am #3812633 | |
Riffaz Supporter Languages: English (English ) Timezone: Asia/Colombo (GMT+05:30) |
Hi, They replied: in your suggested code, you have one more ' element that should be removed. echo '<div class="remaining">' . number_format($product->stock,0,'','') . ' ' . __('na skladě', 'my-text-domain') . '</div>'; should become echo '<div class="remaining">' . number_format($product->stock,0,'','') . __('na skladě', 'my-text-domain') . '</div>'; Could you please check this and let me know? Regards, |
May 15, 2019 at 2:53 pm #3818029 | |
tomasD-10 |
Hello, I mean this one: function backorder_text($availability) { foreach($availability as $i) { //$availability = str_replace('Dostupné na objednávku', 'Na objednávku do 3 - 7 týdnů', $availability); $availability = str_replace('Dostupné na objednávku', 'Na objednávku do 3 - 7 týdnů', $availability); In english it shows only in "Available on backorder" instead of "On order within 3 - 7 weeks." |
May 16, 2019 at 5:54 am #3822071 | |
Riffaz Supporter Languages: English (English ) Timezone: Asia/Colombo (GMT+05:30) |
Hi, Great, it works now. The second one needs a simple hack. Regards, |
May 16, 2019 at 6:43 am #3822261 | |
Riffaz Supporter Languages: English (English ) Timezone: Asia/Colombo (GMT+05:30) |
Hi, Add replaced that with this $availability = str_replace('Dostupné na objednávku', __( 'Na objednávku do 3 - 7 týdnů', 'text-domain') , $availability); and it shows up in the String Translation : hidden link Anyhow, you are trying to replace programmatically a string that your theme or something else already sets. Regards, |
May 16, 2019 at 7:33 am #3822635 | |
tomasD-10 |
Hello, |
May 16, 2019 at 8:11 am #3823017 | |
Riffaz Supporter Languages: English (English ) Timezone: Asia/Colombo (GMT+05:30) |
Hi, Your function has no this phrase: Available on backorder |
May 16, 2019 at 8:35 am #3823283 | |
tomasD-10 |
The code I sent do this: Available on backorder (English string in Woocomerce) = Dostupné na objednávku (Czech) and the code changes Dostupné na objednávku for another text. But it also overwrite the source code "Abailable on backorder". I think it is too complicated to translate this code. We will keep it. Thank you for your help! |
May 16, 2019 at 8:55 am #3823397 | |
Riffaz Supporter Languages: English (English ) Timezone: Asia/Colombo (GMT+05:30) |
Hi, I checked with the development team and they say this will require a lot of conditional and advanced PHP coding which is out of the support scope. Regards, |