Multi-lingual invoices.
  • I needed to have my invoices in either English or German, so I have changed simple invoices a little and got exactly what I was after.
    I know other people need this feature, so I thought I'd let you know how I did it, it's a bit of a hack but you can get it done in less than 5 minutes

    This is my first time contributing code to a forum, so if it's unintelligable or weirdly done be nice :)

    First off, I have two invoice preferences setup, one named Invoice English, one Invoice German.
    These contain all the editable stuff for the invoice (payment method etc.). This kinda has to be done to make this part translatable.

    Second, In 'include/language.php' on line 28 I added the argument '$language' for the function 'getLanguageArray()' and commented out the global language variable on the following line.
    This enables us to call whatever language we like regardless f the global language variable.
    on line 92 i pass the variable language to this function so it still loads the default language on startup.
    $LANG = getLanguageArray($language);

    Third. in 'include/class/export.php' In function getData() I added the global variable $LANG
    and the following code on Line 67:
    if($preference['pref_description'] == 'Invoice German'){
    $LANG = getLanguageArray('de');
    }
    This code means, that if the invoice Type is german, it will call the german language.... this is the bit of code you'll need to change for your own installations depending on what languages you want and what you call your invoice preferences.

    Fourth. add $smarty -> assign('display_lang',$LANG);
    to the list of smarty variables around line 90 or so.

    Fifth. replace the variable $LANG with the variable $display_lang in your template.
    now your template will display whichever language it is passed.

    Checked this on print view and pdf view... don't know if it works for email cause I dont use it.

    Hope this helps,

    James

  • justinjustin March 2010

    thanks james for posting this!!

    in our development version i've added language and locale options to invoice preferences with the intention of doing similar to as you have done - still a work in progress

    so this feature should make it into Simple Invoices some time soon

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

Categories