Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is trying to translate labels for WooCommerce Subscriptions fields for the day values, like 1st or 15th. The strings are saved as placeholders inside the translatable labels.
Solution: These strings from WooCommerce Subscriptions might need additional translation.
Search for strings like "%sst", "%snd", "%srd", and "%sth" in WPML's String Translation and translate them accordingly.
If these steps do not resolve your issue, or if the solution seems outdated or irrelevant to your case, we highly recommend checking related known issues at WPML Known Issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket.

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: 

This topic contains 15 replies, has 2 voices.

Last updated by alexanderO-11 1 year, 5 months ago.

Assisted by: Andreas W..

Author Posts
May 16, 2024 at 2:15 pm #15635731

alexanderO-11

Default language is Danish and we have one additional language (English).

When WPML is activated the labels for the WooCommerce fields is in English but everything else is in Danish. Please see attached image.

How to solve this?

When WPML is deactivated the labels are in Danish as intended.

BiaB checkout mixed languages.JPG
May 16, 2024 at 7:19 pm #15636872

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

First, could you please increase your WP Memory limit to 256M? 128M is the minimum required by WPML.
Your current values are:

PHP Memory Limit 4097M
WP Memory Limit 40M
Add this code to your wp-config.php to increase WP memory:

define('WP_MEMORY_LIMIT', '256M');

Paste it just before:

/ That's all, stop editing! Happy blogging. /

Now, verify the current settings at WPML > Support > WordPress. Then complete the translation again.

These settings can be limited directly by your hosting provider, so I recommend you contact and ask them to modify them directly.
If you can get even higher values It would be great.

https://wpml.org/home/minimum-requirements/
Note: WPML needs a minimum WP Memory limit of 128M to work only under a minimal environment, which means, with a default theme and no other plugins installed.

Now, for the strings, please revise WPML > String Translation.

What might be the issue here, is that the strings are not assigned to the correct source language:
https://wpml.org/documentation/getting-started-guide/string-translation/how-to-change-the-source-language-of-strings/

Let me know if further assistance will be needed.

Best regards
Andreas

May 16, 2024 at 7:50 pm #15637023

alexanderO-11

Hi Andreas,

Just increased WP Memory limit to 256M and confirmed the settings under WPML -> Support

I have checked through all strings for WooCommerce, Gutenberg (used for the checkout page) and Divi and all English strings are assigned to the correct source language.

So the issue is unsolved.

When I browse the checkout page from a signed in user which uses the Danish language, the labels on the checkout page is correctly displayed in Danish.

So the issue is only shown for non logged in users.

Br
Jacob

May 16, 2024 at 8:04 pm #15637046

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

If you use only Blocks on the Checkout page, then the Checkout Page would need to be translated with the WPML Translation Editor.

Did you try to edit the original Checkout page, save it, and then open the WPML Translation Editor and apply the translation to 100%?

Also, when translating the page, try to locate additional strings by using the search field on the top left of the editor.

Guide:
https://wpml.org/documentation/translating-your-contents/advanced-translation-editor/#main-features-of-the-advanced-translation-editor

It might be that you are using Custom Blocks which are not yet properly configured to be translatable on the WPML Translation Editor.

In this case, we would need to create a custom XML configuration for those blocks:
https://wpml.org/documentation/support/language-configuration-files/make-custom-gutenberg-blocks-translatable/

May 16, 2024 at 8:35 pm #15637075

alexanderO-11

Hi again,

Thanks! I changed the blocks on cart and checkout to the classic view (using shortcodes) and that solved the issue regarding the translations.

One other question regarding WooCommerce Subscriptions:
How can I translate or change the format of the syncronized date renewal.

In English terms it would be e.g. "xx$ the 15th every 2nd month."

In Danish that would translate to "xx kr. d. 15. hver 2. måned."

So I have to change "15th" and "2nd" to "15." and "2.".

I just can't figure out how to do it. Do you have any ideas? 🙂

Br
Jacob

Checkout dates.JPG
Checkout dates backend.JPG
May 16, 2024 at 8:47 pm #15637120

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

This might be achievable with WPML > String Translation.

How did you manage to adjust the translations so far? Do you maybe have an example of a registered string on WPML > String Translation?

The string like "15th" or "2nd" might be registered on String Translation where you can translate them.

Maybe you might need to scan "WooCommerce Subscriptions" for new strings at WPML > Theme & Plugin Localization or search for the strings at WPML > String Translation > Translate texts in admin screens.

If this will not solve the issue, please let me know and we will split this issue into a new ticket for further investigation.

May 17, 2024 at 8:13 am #15637903

