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

Last updated by Aurelien 4 years, 3 months ago.

Assigned support staff: Bigul.

Author Posts
August 15, 2017 at 8:02 am #1343390

Aurelien

Hello,

Sure, here is the context :

- I send data to a custom endpoint inside the WP Rest API.
- For this specific data, I want to send some translated strings.
- All of this strings are translated with the translation plugin by WPML.

So the way that I use :
- I register all strings with this code :

$translations = array(
'Tout',
'Informations',
'Actualités',
'Agenda',
'Réseaux sociaux',
'Médias'
);

$package = array(
'kind' => 'My-Package',
'name' => 'my_package',
'title' => 'My-Package',
'edit_link' => '',
'view_link' => ''
);

foreach($translations as $translation):
do_action('wpml_register_string', $translation, $translation, $package, $translation, 'LINE');
endforeach;

- After to apply this code, I can see all my strings inside the string translation plugin inside the wordpress backend.
- In my custom function resource endpoint, I setup the current language according to en or fr. The post or other data are correctly translated.
- Then, I try to use this code to translate some strings :

$t_all = apply_filters('wpml_translate_string', 'Tout', 'Tout', $package);

- But it doesn't work, only the fr version who is the default one is showed. I didn't get the english version.

Thanks a lot !

August 16, 2017 at 8:14 am #1344228

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thank you for the details. I have two more requests for tracking the issue.

1) Please share me the code you are using for changing the current language

In my custom function resource endpoint, I setup the current language according to en or fr. The post or other data are correctly translated.

2) Are you getting the expected result with the *wpml_translate_single_string* API? Please check the following sample.

$custom_textarea =  apply_filters('wpml_translate_single_string', *Tout*, 'My-Package', 'Tout', 'en' );

https://wpml.org/wpml-hook/wpml_translate_single_string/

--
With Regards

Bigul

August 17, 2017 at 7:13 am #1344985

Aurelien

Hello Bigul,

Here is the code who change the language, for the moment it's a static version, I have hardcoded the 'en' variable as you can see to force to get the english version who is not the default language on our website :

global $sitepress;
$sitepress->switch_lang('en', false);
...
The code who return post content and string translations.

I try your line but it doesn't work.
I found a weird thing, inside the string translation plugin the domain of my new string translation is called : my-package-my_package instead to my_package. Maybe this is the error ?

Aurélien.

August 17, 2017 at 1:51 pm #1345328

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thank you for the information. We have to specify the correct string *Package name*/*Domain name* while using 'wpml_translate_string/wpml_translate_single_string APIs.

Are you getting the expected result with the following code?

$custom_textarea =  apply_filters('wpml_translate_single_string', *Tout*, 'my-package-my_package', 'Tout', 'en' );

Please let me know your feedback.

--
With Regards

Bigul

August 18, 2017 at 5:29 am #1345798

Aurelien

Hello,

Yes Still have the issue with this new code with the new domain.
I don't understand why I get only French version instead to get English.

With Regards,
Aurélien

August 18, 2017 at 12:01 pm #1346031

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi ,

Thank you for the updates. I would like to access admin area of your site for further checking. Please fill the private details fields after a full site backup. Check the following links for more details about private information sharing.

hidden link

https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

Please allow me to make a duplicator copy of your site using Duplicator plugin(https://wordpress.org/plugins/duplicator/) for debugging the issue locally.

--
With Regards

Bigul

August 22, 2017 at 3:28 pm #1348413

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thank you for the login information. But I am unable to make a duplicator package because of the file permissions. Please check the attached image for more details.

Also, I am not able to access the plugin list of the site.

--
With Regards

Bigul

2017-08-22_2049.png
August 29, 2017 at 5:29 am #1352923

Aurelien

Hello Bigul,

The duplicator plugin is enable for you.

Thanks for helping.

August 29, 2017 at 6:40 am #1352956

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thank you for the updates. But I am unable to make a duplicator package. It is showing *Bad interrupt* message for me. Please check the attached image for more details.

I have a request. Please grant me access to the Network Admin side. So I can activate and try with Duplicator Pro.

--
With Regards

Bigul

2017-08-29_1208.png
August 30, 2017 at 12:21 pm #1354264

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thank you for the Duplicator package and Multisite admin access. Sorry, I am unable to install the Duplicator copy successfully on my local server because of the Multisite installation.

When I tried to upload the *Duplicator Pro* package on your site it is showing *Upload Maxsize* error. Please check the attached image for more details and please increase the *Upload Maxsize* size. Now it is 2 MB.

--
With Regards

Bigul

2017-08-30_1344.png
August 31, 2017 at 5:40 am #1354822

Aurelien

Hello Bigul,

If it's on your local, duplicate the duplicator pro plugin folder inside the wp-content/plugins folder and you will see the plugin appear in the plugin list so you will be able to enable this one.
Or increase your upload_max_filesize inside your php.ini file of your php configuration.

If you want to upload this plugin on our staging send me a copy in private message please.

Thanks.

August 31, 2017 at 5:35 pm #1355458

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

For your kind information, I will check with my team leader about the file sharing permissions and get back to you tomorrow. If possible, please increase the *upload_max_filesize* size of your staging server to *10 MB* temporarily.

I have two more requests.

1) Please grant me the permission to do some testing on your staging site like deactivating other plugins/switching to default theme etc..

2) Please share me the URLs which you are using to register and displaying the strings

--
With Regards

Bigul

September 1, 2017 at 10:04 am #1355871

Aurelien

Hello Bigul,

I found a second way, I will try on my side and I will let you know the result.

Best regards.

September 1, 2017 at 4:52 pm #1356239

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

Thank you for the updates and waiting for your feedback.

Please share with me your feedback on the following if you are still having the issues.

1) Please grant me the permission to do some testing on your staging site like deactivating other plugins/switching to default theme etc..

2) Please share me the URLs which you are using to register and displaying the strings

I am enabling the private information for the next reply. So you can share the private details also.

--
With Regards

Bigul

September 7, 2017 at 8:55 am #1363215

Aurelien

Hello Bigul,

I fix the problem on my side.

Thanks for your helping.