Skip Navigation

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 9 replies, has 2 voices.

Last updated by Eran Helzer 1 year, 3 months ago.

Assisted by: Eran Helzer.

Author Posts
July 17, 2023 at 2:49 pm #14050735

ruiG-5

I have develop my own GA4 plugin and i was able to convert text to string (screenshot_1).
I was also able to translate all measurement_id + api_secret (screenshot_2).

But looks like the code is only adding the "main" measurement id + api_secret.

Any ideas whats missing?

Screenshot_1.jpg
July 18, 2023 at 7:57 am #14055491

Eran Helzer
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Hi,

I am not entirely sure what you mean by "the code is only adding the "main" measurement id + api_secret".

Please provide me with more information, such as:
- How are you registering these strings for translation
- What the correct outcome should be
- You mention two screenshots in your question, but only one is attached. Please add more screenshots showing the issue, and what you have already done

Also, please make sure you are following our documentation, if you aren't already, on developing WPML compatible plugins:
https://wpml.org/documentation/support/translating-the-theme-you-created/
https://wpml.org/documentation/support/achieving-wpml-compatibility-for-your-themes-and-plugins/#6

July 18, 2023 at 10:55 am #14058387

ruiG-5

Screenshot_2 attached.

I don't think i'll need to add xml to do what i am trying to do. Let me explain:

  • I have successfully added text to strings
  • I have translated my 3 strings
  • All 3 strings translations are stored in the database (already checked that)

The problem is when i am in a different language WPML should change the string to their translation language.

In this case:

  • EN: original string
  • DK: translated string

And so on. I have done this in order to have google analytics pro with each different UA code. Now i am trying to do the same with GA.

What other information do you need?

Screenshot_2.jpg
July 18, 2023 at 8:42 pm #14062035

ruiG-5

Why this ticket is taking so long to have replies?

July 19, 2023 at 5:08 am #14062493

Eran Helzer
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Okay, so the issue is that your plugin only uses the default language values, although the strings are translated correctly.

In order to know what is incorrect/missing from your code, I need to see it.

If you prefer, you can grant me admin access to your site and direct me to the exact files where the incorrect values are used and I will take a look.

I have set your next reply to be private so you can share credentials there.
Remember that it is always better to create a new admin user for me, then when we are done you can delete it.

July 20, 2023 at 6:26 am #14069213

Eran Helzer
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

Perfect, thank you.

After looking at the code, I believe I understand why only the default language values are used.

The woocommerce_admin_fields() function uses the WooCommerce settings. The translations are stored and maintained by WPML, thus not really related.

I will ask what the correct way of doing this is, however I do think it will be by using WPML's coding API and fetching the strings from the String Translation table.

In the meanwhile, you can take a look here and check out our documentation:
https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/#hook-617933

I will update you when I have news.

July 20, 2023 at 6:47 am #14069287

ruiG-5

https://woocommerce.com/products/woocommerce-google-analytics-pro/

I have used this plugin for the past 7 years and I have did the same thing and everything works.

After checking their code, there's no reference anywhere about doing string translations or having custom code to make it compatible with wpml. In fact, I have other support tickets related to this situation with (GA pro).

Anyway, I'll be waiting to hear back from you. Would be great if you could move fast, since I'm not receiving any data from other domains.

July 20, 2023 at 6:54 am #14069357

Eran Helzer
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

I think there may be some miscommunication.

This is your plugin, correct? - Flex Lab | Google Analytics for WooCommerce (GA4)

In the code, the woocommerce_admin_fields function is called. The function does not seem to use localized values, since it gets them from the wp_options table where translations are not stored.

I haven't looked at the https://woocommerce.com/products/woocommerce-google-analytics-pro/ code. Your code calls a function that does not retrieve localized values.

Please confirm for me that we are indeed talking about the same issue.

July 20, 2023 at 7:06 am #14069387

ruiG-5

Yes, we are talking about the same thing. I just gave you an example. You can check Google analytics pro (it's also in my server) to compare or to find out why one can do this and the other can't.

July 20, 2023 at 8:56 am #14070577

Eran Helzer
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+02:00)

I am sorry, but debugging custom code is outside of our support policy.

I will suggest you use our Hooks API to get the value in the current language, something along the lines of this should be what you are looking for:

apply_filters( 'wpml_translate_single_string', 'yes', 'admin_texts_woocommerce_google_analytics__use_google_tag', 'woocommerce_google_analytics__use_google_tag', apply_filters( 'wpml_current_language', null ) );

This does not mean we are taking responsibility for this custom code, this is just a suggestion you can take, or not.

I would like to direct you to our documentation. Please take a look and see if there are other functions that would suit you better:
https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/