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

ActivePackage

ahmetbarut/translation
======================

Çoklu dil kullanan web sitesinde birden fazla dil ve kullanım kolaylığı sunuyor.

v1.1.0(4y ago)316MITPHP

Since Sep 7Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ahmetbarut/php-translation)[ Packagist](https://packagist.org/packages/ahmetbarut/translation)[ RSS](/packages/ahmetbarut-translation/feed)WikiDiscussions master Synced 6d ago

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

- [PHP Translation](#php-translation)
    - [Install](#install)
    - [Lifecycle](#lifecycle)
    - [Configuration](#configuration)
        - [Content of PHP File](#content-of-php-file)
        - [Content of Json File](#content-of-json-file)
        - [Content Of Database Table](#content-of-database-table)
- [Use Of](#use-of)
    - [Array Or Json](#array-or-json)
    - [Database](#database)

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

[](#php-translation)

It is a php package that enables multi-language capability very easily. Also, the package accepts formats as `array`, `json` and `Database`.

Install
-------

[](#install)

```
    composer require ahmetbarut/translation
```

Lifecycle
---------

[](#lifecycle)

[![diagram](./lifecycle.png)](./lifecycle.png)

Configuration
-------------

[](#configuration)

The directory structure of the language files should be as follows and it should return an array. The location of the directory is not important, but the content is!

---

- lang
    - en
        - menu.php / menu.json
    - tr
        - menu.php / menu.json
    - de
        - menu.php / menu.json

---

#### Content of PHP File

[](#content-of-php-file)

```
    return [
    'home' => 'Home',
];
```

#### Content of Json File

[](#content-of-json-file)

```
    {
        "home": "Home",
        "deneme": "TEST"
    }
```

#### Content Of Database Table

[](#content-of-database-table)

You can change the table name as you wish. If the table name is different, you must give the table name to the `$table` parameter in the constructor of the `Translation` class.

```
CREATE TABLE translation (
    id serial PRIMARY KEY,
    key varchar (255),
    value VARCHAR (255),
    language VARCHAR(255)
    )
```

Use Of
======

[](#use-of)

Array Or Json
-------------

[](#array-or-json)

```
use ahmetbarut\Translation\Translation;

require "./vendor/autoload.php";

$translation = new Translation(__DIR__ . '/lang', 'array');
$translation->setLocale('en');

trans('menu.home')
```

The `trans` function accepts a `string` and the first word before the period represents the file, and the word after the period is the key to the requested value.

The `setLocale` method also belongs to the `Translation` class.

Database
--------

[](#database)

```
use ahmetbarut\Translation\Translation;

require "./vendor/autoload.php";

try {
    $connect = new PDO('pgsql:host=localhost;dbname=translation;', 'ahmetbarut', "");
}catch (PDOException $th){
    die($th->getMessage());
}

$translation = new Translation( format: 'db', connect: $connect, table: 'translation_words');
$translation->setLocale('en');

trans('home')
```

The `trans` function does not expect `.` in this case.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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 ~6 days

Total

4

Last Release

1692d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/530008a3a5e32fa689343dc342c6686b50267ba86905e55e5f42ad2d1c8c193c?d=identicon)[ahmetbarut](/maintainers/ahmetbarut)

---

Top Contributors

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

---

Tags

phpphp-translation

### Embed Badge

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

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

PHPackages © 2026

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