Support

Home Forums Event Espresso Premium Invoice localization php file

Invoice localization php file

Posted: September 26, 2013 at 4:24 am


B D

September 26, 2013 at 4:24 am

I’m attempting to follow what Josh has pointed out in https://eventespresso.com/topic/localization-of-invoice/ post. Where is located the custom_functions.php file?

Thank you,

B D


Tony

  • Support Staff

September 26, 2013 at 4:37 am

Hi,

custom_functions.php is part of the Custom Files Add-on

The function mentioned within the thread you have linked to can also be placed within your theme’s functions.php file if you would like.


B D

September 26, 2013 at 4:52 am

Thanks. I have placed it within my child theme’s functions.php file, but nothing happens…

B D


Tony

  • Support Staff

September 26, 2013 at 5:10 am

Can you either paste the function here or onto pastebin so we can view it please?


B D

September 26, 2013 at 5:31 am

I have tested with the following (after ‘Bill To:’ I however need to add other strings):

function mycustom_filter_gettext( $translated, $original, $domain ) {
// This is an array of original strings
// and what they should be replaced with
$strings = array(
‘Bill To: ‘ => ‘Facturé à’

// Add some more strings here
);

// See if the current string is in the $strings array
// If so, replace it’s translation
if ( isset( $strings[$original] ) ) {
// This accomplishes the same thing as __()
// but without running it through the filter again
$translations = &get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}
return $translated;
}

add_filter( ‘gettext’, ‘mycustom_filter_gettext’, 10, 3 );


Tony

  • Support Staff

September 26, 2013 at 9:44 am

Hi,

In this case I would advise you to edit the file directly.

If you copy the invoice folder to wp-uploads/espresso/gateways and edit the files there they will be kept after EE updates.

So once the folder it copied the file to edit would be wp-content/uploads/espresso/invoice/template.php.


B D

September 26, 2013 at 11:16 am

Thank you.

This way it works. However, one issue remains: the date format. More precisely, my WP date format contains the name of the month, that I cannot change/translate in this file. Is there a way to render this translatable? (of course, alternatively I can change the date format to contain only numbers, but I’d rather keep the format with the name of the month).

Thank you in advance,

B D


Josh

  • Support Staff

September 26, 2013 at 12:13 pm

You can make the date display according to the selected date format option in WP>Settings by editing the template and changing any instance of:

date('m-d-Y',

to:

date(get_option('date_format'),


B D

September 26, 2013 at 1:35 pm

Thank you Josh. This works fine.

However, if my WP date format is “26 September 2013” (in French, in my case), the name of the month appears in the pdf invoice still in English, untranslated. Is there any way to translate the name of the monthts, and where?


Josh

  • Support Staff

September 27, 2013 at 11:30 am

In that case you’d change it from using the regular old date function to using the WordPress date internationalization function.

so

date(get_option('date_format'),

can be changed to:

echo date_i18n(get_option('date_format') ,

The support post ‘Invoice localization php file’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso