PHPackages                             rougin/transcribe - 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. rougin/transcribe

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

rougin/transcribe
=================

Simple localization package in PHP.

v0.4.0(1y ago)167MITPHPPHP &gt;=5.3.0CI failing

Since Jul 18Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/rougin/transcribe)[ Packagist](https://packagist.org/packages/rougin/transcribe)[ Docs](https://roug.in/transcribe/)[ RSS](/packages/rougin-transcribe/feed)WikiDiscussions master Synced 1mo ago

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

Transcribe
==========

[](#transcribe)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6e8d7568aa9fc19833c85fcc4d4915684138e5a63051627430cd49b22e446685/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f7567696e2f7472616e7363726962652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rougin/transcribe)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/rougin/transcribe/blob/master/LICENSE.md)[![Build Status](https://camo.githubusercontent.com/5e37e812fd1b8b0185115f0446ed52f5dc593645a83bb506c6a206f40b68c1fb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f726f7567696e2f7472616e7363726962652f6275696c642e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/rougin/transcribe/actions)[![Coverage Status](https://camo.githubusercontent.com/29b626d5f36b1a6246f4070d441be4e35eef2cb62ce0ac0ca8de3b2642e6879d/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f726f7567696e2f7472616e7363726962653f7374796c653d666c61742d737175617265)](https://app.codecov.io/gh/rougin/transcribe)[![Total Downloads](https://camo.githubusercontent.com/b6af2ba89305a7570b9c315988dcd746aa4170b77bfdb2e98a4e1eaac2dd8a6a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f7567696e2f7472616e7363726962652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rougin/transcribe)

`Transcribe` is a simple localization package written in PHP in which the translated word can be retrieved easily based on the specified locale. A localization source can be from multiple `.php` files or from a database connection using [PDO](https://www.php.net/manual/en/intro.pdo.php).

Installation
------------

[](#installation)

Install the `Transcribe` package via [Composer](https://getcomposer.org/):

```
$ composer require rougin/transcribe
```

Basic usage
-----------

[](#basic-usage)

Prior in using `Transcribe`, a list of words must be provided with its specified translations (e.g., `fil_PH.php`):

```
// locales/fil_PH.php

$texts = array();

$texts['language'] = 'linguahe';
$texts['name'] = 'pangalan';
$texts['school'] = 'paaralan';

return $texts;
```

Once provided, specify the words in a source (e.g., `FileSource`):

```
// index.php

use Rougin\Transcribe\Source\FileSource;

// ...

$source = new FileSource;

// Add the directory to the source ----
$source->addPath(__DIR__ . '/locales');
// ------------------------------------
```

After creating the specified source, use the `get` method from the `Locale` class to get the localized word based on its keyword:

```
// index.php

use Rougin\Transcribe\Locale;

// ...

/** @var \Rougin\Transcribe\Source\FileSource */
$source = /** ... */;

$locale = new Locale($source);

echo $locale->get('fil_PH.name');
```

```
$ php index.php
pangalan
```

Using the `setDefault` method can define the default locale. With this, there is no need to specify it when using the `get` method:

```
// index.php

$locale->setDefault('fil_PH');

// No need to specify "fil_PH" ---
echo $locale->get('name');
// -------------------------------
```

Using sources
-------------

[](#using-sources)

The previous example uses the `FileSource` which uses `.php` files in getting localized words. But `Transcribe` also provides a way in getting the said localized words through a database using the `PdoSource`:

```
// index.php

use Rougin\Transcribe\Source\PdoSource;

// ...

// Create a PDO instance -----------------
$dsn = 'mysql:host=localhost;dbname=demo';

$pdo = new PDO($dsn, 'root', /** ... */);
// ---------------------------------------

$source = new PdoSource($pdo);

// ...
```

When using the `PdoSource` class, it can also specify the database table and its columns to be used for getting the localized words:

```
# Contents of the "locales" table

| `id` | `type` | `name` | `text`   |
|------|--------|--------|----------|
| 1    | fil_PH | name   | pangalan |
| 2    | fil_PH | school | paaralan |

```

```
// ...

// Use "locales" table from database ---
$source->setTableName('locales');
// -------------------------------------

// Use "type" column from "locales" table ---
$source->setTypeColumn('type');
// ------------------------------------------

// Use "name" column from "locales" table ---
$source->setNameColumn('name');
// ------------------------------------------

// Use "text" column from "locales" table ---
$source->setTextColumn('text');
// ------------------------------------------

// ...
```

Note

If the required table and columns were not specified, its default values are the same from the above-example (e.g., `locales` for table, and `type`, `name`, and `text` values for the columns).

Then use the same `get` method from `Locale` class to get the localized word from the database table:

```
// index.php

// ...

echo $locale->get('fil_PH.name');
```

```
$ php index.php
pangalan
```

Creating custom sources
-----------------------

[](#creating-custom-sources)

To create a custom source, kindly use the `SourceInterface` for its implementation:

```
namespace Rougin\Transcribe\Source;

interface SourceInterface
{
    /**
     * Returns an array of words.
     *
     * @return array
     */
    public function words();
}
```

The `words` method should return a list of words in an associative array format:

```
return array(
    'fil_PH' => array(
        'language' => 'linguahe',
        'name' => 'pangalan',
        'school' => 'paaralan',
    ),
);
```

The specified method will be used as the reference for finding the localized word from the `get` method of `Locale` class.

Migrating to the `v0.4.0` release
---------------------------------

[](#migrating-to-the-v040-release)

The new release for `v0.4.0` will be having a [backward compatibility](https://en.wikipedia.org/wiki/Backward_compatibility) break (BC break). With this, some functionalities from the earlier versions might not be working after upgrading. This was done to increase extensibility, simplicity and maintainbility. This was discussed in one of [my blog post](https://roug.in/hello-world-again/) which also mentions `Transcribe`:

> I also want to extend this plan to my personal packages as well like [Staticka](https://github.com/staticka/staticka) and [Transcribe](https://github.com/rougin/transcribe). With this, I will introduce backward compatibility breaks to them initially as it is hard to migrate their codebase due to minimal to no documentation being provided in its basic usage and its internals. As I checked their code, I realized that they are also over engineered, which is a mistake that I needed to atone for when updating my packages in the future.

Please see [Pull Request #1](https://github.com/rougin/transcribe/pull/1) for the files that were removed or updated in this release and the [UPGRADING](https://github.com/rougin/transcribe/blob/master/UPGRADING.md) page for the specified breaking changes.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](https://github.com/rougin/transcribe/blob/master/CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Credits
-------

[](#credits)

- [All contributors](https://github.com/rougin/transcribe/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](https://github.com/rougin/transcribe/blob/master/LICENSE.md) for more information.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance52

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Recently: every ~866 days

Total

7

Last Release

421d ago

### Community

Maintainers

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

---

Top Contributors

[![rougin](https://avatars.githubusercontent.com/u/6078637?v=4)](https://github.com/rougin "rougin (62 commits)")

---

Tags

php-l10nphp-localephp-text-tablephp-l10nphp-localephp-text

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rougin-transcribe/health.svg)

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

###  Alternatives

[symfony/translation

Provides tools to internationalize your application

6.6k836.5M2.1k](/packages/symfony-translation)[nesbot/carbon

An API extension for DateTime that supports 281 different languages.

169661.4M4.8k](/packages/nesbot-carbon)[joedixon/laravel-translation

A tool for managing all of your Laravel translations

717911.4k11](/packages/joedixon-laravel-translation)[illuminate/translation

The Illuminate Translation package.

6936.4M495](/packages/illuminate-translation)[lajax/yii2-translate-manager

Translation management extension for Yii 2

227578.8k13](/packages/lajax-yii2-translate-manager)[larswiegers/laravel-translations-checker

Make sure your laravel translations are checked and are included in all languages.

256423.2k2](/packages/larswiegers-laravel-translations-checker)

PHPackages © 2026

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