You should get the language with this code (not tested):
// Add Shortcode to get TranslatePress language
add_shortcode ('CurrentLanguageCode', 'dartrax_get_language_code');
function dartrax_get_language_code() {
if( ! class_exists('TRP_Translate_Press') ) return '';
global $TRP_LANGUAGE;
return $TRP_LANGUAGE;
}
Now [CurrentLanguageCode] should resolve to the current locale like “en_US” for Example. It’s up to the payment provider plugin if it allows Shortcodes in the callback url parameter. If not, you should search or ask if there is a filter you could use to alter the url.
Thank you @dartrax Translatepress should hire you since you are trying to solve all of their support problems 🙂
I will try this. One question: I’m using a snippet plugin to add codes to function.php
Should I add this code there?
@dartrax I just tried the code but Payment Provider does not seem to be accepting shortcodes on the URL, test transaction stayed in the awaiting payment status once I added the shortcode.
I will ask them if there’s a way implementing the code. Thanks again.
Thanks 😉
Try it in your child theme’s functions.php first and add the shortcode on one of your pages just to make sure it will show the current locale. If that works, you can try with the url parameter, and if it still works, try moving it into a snippet.
But it seems you already done this and it did not work, so you need a way to dynamically change the url, for example with a filter hook – the payment provider should be able to tell you if there is one available.
@dartrax Thanks. They actually suggested a fix like this: writing a code to get the order language from meta-data of the order and redirecting the callback URL with the correct slug.
I got the first part “saving the language data” thanks to you 🙂 now I’m trying to find a way to get the second part working.
Hello @kitboxdesign,
Unfortunately, for the time being, we don’t have support for storing and sending the current language to other plugins that need it.
This is a tracked feature and will be available in the future versions of TranslatePress – but, as there are other features more requested that require prioritization, I can’t give you a timeframe for when will this be implemented.
Thank you for understanding.
Best regards,
Cristian