PHPackages                             salamek/gettexttranslator - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. salamek/gettexttranslator

ActiveLibrary[Localization &amp; i18n](/categories/localization)

salamek/gettexttranslator
=========================

Translator for Nette (PHP framework).

v1.4.2(8y ago)113.1k↓100%7BSD-3-ClausePHPPHP &gt;=5.3.0

Since Jun 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Salamek/gettexttranslator)[ Packagist](https://packagist.org/packages/salamek/gettexttranslator)[ Docs](https://github.com/Salamek/gettexttranslator)[ RSS](/packages/salamek-gettexttranslator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (1)Versions (8)Used By (0)

Gettext Translator
==================

[](#gettext-translator)

Gettext Translator is tool that enables simple and user friendly translation of your texts via panel in debug bar. No need to edit or operate with .po/.mo files.

Tested with nette 2.1&gt;, please report any bugs into Issues

Installation and usage
----------------------

[](#installation-and-usage)

### Installation via composer:

[](#installation-via-composer)

```
{
  "require":{
    "salamek/gettexttranslator"
  }
}
```

### Usage

[](#usage)

#### Set up config.neon:

[](#set-up-configneon)

```
common:
  gettextTranslator:
    lang: cs #default language
    files:
      front: %appDir%/lang # for module Front and other non-specified modules
      admin: %appDir%/lang-admin # for module Admin
    # optional with defaults
    layout: horizontal # or: vertical
    height: 450

extensions:
  gettextTranslator: GettextTranslator\DI\Extension
```

#### Set up in BasePresenter.php

[](#set-up-in-basepresenterphp)

```
class BasePresenter extends Nette\Application\UI\Presenter
{
  /** @persistent */
  public $lang;

  /** @var \GettextTranslator\Gettext */
  protected $translator;

  /**
   * @param \GettextTranslator\Gettext
   */
  public function injectTranslator(GettextTranslator\Gettext $translator)
  {
    $this->translator = $translator;
  }

  public function createTemplate($class = NULL)
  {
    $template = parent::createTemplate($class);

    // if not set, the default language will be used
    if (!isset($this->lang))
    {
      $this->lang = $this->translator->getLang();
    }
    else
    {
       $this->translator->setLang($this->lang);
    }

    $template->setTranslator($this->translator);

    return $template;
  }
}
```

### Change language eg. in @template.latte

[](#change-language-eg-in-templatelatte)

```
Choose language:
English
Česky
```

### How to translate a string

[](#how-to-translate-a-string)

#### In template

[](#in-template)

```
{_"Login"}

{_"piece", $number}
1 piece
2 pieces
5 pieces
```

#### In forms

[](#in-forms)

```
protected function createComponentMyForm()
{
  $form = new Form;
  $form->setTranslator($this->translator);

  // ...

  return $form;
}
```

#### In components

[](#in-components)

```
public function createTemplate($class = NULL)
{
  $template = parent::createTemplate($class);
  $template->setTranslator($this->parent->translator); // $translator in presenter has to be public
  // or $this->translator via construct/inject

  return $template;
}
```

#### In flash message

[](#in-flash-message)

```

  ×
  {_$flash->message|noescape}

```

Authors
-------

[](#authors)

### Actively developing

[](#actively-developing)

- Adam Schubert

### Previously developed by

[](#previously-developed-by)

- Josef Kufner ()
- Miroslav Paulík ()
- Roman Sklenář ()
- Miroslav Smetana
- Jan Smitka
- Patrik Votoček ()
- Tomáš Votruba ()
- Václav Vrbka ()

Under *New BSD License*

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~226 days

Recently: every ~246 days

Total

7

Last Release

2994d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c21212e1504816757058ac5cee91f87aea0395f3d7e2d26a01e71aaefcadac0b?d=identicon)[Salamek](/maintainers/Salamek)

---

Top Contributors

[![Salamek](https://avatars.githubusercontent.com/u/1226241?v=4)](https://github.com/Salamek "Salamek (14 commits)")[![martenb](https://avatars.githubusercontent.com/u/13311472?v=4)](https://github.com/martenb "martenb (1 commits)")

---

Tags

nettegettexttranslator

### Embed Badge

![Health badge](/badges/salamek-gettexttranslator/health.svg)

```
[![Health](https://phpackages.com/badges/salamek-gettexttranslator/health.svg)](https://phpackages.com/packages/salamek-gettexttranslator)
```

###  Alternatives

[gettext/gettext

PHP gettext manager

70530.2M101](/packages/gettext-gettext)[phpmyadmin/motranslator

Translation API for PHP using Gettext MO files

591.8M8](/packages/phpmyadmin-motranslator)[gettext/translator

Gettext translator functions

114.6M10](/packages/gettext-translator)[om/potrans

Command line tool for translate Gettext with Google Translator API or DeepL API

10515.0k4](/packages/om-potrans)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
