Please make sure to update to WPML 4.3.6 and check our list of Known Issues before reporting

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.

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

Problem: Can't translate string programmatically Solution: In short, this is not possible as there is no such hook no more. Relevant Documentation: https://wpml.org/forums/topic/how-to-translate-taxonomy-labels-programmatically/page/2/#post-4312989

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by willR-4 2 months, 2 weeks ago.

Assigned support staff: Bruno Kos.

Author Posts
December 5, 2019 at 10:10 am #5075145

willR-4

I am trying to: Add a string translation via the WPML API (not via PO files or the String Translation interface). However, the previous methods were deprecated and it doesn't appear possible to do this any more.

Here is a ticket with a similar issue: https://wpml.org/forums/topic/internal-working-of-icl_add_string_translation/

I have checked the Hooks API and I don't see any method that replaces the old one: icl_add_string_translation.

How do I add a string translation programmatically through the new API?

Thanks

December 5, 2019 at 10:23 am #5075275

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hi,

Can you please check this answer of mine:
https://wpml.org/forums/topic/how-to-translate-taxonomy-labels-programmatically/page/2/#post-4312989

(and the thread as a whole).

In short, this is not possible as there is no such hook no more. You can register them like this:
https://wpml.org/wpml-hook/wpml_register_single_string/
https://wpml.org/wpml-hook/wpml_register_string/

But not translate it.

Regards,
Bruno Kos

December 5, 2019 at 10:34 am #5075435

willR-4

Thanks for the quick reply.

Yes, I saw those hooks but they don't allow translations to be added. That's a glaring flaw in your API since it's not always possible to use the admin interface.

December 5, 2019 at 10:55 am #5075659

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hi,

It is not used very often, personally I think I had only 1 or 2 requests in the last year, on almost 2000 tickets I covered so far. The number of these requests is mostly what decides whether this will be implemented into WPML or not, as there are other more frequent feature requests by our clients.

I can only suggest that you submit a feature request here:
https://wpml.org/suggest-a-new-feature-for-wpml/

Perhaps it ends up in queue higher :).

Regards,
Bruno Kos

December 5, 2019 at 11:13 am #5075727

willR-4

Thanks - I have done so.

I don't understand why this functionality was removed from the API. Now I'm forced to modify the database directly in order to translate my strings, which is far from ideal.

December 5, 2019 at 11:14 am #5075783

willR-4

My issue is not resolved but I will find a way around it.