2017 © Pedro Peláez
 

library locale

Internationalization support for PHP applications. It is a simple set of classes to manage languages/locales, to translate texts depending on a locale. The package contains a trait to include internationalization functions to any classes very easy and with minimum coding.

image

gelembjuk/locale

Internationalization support for PHP applications. It is a simple set of classes to manage languages/locales, to translate texts depending on a locale. The package contains a trait to include internationalization functions to any classes very easy and with minimum coding.

  • Tuesday, February 2, 2016
  • by gelembjuk
  • Repository
  • 1 Watchers
  • 0 Stars
  • 48 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Gelembjuk/Locale

Internationalization support for PHP applications. It is a simple set of classes to manage languages/locales, to translate texts depending on a locale. The package contains a trait to include internationalization functions to any classes very easy and with minimum coding., (*1)

Installation

Using composer: gelembjuk/locale require: {"gelembjuk/locale": "1.*"}, (*2)

Configuration

No configuration needed., (*3)

You need to have a folder with your texts on different languages. Separate fodler for each locale, like en,ge,it,.... Each folder should contain minimum one file default.txt, (*4)

Translation files have simple key=values format, (*5)

Usage


require '../vendor/autoload.php'; $translation = new Gelembjuk\Locale\Translate( array( 'localespath' => $lang_folder_path, // path to your translations directory 'locale' => $locale // current locale, 2 symbol language code ) ); echo $translation->getText('hello',''/*default group*/,$username); // hello = Hello, %s on our site. $username will be put in place of %s echo $translation->getText('welcome'); echo $translation->getText('backsoon','logoutpage'); // custom texts group in a separate web site

Trait usage, (*6)

class MyClass {
    // include translation functions
    use Gelembjuk\Locale\GetTextTrait;

    public function doSomething() {
        echo $this->getText('welcome').'<br>';
    }

    public function andAgainWelcome($name) {
        // use short call for getText
        echo $this->_('hello','',$name).'<br>';
    }
}

$obj = new MyClass();

$obj->setTranslation($translation);

$obj->doSomething();

$obj->andAgainWelcome($username);

$obj->setLocale('en');

$obj->andAgainWelcome($username);

Languages manager usage, (*7)

$langobj = new Gelembjuk\Locale\Languages(array('localespath' => $lang_folder_path));

// list of used languages, used are languages with a folder in $lang_folder_path
$languages = $langobj->getUsedLanguages();

// print language select form

echo '

'; echo $langobj->getHTMLSelect(' name="locale" onchange="document.langform.submit()" ',$locale/*current selected locale*/); echo '
';

Author

Roman Gelembjuk (@gelembjuk), (*8)

The Versions

02/02 2016

dev-master

9999999-dev

Internationalization support for PHP applications. It is a simple set of classes to manage languages/locales, to translate texts depending on a locale. The package contains a trait to include internationalization functions to any classes very easy and with minimum coding.

  Sources   Download

MIT

by Roman Gelembjuk

18/01 2016

1.1.5

1.1.5.0

Internationalization support for PHP applications. It is a simple set of classes to manage languages/locales, to translate texts depending on a locale. The package contains a trait to include internationalization functions to any classes very easy and with minimum coding.

  Sources   Download

MIT

by Roman Gelembjuk

18/01 2016

1.1.4

1.1.4.0

Internationalization support for PHP applications. It is a simple set of classes to manage languages/locales, to translate texts depending on a locale. The package contains a trait to include internationalization functions to any classes very easy and with minimum coding.

  Sources   Download

MIT

by Roman Gelembjuk

05/10 2015

1.1.3

1.1.3.0

Internationalization support for PHP applications. It is a simple set of classes to manage languages/locales, to translate texts depending on a locale. The package contains a trait to include internationalization functions to any classes very easy and with minimum coding.

  Sources   Download

MIT

by Roman Gelembjuk

30/09 2015

1.1.2

1.1.2.0

Internationalization support for PHP applications. It is a simple set of classes to manage languages/locales, to translate texts depending on a locale. The package contains a trait to include internationalization functions to any classes very easy and with minimum coding.

  Sources   Download

MIT

by Roman Gelembjuk

29/09 2015

1.1.1

1.1.1.0

Internationalization support for PHP applications. It is a simple set of classes to manage languages/locales, to translate texts depending on a locale. The package contains a trait to include internationalization functions to any classes very easy and with minimum coding.

  Sources   Download

MIT

by Roman Gelembjuk

29/09 2015

1.1.0

1.1.0.0

Internationalization support for PHP applications. It is a simple set of classes to manage languages/locales, to translate texts depending on a locale. The package contains a trait to include internationalization functions to any classes very easy and with minimum coding.

  Sources   Download

MIT

by Roman Gelembjuk

03/09 2015

1.0.1

1.0.1.0

Internationalization support for PHP applications. It is a simple set of classes to manage languages/locales, to translate texts depending on a locale. The package contains a trait to include internationalization functions to any classes very easy and with minimum coding.

  Sources   Download

MIT

by Roman Gelembjuk

31/07 2015

1.0.0

1.0.0.0

Internationalization support for PHP applications. It is a simple set of classes to manage languages/locales, to translate texts depending on a locale. The package contains a trait to include internationalization functions to any classes very easy and with minimum coding.

  Sources   Download

MIT

by Roman Gelembjuk