Support

Home Forums Event Espresso Premium Localization of invoice

Localization of invoice

Posted: July 14, 2013 at 3:49 pm

Viewing 5 reply threads


Runemester

July 14, 2013 at 3:49 pm

Hi,

I’ve been scanning the files for translatable strings for the invoice generated as pdf. And some of the strings seem to be translatable (eg payment instructions, table headers etc) but aren’t picked up unless I translate the strings directly in the core files (gateways/invoice/template.php and settings.php). Has anyone else encountered this issue?

The same goes for the link generated by the [payment_url] shortcode in the confirmation email.

Also the date in the printable ticket can’t be localized (I believe this issue has been raised before though)

Thanks
Rune

  • This topic was modified 11 years, 4 months ago by Runemester.
  • This topic was modified 11 years, 4 months ago by Runemester.


Dean

July 15, 2013 at 7:14 am

Hi Rune,

Some of the text isnt translatable by WordPress as it is user generated, so if you go to the Payment Settings invoice, you can add the Payment Instructions etc in the language of your choice.

There will probably still be elements that are not translatable, we have an open ticket to fix some of those.


Runemester

July 16, 2013 at 7:52 am

Thanks Dean,

I found that out and have translated the payment instructions.

But still a number of strings aren’t picked up although they are added to the textdomain – eg ‘Bill To:’, ‘Total:’, ‘Amount Paid:’ etc. (from around line 135- in gateways/invoice/template.php and settings.php)


Josh

  • Support Staff

July 16, 2013 at 3:25 pm

Hi Rune,

While I can’t say for sure why the invoice strings aren’t picking up strings from the translation files, this function dropped into the custom_functions.php seems to work fine:

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: ' => 'your bill to string',
    	'Total:' => 'your total string',
    	'Amount Paid:' => 'your amount paid string'

        // 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 );

I checked on the date on the ticket and that should pull the date format set in WP>Settings>General. That’s what it’s doing on my test site anyway. Not happening for you?


Runemester

July 16, 2013 at 4:13 pm

Thanks Josh,

I tested your snippet and it does the job perfectly. No idea why the the strings aren’t picked up though.

Regarding the date. I can change the format, but not the translation of the months. If I use j. F Y (which translates fine in WP in general) the output is still ‘July’ in English.

BTW a big thank you to you guys for giving excellent support

Cheers
Rune


Josh

  • Support Staff

July 17, 2013 at 9:23 am

Hi Rune,

We checked into this and the function that pulls the date from the db is using the WP date_i18n() function, which uses the $wp_locale global object. The odd thing is it appears that the $wp_locale global object is getting nulled out somewhere.
Adding this to the ticket template returns NULL:
<?php global $wp_locale; var_dump($wp_locale); ?>

I’ve created a ticket for one of the developers to look into why this is happening.

For now, you could use the gettext function that you’re already using for the invoice strings to translate the month names on the ticket until this can get fixed.

Viewing 5 reply threads

The support post ‘Localization of invoice’ 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