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

ActiveLibrary

vsalvans/twig-translation
=========================

Twig Translation Extension using YAML files

015PHP

Since Dec 15Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Translation Twig Extension
==========================

[](#translation-twig-extension)

Twig Translation Extension using YAML files

```
//TranslationTwigExtension is in include folder
$twig->addExtension(new TranslationTwigExtension($lang, __DIR__.'/locale'));

```

First argument is $lang and the second is the translation yaml files folder

/locale/es.yaml is the translation file

For instance in es.yaml

```
Hello: Hola
English: Spanish
Your name is @name: Your name is @name

```

In the twig template use trans function like this:

```
{{ "Hello" | trans }}
{{ "English" | trans | raw }}
{{ "Your name is @name" | trans({"@name" : "víctor"}) }}

```

You can add a language fallback usign the third parameter:

```
$twig->addExtension(new TranslationTwigExtension($lang, __DIR__.'/locale', $fallbackLanguage));

```

If there is no translation for the current language it searchs a translation in the fallback language files

You can add debug log file. It add a new entry for each translation failed

```
$twig->addExtension(new TranslationTwigExtension($lang, __DIR__.'/locale', $fallbackLanguage, $logfile));

```

Then in the terminal you can list all strings without translation buy typing:

```
$ cat log_file | sort -u

```

Alert!!
=======

[](#alert)

This project has been archived because is old and has vulnerabilities

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/68d1328e1584ff24fe7d252d067faea40236f703d549d2b962da3135c0d6b890?d=identicon)[vsalvans](/maintainers/vsalvans)

---

Top Contributors

[![vsalvans](https://avatars.githubusercontent.com/u/1379281?v=4)](https://github.com/vsalvans "vsalvans (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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