Support

Home Forums Translations Translating event_espresso text domain from custom payment folder

Translating event_espresso text domain from custom payment folder

Posted: November 4, 2019 at 8:17 am


ctincristi-nails

November 4, 2019 at 8:17 am

Hello,

I have developed a custom payment gateway which references text from event_espresso text domain, for example: $payment->set_gateway_response( __( ‘Payment Failed’, ‘event_espresso’ ) );

I’ve also prepared translation file as wp-content/plugins/netopia-mobilpay/languages/event_espresso-ro_RO.mo.

Despite this, the translation does not get picked up and either there is no translation or, if one is available in wp-content/uploads/espresso/languages/event_espresso-ro_RO.mo, that one is picked up.

Is there any way of having my plugin translation file be used? If not, how I see it I need to rename the text domain from event_espresso to my custom plugin name (it is not enough if I translate the texts in the official EE translation site as some custom plugin strings appear only for my plugin and are not part of EE).
Thank you.


Tony

  • Support Staff

November 6, 2019 at 6:52 am

Hi there,

Is there any way of having my plugin translation file be used?

You can’t have 2 plugins using the same text_domain and different .MO files.

Text domains are essentially pointers to MO files, when you try to use the same text domain with 2 different files, you basically overwrite the filename of one with the other.

I think you’ll need to use your own text domain for your strings and likely your own call to load_textdomain to load the correct mo file.

Is your code publicly accessible somewhere where I can take a look?


ctincristi-nails

November 6, 2019 at 12:29 pm

Hi, Tony,

I understand. I can send you the code; just point me to the right email address / contact form.
Thanks!


Tony

  • Support Staff

November 7, 2019 at 4:32 am

You can use support[at]eventespresso.com


ctincristi-nails

November 7, 2019 at 5:44 am

Hi, Tony,

I’ve just sent you the files. Is there anything else that I need to do besides replacing the text domain? Functional wise, the payment gateway has been tested ok.
Thank you.


ctincristi-nails

November 8, 2019 at 1:11 am

Hello again,

I’ve managed to activate my custom text domain by setting below code in the payment gateway class file. Is the code ok from your point of view? Do I need to do anything else?
Thanks.

Class  EE_Netopia_Mobilpay extends EE_Addon {

	/**
	 * class constructor
	 */
	public function __construct()
	{
		add_action( 'plugins_loaded', array( __CLASS__, 'netopia_mobilpay_load_plugin_textdomain'));
	}
	
	public static function netopia_mobilpay_load_plugin_textdomain()
	{
		load_plugin_textdomain( 'netopia-mobilpay', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
	}


Tony

  • Support Staff

November 8, 2019 at 5:09 am

The above looks fine to me and I don’t think you’ll need anything else.

You’ll now be loading your own translations so they should work throughout your plugin.

I tried to take a look over your code however you’ll need to make it public as its limited to the support[at]eventespresso.com user.


ctincristi-nails

November 8, 2019 at 8:35 am

Email resent without confidentiality feature of Gmail. Thanks.

You must be logged in to reply to this support post. Sign In or Register for an Account

Status: publish

Updated by  ctincristi-nails 1 week, 4 days ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!
[for="input_96_5_3"]
[for="input_96_5_3"]
[gravityform id=96 title=false description=false]
  • This field is for validation purposes and should be left unchanged.
[i]
[i]
[gravityform id=69 title=false description=false]
  • This field is for validation purposes and should be left unchanged.