alexanderO-11

Please see attached for already translated string. The problem is that "15th" and "2nd" are dynamic values and therefore inserted by these tags: "%1$s" and "%2$s" so it's not possible to translate the "th" and "nd" parts.

I have scanned WooCommerce Subscriptions several times for strings and can't fint "15th and "2nd". Please see attached screenshot where I try to search for "15th" in all text domains. 🙂

Missing 15th in string translations.PNG
Translated string 1.PNG
May 17, 2024 at 1:59 pm #15639967

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Yes, I was guessing that it uses placeholders. So we would need to investigate where those strings are coming from and why we can not localize them for translation.

Could it be that this date is actually added by the plugin "Custom Start Date For WooCommerce Subscriptions"? Did you scan this plugin for new strings already?

I can offer a WPML Test Site on which you can install the plugin(s) and we try to recreate the issue and work on a solution. Would you be able to cooperate on this matter?

May 21, 2024 at 1:08 pm #15650603

alexanderO-11

Already tried searching "Custom Start Date For WooCommerce Subscriptions" for new strings without luck. 🙁

I'm not sure how easy it is to troubleshoot on a new test site as it's a WooCommerce extension so it's all handled through WooCommerce.com.

It's a staging site right now. Can I give you access to the current site and then do the troubleshooting from there directly? 🙂

May 21, 2024 at 1:50 pm #15651114

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

I would like to offer to have a closer look at the problem and request temporary access (wp-admin and FTP) to the staging site to investigate this issue further.

You can find the required fields below the comment section when you log in to leave the next reply. The information you provide is private, which means only you and I can see and access it.

IMPORTANT
Please be sure to make a backup copy of the website and database before allowing us access.
If you can't see the wp-admin / FTP fields, your post and website credentials are set as PUBLIC. DO NOT publish the data unless you see the required wp-admin / FTP fields.

The private response form looks like this:
hidden link

Next time you reply, click "I still need assistance."

Video:
hidden link

Please note that we are obliged to request this information individually on each ticket. We may not access any access information not specifically submitted on this ticket in the private response form.

Best regards
Andreas

May 22, 2024 at 11:56 am #15657907

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Do you mind if I install the plugin "WP File Manager" to download the plugin folder of "WooCommerce Subscriptions" so that I can take a closer look at its code?

May 22, 2024 at 12:00 pm #15657912

alexanderO-11

Does FTP access not work? 🙂

May 22, 2024 at 12:17 pm #15658065

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Ok, I am using FTP. I was just asking for the File Manager, as FTP is very slow and takes pretty long to download all the files of the plugin.

May 22, 2024 at 12:22 pm #15658089

alexanderO-11

Makes sense. Please feel free to use the File Manager plugin if that's easier for you! 🙂

May 23, 2024 at 1:08 am #15659966

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

The strings that you are trying to translate are coming from this function:

\wp-content\plugins\woocommerce-subscriptions\vendor\woocommerce\subscriptions-core\includes\wcs-formatting-functions.php line 291

function wcs_append_numeral_suffix( $number ) {

	// Handle teens: if the tens digit of a number is 1, then write "th" after the number. For example: 11th, 13th, 19th, 112th, 9311th. <em><u>hidden link</u></em>
	if ( strlen( $number ) > 1 && 1 == substr( $number, -2, 1 ) ) {
		// translators: placeholder is a number, this is for the teens
		$number_string = sprintf( __( '%sth', 'woocommerce-subscriptions' ), $number );
	} else { // Append relevant suffix
		switch ( substr( $number, -1 ) ) {
			case 1:
				// translators: placeholder is a number, numbers ending in 1
				$number_string = sprintf( __( '%sst', 'woocommerce-subscriptions' ), $number );
				break;
			case 2:
				// translators: placeholder is a number, numbers ending in 2
				$number_string = sprintf( __( '%snd', 'woocommerce-subscriptions' ), $number );
				break;
			case 3:
				// translators: placeholder is a number, numbers ending in 3
				$number_string = sprintf( __( '%srd', 'woocommerce-subscriptions' ), $number );
				break;
			default:
				// translators: placeholder is a number, numbers ending in 4-9, 0
				$number_string = sprintf( __( '%sth', 'woocommerce-subscriptions' ), $number );
				break;
		}
	}

	return apply_filters( 'woocommerce_numeral_suffix', $number_string, $number );
}

This means:

The string as example for 1st would be "%sst".
The string as example for 2nd would be "%snd".
The string as example for 3rd would be "%srd".
The strings as example for 15th would be "%sth".

You need to search those strings and translate them with String Translation.

Please give this a try and let me know the results.