PHPackages                             h4kuna/gettext-latte - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. h4kuna/gettext-latte

Abandoned → [symfony/translation](/?search=symfony%2Ftranslation)Library[Templating &amp; Views](/categories/templating)

h4kuna/gettext-latte
====================

Gettext translator for Latte template

v1.3.4(6y ago)1412.4k↑47.5%71MITPHP

Since Oct 12Pushed 5y ago1 watchersCompare

[ Source](https://github.com/h4kuna/gettext-latte)[ Packagist](https://packagist.org/packages/h4kuna/gettext-latte)[ Docs](https://github.com/h4kuna/gettext-latte)[ RSS](/packages/h4kuna-gettext-latte/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (7)Versions (23)Used By (1)

\[Abandoned\]
=============

[](#abandoned)

GettextLatte
============

[](#gettextlatte)

[![Build Status](https://camo.githubusercontent.com/5a2e336a4a7548c6c32fab3a8a568b81f650a5fdc29a36a65d58dbc97a7ba885/68747470733a2f2f7472617669732d63692e6f72672f68346b756e612f676574746578742d6c617474652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/h4kuna/gettext-latte)[![Latest stable](https://camo.githubusercontent.com/cca8747f8445406a60d964f523b38b2d06c882d0204bb0bdf08e30b504c096b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68346b756e612f676574746578742d6c617474652e737667)](https://packagist.org/packages/h4kuna/gettext-latte)

is localization addon for [Nette framework 2.3](http://nette.org/), which natively supports [gettext](http://php.net/manual/en/book.gettext.php).

Conditions for start-up
-----------------------

[](#conditions-for-start-up)

- gettext extension enabled
- language installed on server, you can check by using command **$ locale -a**
- your application written in UTF-8 encoding

In the repository is directory **locale** containing prepared directory structure for your project. In folder **example** are files, whose help you setup this translator. You can write your application in your native language, here is example in english, but it may be czech, slovak, german language...

Start-up
--------

[](#start-up)

Clone this repository or use composer.

```
composer require h4kuna/gettext-latte
```

Router keep language.

```
/**
 * @return Nette\Application\IRouter
 */
public static function createRouter(\h4kuna\Gettext\GettextSetup $translator) {
    $router = new RouteList();
    $router[] = new Route('index.php', 'Homepage:default', Route::ONE_WAY);
    $router[] = new Route('[/]//[/]', array(
        'presenter' => 'Homepage',
        'action' => 'default',
        'lang' => $translator->getDefault()
    ));

    return $router;
}
```

### examples/config.neon

[](#examplesconfigneon)

On Mac encoding is represented as 'en\_US.UTF-8' everytime dojo format 'en\_US.utf8'.

```
extensions:
    gettextLatteExtension: h4kuna\Gettext\DI\GettextLatteExtension

gettextLatteExtension:
    langs:
        cs: cs_CZ.utf8
        sk: sk_SK.utf8
        en: en_US.utf8

```

Install new macro to latte engine with alias for native gettext function [{\_'' /*, ...*/}](http://www.php.net/manual/en/function.gettext.php) and [{\_n'', '', '' /*, ...*/}](http://www.php.net/manual/en/function.ngettext.php) new is [{\_d'catalog', 'message'}](http://www.php.net/manual/en/function.dgettext.php) and plural [{\_dn'catalog', 'message' /*, ...*/}](http://www.php.net/manual/en/function.dgettext.php).

Run service and support automatic detection of language
-------------------------------------------------------

[](#run-service-and-support-automatic-detection-of-language)

Load language as soon as possible.

```
