PHPackages                             umi/sami-translator - 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. umi/sami-translator

ActiveLibrary

umi/sami-translator
===================

0.4.0(12y ago)144MITPHP

Since Dec 23Pushed 12y ago1 watchersCompare

[ Source](https://github.com/velosipedist/sami-translator)[ Packagist](https://packagist.org/packages/umi/sami-translator)[ RSS](/packages/umi-sami-translator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (13)Used By (0)

Translator
==========

[](#translator)

Used with [Sami](https://github.com/fabpot/Sami) tool to generate multi-language HTML API docs from your PhpDocs.

Translation routines is powered up by [Gettext format](http://www.gnu.org/software/gettext/) and it's [php implementation](https://github.com/oscarotero/Gettext).

Basic usage is to prepare Sami config php file...

```
// include all necessary dependencies
require_once __DIR__ . '/vendor/autoload.php';

use Sami\Sami;
use Symfony\Component\Finder\Finder;
use umi\sami\translator\TranslatorPlugin;

// create any files iterator you like
$iterator = Finder::create()
    ->in(getcwd())
    ->exclude('.git')
    ->exclude('.idea')
    ->exclude('vendor')
    ->exclude('tests')
    ->exclude('docs')
    ->name('*.php');

// tune up generation process
$options = [
    // where to look your php source code
    // specify version placeholder for separate HTML output
    'build_dir' => getcwd() . '/docs/build/%version%',
    // to faster cache deletion ;)
    'cache_dir' => getcwd() . '/docs/cache/%version%',
    // this is required option
    'default_opened_level' => 2,
];

// pass iterator & options to Sami tool instance
$sami = new Sami($iterator, $options);

// now power it up with i18n with direct instantiation
$sami[TranslatorPlugin::ID] = new TranslatorPlugin('ru', $sami, [
    // skip phpDocs containing stub docs
    'ignoreDocPatterns'  => [
        '/@inheritdoc/',
        '/@copyright/'
    ],
    // where we keep our .po + .pot + .mo translation files
    'translationsPath'   => 'any/path/you/want/to/keep/gettext/files',

    // path also can be extended with custom version subdir
    // (by default version dir will be appended to translations path to avoid data losing)
    //'translationsPath' => 'D:/gettext-repo/%version%/subdir',

    // path can be relative to build dir, to keep translations together with API build
    //'translationsPath' => '%build%/translations/', // add %version% anywhere, to your taste

    // whether to add PhpDoc'ed code as translation comment, for sensible human-translating
    'useContextComments' => true,

]);

return $sami;
```

...and then to execute Sami console tool passing this php config file location:

```
sami.php update /path/to/config.php

```

First translation
-----------------

[](#first-translation)

If you did'nt translate sources before and haven't .pot files, Translator plugin will generate it by special flag specified:

```
$sami[TranslatorPlugin::ID] = new TranslatorPlugin('ru', $sami, [
    // ...
    // create non-existent & update existing .po + .pot file sets
    'translateOnly' => false,
]);
```

Now you have .po+.pot file pairs created in `translationsPath`. Open your PoEdit tool and start i18'ning!

After you saved translation results and generated .mo files, you can run Sami again to refresh HTML build:

```
sami.php update /path/to/config.php

```

Message Keys modes
------------------

[](#message-keys-modes)

At very beginning, Translator was able only index phpdoc messages literally by themselves, for char-presize translation workflow.

After v 0.2 we have introduced second way to build key-value message pairs: bu signatures:

```
$sami[TranslatorPlugin::ID] = new TranslatorPlugin('ru', $sami, [
    // ...
    // use signatures
    'messageKeysStrategy' => TranslatorPlugin::USE_SIGNATURES_AS_KEYS
]);
```

Previous strategy, `USE_PHPDOCS_AS_KEYS` is still used by default.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

12

Last Release

4499d ago

### Community

Maintainers

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

### Embed Badge

![Health badge](/badges/umi-sami-translator/health.svg)

```
[![Health](https://phpackages.com/badges/umi-sami-translator/health.svg)](https://phpackages.com/packages/umi-sami-translator)
```

###  Alternatives

[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M190](/packages/simplesamlphp-simplesamlphp)[spatie/string

String handling evolved

5604.6M24](/packages/spatie-string)[wp-cli/i18n-command

Provides internationalization tools for WordPress projects.

11610.4M52](/packages/wp-cli-i18n-command)[tio/laravel

Add this package to localize your Laravel application (PHP, JSON or GetText).

170318.5k](/packages/tio-laravel)[om/potrans

Command line tool for translate Gettext with Google Translator API or DeepL API

10515.0k4](/packages/om-potrans)[gettext/php-scanner

PHP scanner for gettext

15471.2k12](/packages/gettext-php-scanner)

PHPackages © 2026

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