PHPackages                             abedmaatalla/slim-twig-translation - 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. abedmaatalla/slim-twig-translation

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

abedmaatalla/slim-twig-translation
==================================

Twig function for Illuminate\\Translation\\Translator in Slim framework

1.0.0(9y ago)29422[2 PRs](https://github.com/abedmaatalla/slim-twig-translation/pulls)MITPHPPHP &gt;=5.3.0

Since Nov 25Pushed 7y agoCompare

[ Source](https://github.com/abedmaatalla/slim-twig-translation)[ Packagist](https://packagist.org/packages/abedmaatalla/slim-twig-translation)[ Docs](http://github.com/abedmaatalla/slim-twig-translation)[ RSS](/packages/abedmaatalla-slim-twig-translation/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Slim Twig Translation
=====================

[](#slim-twig-translation)

This repository provides a twig extension class for the twig view parser. The class adds a translate helper function for the use in twig templates. The translator function tries to call the trans() function of an Illuminate\\Translation\\Translator object in the slim DI container.

How to install
--------------

[](#how-to-install)

#### using [Composer](http://getcomposer.org/)

[](#using-composer)

Create a composer.json file in your project root:

```
{
    "require": {
        "abedmaatalla/slim-twig-translation": "1.0.0"
    }
}
```

Then run the following composer command:

```
$ php composer.phar install
```

How to use
----------

[](#how-to-use)

Create new folder for langauges

-

\-- lang

- -- en
    - -- file.php
- -- fr
    - -- file.php

### Tanslator

[](#tanslator)

Set up your Tansloator

```
$container['translator'] = function ($c)
{
  // Register the English translator 'en'
  $translator = new Illuminate\Translation\Translator(new Illuminate\Translation\FileLoader(new Illuminate\Filesystem\Filesystem(), __DIR__ . '/lang'), 'en');
    // setLocal for new location
    $translator->setLocale('fr');
    return $translator;
};
```

### Slim

[](#slim)

Set up your twig views as described in the [SlimViews Repository](https://github.com/codeguy/Slim-Views). Add the extension to your parser extensions.

```
$container['view'] = function ($c)
{
  $view = new \Slim\Views\Twig('../resources/views');

  // add translator functions to Twig
  $view->addExtension(new \abedmaatalla\Slim\Twig\Extension\TranslationExtension($c->translator));

}
```

### Twig template

[](#twig-template)

In your twig template you would write:

```
  {{ translate('male') }}

```

You can also use the shorthand:

```
  {{ tans('male') }}

```

You can also use the shorthand:

```
  {{ _('male') }}

```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3505d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5932922?v=4)[Abed MAATALLA](/maintainers/abedmaatalla)[@abedmaatalla](https://github.com/abedmaatalla)

---

Top Contributors

[![abedmaatalla](https://avatars.githubusercontent.com/u/5932922?v=4)](https://github.com/abedmaatalla "abedmaatalla (6 commits)")

---

Tags

twigtranslationslimilluminatemicroframework

### Embed Badge

![Health badge](/badges/abedmaatalla-slim-twig-translation/health.svg)

```
[![Health](https://phpackages.com/badges/abedmaatalla-slim-twig-translation/health.svg)](https://phpackages.com/packages/abedmaatalla-slim-twig-translation)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[symfony/ux-twig-component

Twig components for Symfony

22018.6M322](/packages/symfony-ux-twig-component)[symfony/ux-live-component

Live components for Symfony

1647.0M117](/packages/symfony-ux-live-component)[twig/intl-extra

A Twig extension for Intl

36569.4M330](/packages/twig-intl-extra)[twig/cssinliner-extra

A Twig extension to allow inlining CSS

22919.7M83](/packages/twig-cssinliner-extra)[symfony/ux-toolkit

A tool to easily create a design system in your Symfony app with customizable, well-crafted Twig components

1682.8k1](/packages/symfony-ux-toolkit)

PHPackages © 2026

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