2017 © Pedro Pelรกez
 

library php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

image

smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

  • Wednesday, October 28, 2015
  • by smmoosavi
  • Repository
  • 2 Watchers
  • 11 Stars
  • 9,585 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 8 Versions
  • 3 % Grown

The README.md

php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system., (*1)

How to Install

Using Composer

Create a composer.json file in your project root:, (*2)

{
    "require": {
        "smmoosavi/php-gettext": "dev-master"
    }
}

Then run the following composer command:, (*3)

$ php composer.phar install

How to use

Create translate files

.
โ”œโ”€โ”€ composer.json
โ”œโ”€โ”€ composer.lock
โ”œโ”€โ”€ locale
โ”‚ย ย  โ”œโ”€โ”€ en_US
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ LC_MESSAGES
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ messages.mo
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ messages.po
โ”‚ย ย  โ””โ”€โ”€ fa_IR
โ”‚ย ย      โ””โ”€โ”€ LC_MESSAGES
โ”‚ย ย          โ”œโ”€โ”€ messages.mo
โ”‚ย ย          โ””โ”€โ”€ messages.po
โ”œโ”€โ”€ test.php
โ””โ”€โ”€ vendor
    โ”œโ”€โ”€ autoload.php
    ...

php code

<?php // test.php
require 'vendor/autoload.php';

use smmoosavi\util\gettext\L10n;

$locale = 'fa_IR';
$lang = 'fa';
L10n::init($lang, __DIR__ . "/locale/$locale/LC_MESSAGES/messages.mo");

var_dump(__('Hi'));
var_dump(__('other'));

Example .po file

msgid ""
msgstr ""
"Project-Id-Version: php-gettext 0.0.1\n"
"Report-Msgid-Bugs-To: example@example.com\n"
"POT-Creation-Date: 2010-05-28 06:18-0500\n"
"PO-Revision-Date: 2013-08-07 11:34+0330\n"
"Last-Translator: example translator <example@example.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.5.5\n"

msgid "test"
msgstr "ุชุณุช"

msgid "Hi"
msgstr "ุณู„ุงู…"

Converting .po to .mo

$ msgfmt -cv -o locale/fa_IR/LC_MESSAGES/messages.mo locale/fa_IR/LC_MESSAGES/messages.po

TODO

  • Provide ext-gettext. You can track progress in topic/provide-ext-gettext branch.

Note

Thank Danilo Segan. php-gettext 1.0.11 used in this project, (*4)

The Versions

28/10 2015

dev-master

9999999-dev

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

  Sources   Download

The Requires

 

by Seyyed Morteza Moosavi

28/10 2015

v1.0.1

1.0.1.0

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

  Sources   Download

The Requires

 

by Seyyed Morteza Moosavi

16/09 2015

dev-dev

dev-dev

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

  Sources   Download

The Requires

  • php >=5.3.0

 

by Seyyed Morteza Moosavi

16/09 2015

dev-topic/provide-ext-gettext

dev-topic/provide-ext-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

  Sources   Download

The Requires

  • php >=5.3.0

 

by Seyyed Morteza Moosavi

08/06 2014

v1.0.0

1.0.0.0

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

  Sources   Download

The Requires

  • php >=5.3.0

 

by Seyyed Morteza Moosavi

27/11 2013

0.0.3

0.0.3.0

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

  Sources   Download

The Requires

  • php >=5.3.0

 

by Seyyed Morteza Moosavi

27/11 2013

0.0.2

0.0.2.0

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

  Sources   Download

The Requires

  • php >=5.3.0

 

by Seyyed Morteza Moosavi

27/11 2013

0.0.1

0.0.1.0

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

  Sources   Download

The Requires

  • php >=5.3.0

 

by Seyyed Morteza Moosavi