2017 © Pedro PelĂĄez
 

library chubbyphp-translation

Chubbyphp Translation

image

chubbyphp/chubbyphp-translation

Chubbyphp Translation

  • Tuesday, June 26, 2018
  • by dominikzogg
  • Repository
  • 0 Watchers
  • 0 Stars
  • 569 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

chubbyphp-translation

Build Status Scrutinizer Code Quality Code Coverage Total Downloads Monthly Downloads Latest Stable Version Latest Unstable Version, (*1)

Description

A simple translation solution., (*2)

Requirements

  • php: ~7.0

Suggest

  • pimple/pimple: ~3.0
  • twig/twig: ^1.25.0

Installation

Through Composer as [chubbyphp/chubbyphp-translation][1]., (*3)

composer require chubbyphp/chubbyphp-translation "~1.1"

Usage

Translator

<?php

use Chubbyphp\Translation\LocaleTranslationProvider;
use Chubbyphp\Translation\Translator;

$translator = new Translator([
    new LocaleTranslationProvider('de', [
        'some.existing.key' => 'erfolgreiche Uebersetzung',
        'another.existing.key' => '%d erfolgreiche Uebersetzungen',
        'yetanother.existing.key' => '{{key}} erfolgreiche Uebersetzungen'
    ]),
    new LocaleTranslationProvider('en', [
        'some.existing.key' => 'successful translation',
        'another.existing.key' => '%d successful translations'
        'yetanother.existing.key' => '{{key}} successful translations'
    ])
]);

echo $translator->translate('de', 'some.existing.key'); // erfolgreiche Uebersetzung
echo $translator->translate('en', 'some.existing.key'); // successful translation
echo $translator->translate('fr', 'some.existing.key'); // some.existing.key

echo $translator->translate('de', 'another.existing.key', [5]); // 5 erfolgreiche Uebersetzungen
echo $translator->translate('en', 'another.existing.key', [5]); // 5 successful translations
echo $translator->translate('fr', 'another.existing.key', [5]); // some.existing.key

echo $translator->translate('de', 'yetanother.existing.key', ['key' => 5]); // 5 erfolgreiche Uebersetzungen
echo $translator->translate('en', 'yetanother.existing.key', ['key' => 5]); // 5 successful translations
echo $translator->translate('fr', 'yetanother.existing.key', ['key' => 5]); // some.existing.key

TranslationProvider (Pimple)

<?php

use Chubbyphp\Translation\Translator;
use Chubbyphp\Translation\TranslationProvider;
use Pimple\Container;

$container->register(new TranslationProvider);

$container->extend('translator.providers', function (array $providers) use ($container) {
    $providers[] = new LocaleTranslationProvider('de', [
        'some.existing.key' => 'erfolgreiche Uebersetzung',
        'another.existing.key' => '%d erfolgreiche Uebersetzungen'
    ]);
    $providers[] = new LocaleTranslationProvider('en', [
        'some.existing.key' => 'successful translation',
        'another.existing.key' => '%d successful translations'
    ]);

    return $providers;
});

/** @var Translation $translator */
$translator = $container['translator'];

TranslationTwigExtension

<?php

use Chubbyphp\Translation\LocaleTranslationProvider;
use Chubbyphp\Translation\TranslationTwigExtension;
use Chubbyphp\Translation\Translator;

$twig->addExtension(new TranslationTwigExtension(new Translator([])));
{{ 'some.existing.key'|translate('de') }}
{{ 'another.existing.key'|translate('de', [5]) }}
{{ 'yetanother.existing.key'|translate('de', ['key' => 5]) }}

Dominik Zogg 2016, (*4)

The Versions

26/06 2018

dev-master

9999999-dev

Chubbyphp Translation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

translation slim chubbyphp

20/04 2018

1.1.3

1.1.3.0

Chubbyphp Translation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

translation slim chubbyphp

20/06 2017

1.1.2

1.1.2.0

Chubbyphp Translation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

translation slim chubbyphp

26/04 2017

1.1.1

1.1.1.0

Chubbyphp Translation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

translation slim chubbyphp

13/04 2017

1.1.0

1.1.0.0

Chubbyphp Translation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

translation slim chubbyphp

20/10 2016

1.0.0

1.0.0.0

Chubbyphp Translation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

translation slim chubbyphp

20/10 2016

1.0.0-beta4

1.0.0.0-beta4

Chubbyphp Translation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

translation slim chubbyphp

17/10 2016

1.0.0-beta3

1.0.0.0-beta3

Chubbyphp Translation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dominik Zogg

translation slim chubbyphp