2017 © Pedro Peláez
 

library phalcon-translate

Phalcon Translate Service. Simple way to translate your costom part of templates :-)

image

stanislav-web/phalcon-translate

Phalcon Translate Service. Simple way to translate your costom part of templates :-)

  • Wednesday, July 22, 2015
  • by stanislav-web
  • Repository
  • 2 Watchers
  • 9 Stars
  • 139 Installations
  • HTML
  • 1 Dependents
  • 3 Suggesters
  • 3 Forks
  • 1 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Phalcon Translate Service

Code Coverage Total Downloads License Latest Stable Version, (*1)

Phalcon Translate Service. Simple way to translate your costom part of templates :-), (*2)

Changelog

  • 1.3.1 [FIX] Default language use
  • 1.3 [FIX] Support for Phalcon 2.x // [Minor fix] Translate Adapter Native offsetGet is not work on 2.0
  • 1.2 [FIX, FEATURE] The ability to reuse a set of translations in various services
  • 1.1 Added setDefault() method to watch undefined languages

Compatible

  • PSR-1, PSR-2, PSR-4 Standards

System requirements

  • PHP 5.4.x >
  • Phalcon extension 1.3.x, 2.x

Install

First update your dependencies through composer. Add to your composer.json:, (*3)

"require": {
    "stanislav-web/phalcon-translate": "1.*"
}

```python php composer.phar install, (*4)

OR
```python
php composer.phar require stanislav-web/phalcon-translate 1.*

(Do not forget to include the composer autoloader), (*5)

Or manual require in your loader service, (*6)

    $loader->registerNamespaces([
        'Translate\Translator' => 'path to src'
    ]);

You can create an injectable service, (*7)

    $this->di['translate'] = function() {
        return new Translate\Translator();
    };

Usage

recomended configuration for translate directory (as example)

/app/languages/{LANG}/{PART}.php

LANG meant "ru", "en", "de"
PART meant "menu", "header", "footer"

files for translation

<?php
return [
    'MY ACCOUNT'    =>  'My Account',
    'LOGIN'         =>  'Log in',
    'LOGOUT'        =>  'Log out',
    'WELCOME'       =>  'Welcome, %s! We glad to see you! You are %d',
];

configuration and use

    // get translate service
    $translate = $this->di->get('translate');

     // forward slash must be...  // lang can get from headers or cookies
    $translate->setTranslatePath('/app/Modules/Frontend/languages/')->setLanguage('en');

    // 1.1-stable Added setDefault() method to watch undefined languages
    $translate->setDefault('en');

    // so now you have a directory for "English".. 
    // Next you need to choise a part of translate.
    // I do something like this

    $this->view->setVars('t', $translate);

    // ... in my view or layout i get a part of translate

    echo $t->assign('menu')->translate('MY ACCOUNT'); // My Account

    // or use otherwise
    $this->partial('sidebar', ['t' => $t->assign('sidebar')]);
    echo $t->translate('LOGIN');

    // translate by template variable
    printf($t->translate('WELLCOME'), 'User', 100); // Output: Welcome,User! We glad to see you! You are 100

Issues

The Versions

22/07 2015

dev-master

9999999-dev https://github.com/stanislav-web/phalcon-translate

Phalcon Translate Service. Simple way to translate your costom part of templates :-)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

phalcon phalcon translate phalcon partial translate

12/07 2015

1.3.1-stable

1.3.1.0 https://github.com/stanislav-web/phalcon-translate

Phalcon Translate Service. Simple way to translate your costom part of templates :-)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

phalcon phalcon translate phalcon partial translate

06/07 2015

1.3-stable

1.3.0.0 https://github.com/stanislav-web/phalcon-translate

Phalcon Translate Service. Simple way to translate your costom part of templates :-)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

phalcon phalcon translate phalcon partial translate

15/02 2015

1.2-stable

1.2.0.0 https://github.com/stanislav-web/phalcon-translate

Phalcon Translate Service. Simple way to translate your costom part of templates :-)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

phalcon phalcon translate phalcon partial translate

31/01 2015

1.1-stable

1.1.0.0 https://github.com/stanislav-web/phalcon-translate

Phalcon Translate Service. Simple way to translate your costom part of templates :-)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

phalcon phalcon translate phalcon partial translate

29/01 2015

1.0-stable

1.0.0.0 https://github.com/stanislav-web/phalcon-translate

Phalcon Translate Service. Simple way to translate your costom part of templates :-)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

phalcon phalcon translate phalcon partial translate

28/01 2015

dev-scrutinizer-patch-2

dev-scrutinizer-patch-2 https://github.com/stanislav-web/phalcon-translate

Phalcon Translate Service. Simple way to translate your costom part of templates :-)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

phalcon phalcon translate

28/01 2015

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1 https://github.com/stanislav-web/phalcon-translate

Phalcon Translate Service. Simple way to translate your costom part of templates :-)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

phalcon phalcon translate