PHPackages                             phyzikz/php\_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. phyzikz/php\_translation

ActiveLibrary

phyzikz/php\_translation
========================

A translation handler class using symfony/yaml

v1.0.1(2y ago)07MITPHP

Since Jul 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/phyzikz/php_translation)[ Packagist](https://packagist.org/packages/phyzikz/php_translation)[ RSS](/packages/phyzikz-php-translation/feed)WikiDiscussions main Synced 1mo ago

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

PHP Translation
===============

[](#php-translation)

A translation handler class using symfony/yaml
----------------------------------------------

[](#a-translation-handler-class-using-symfonyyaml)

Please read the [docs of symfony/Yaml component](https://symfony.com/doc/current/components/yaml.html)

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

[](#how-to-use)

### Initialize class:

[](#initialize-class)

```
require_once 'vendor/autoload.php';
use \phyzikz\TransHandler\TransHandler as TH;
$t = new TH();

```

Your translations will be held at default yaml directory, `./translations`. You can change this directory or get current translation directory

```
$t->setYamlDirectory($yamlDirectory);   // set
$yamlFolder = $t->getYamlDirectory();   // get

```

### Creating directory if not exists

[](#creating-directory-if-not-exists)

```
$t->->createYamlDirectory();

```

### Setting desired language / locale / whatever name

[](#setting-desired-language--locale--whatever-name)

```
$t->setLangName('de');

```

### Creating translation file from code

[](#creating-translation-file-from-code)

```
$t->setLangName('de');
$t->setTrans('Welcome', 'Willkommen');  // key, value
$t->setTrans('Hello', 'Hallo');         // key, value
$t->createYaml();                       // saves de.yaml with given key, value pairs

```

### Extending translation file from code

[](#extending-translation-file-from-code)

```
if (!$t->isLangExists('de'))            // checking language file
{
    die("Missing file.");
}
/*
$t->setLangName('de');                  // desired language file
$trans->parseYaml();                    // reading and parsing translation
*/
$trans->parseYaml('de');                // shorthand for setLanguage and parseYaml

$t->setTrans('motorcycle racing', 'Motorradrennen');
$t->createYaml();                       // saves / overwrites de.yaml with extended key/value pairs

```

### Using translation keys

[](#using-translation-keys)

```
$t->parseYaml('hu');
echo $t->getTrans('Greetings')."";

```

### Using translation array

[](#using-translation-array)

```
$t->parseYaml('hu');
$tArray = $t->getTransArray();          // puts translations into an array
foreach($tArray as $k => $v)            // dumping all translation
    echo $k.": ".$v."";

```

### Adding translation outside the class and writing back to file

[](#adding-translation-outside-the-class-and-writing-back-to-file)

```
$t->parseYaml('hu');
$tArray = $t->getTransArray();          // puts translations into an array
$tArray['cucumber'] = 'uborka';
$t->setTransArray($tArray);             // fills class variable
$t->createYaml();                       // writing out
echo "";
var_dump($trans->getTransArray());      // dumps current class var
echo "";

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

Every ~0 days

Total

2

Last Release

1024d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d8c11e4acb66f737e514a31ab81507ba23decc7d1343788679db198c059c786?d=identicon)[phyzikz](/maintainers/phyzikz)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/phyzikz-php-translation/health.svg)

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

###  Alternatives

[getkirby/cms

The Kirby core

1.5k535.5k352](/packages/getkirby-cms)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)

PHPackages © 2026

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