PHPackages                             futurerockstars/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. futurerockstars/gettext-latte

ActiveLibrary[Templating &amp; Views](/categories/templating)

futurerockstars/gettext-latte
=============================

Gettext translator for Latte template

012.2k↓18.8%PHP

Since Jul 2Pushed 2y agoCompare

[ Source](https://github.com/futurerockstars/gettext-latte)[ Packagist](https://packagist.org/packages/futurerockstars/gettext-latte)[ RSS](/packages/futurerockstars-gettext-latte/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

\[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.

```
