Skip to content

Commit

Permalink
readme translation section
Browse files Browse the repository at this point in the history
  • Loading branch information
MartkCz committed Jun 25, 2020
1 parent e64d9f7 commit 0098b91
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Preview with minimal setup](#preview-with-minimal-setup)
- [Entities](#entities)
- [Customizing](#customizing)
- [Translation](#translation)
- [Generating invoices](#generating-invoices)
- [Generating preview](#generating-preview)
- [Neon configuration](#neon-configuration)
Expand Down Expand Up @@ -83,6 +84,54 @@ class CustomFormatter implements IFormatter {
}
```

## Translation

First, create class that implements ITranslator

```php
class Translator implements Contributte\Invoice\ITranslator {

private static $translations = [
'subscriber' => 'Subscriber',
'vat' => 'VAT number',
'vaTin' => 'VATIN',
'date' => 'Date',
'invoice' => 'Invoice',
'invoiceNumber' => 'Invoice number',
'taxPay' => '',
'notTax' => 'VAT unregistered',
'paymentData' => 'Payment information',
'page' => 'Page',
'from' => '/',
'totalPrice' => 'Total price',
'item' => 'Item',
'count' => 'Quantity',
'pricePerItem' => 'Price per item',
'total' => 'Total',
'accountNumber' => 'Account number',
'swift' => 'Swift',
'iban' => 'Iban',
'varSymbol' => 'Variable symbol',
'constSymbol' => 'Constant symbol',
'tax' => 'TAX',
'subtotal' => 'Subtotal',
'dueDate' => 'Due date',
];

public function translate(string $message): string
{
return self::$translations[$message];
}

}
```

and pass it to the invoice and template

```php
$invoice = new Contributte\Invoice\Invoice($company, new Contributte\Invoice\Templates\DefaultTemplate(new Translator()));
```

## Generating invoices

```php
Expand Down

0 comments on commit 0098b91

Please sign in to comment.