smmoosavi/php-gettext
最新稳定版本:v1.0.1
Composer 安装命令:
composer require 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.
README 文档
README
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.
How to Install
Using Composer
Create a composer.json file in your project root:
{
"require": {
"smmoosavi/php-gettext": "dev-master"
}
}
Then run the following composer command:
$ 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 intopic/provide-ext-gettextbranch.
Note
Thank Danilo Segan. php-gettext 1.0.11 used in this project
统计信息
- 总下载量: 24.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 19
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2013-11-27