定制 dasred/php-phraseapp-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dasred/php-phraseapp-client

最新稳定版本:v2.1.1

Composer 安装命令:

composer require dasred/php-phraseapp-client

包简介

README 文档

README

PHP PhraseApp Client for PhraseApp and API Version 2.

CLI Usage

tr-sync

Usage

bin/tr-sync [options] sourcePath

Arguments

sourcePath Path to search in.

Options

--projectId (-p) <string>                                 project id
--accessToken (-a) <string>                               user access token
--localeDefault (-l) <string>                             default locale. Default de-DE
--applicationName (-n) [ <string> ]                       name of your application. Default PHP PhraseApp Client
--preferDirection (-d) [ <string> ]                       prefer direction for sync (remote, local). Default: remote
--exclude (-x) [ <string> ]                               regex to exclude files. can be given multiple times: Default: []
--tagForContentChangeFromLocalToRemote (-t) [ <string> ]  tag for content change from local to remote. Default: newContent
--help (-h)                                               Display this help message
--quiet (-q)                                              Do not output any message
--version (-V)                                            Display this application version

phraseapp

Usage

bin/phraseapp [options] operation

Locale Operations

 locale create <locale> [localeSource]   creates the given locale.
 locale list                             list all locales

Key Operations

 key addTag <key> <tag>                            add the tag to the key.
 key create <name> [description] [tag ...]         create a new key.
 key delete <key>                                  deletes the key.
 key list                                          list the key.
 key update <key> <name> [description] [tag ...]   updates the key.

Translation Operations

 translation store <locale> <key> <content>   set content of a key for a locale.

Options

 --projectId (-p) <string>            project id
 --accessToken (-a) <string>          user access token
 --localeDefault (-l) <string>        default locale. Default de-DE
 --applicationName (-n) [ <string> ]  name of your application. Default PHP PhraseApp Client
 --help (-h)                          Display this help message
 --version (-V)                       Display this application version

PHP Usage for Synchronize

use DasRed\Zend\Log\Writer\Console as Writer;
use DasRed\Zend\Log\Logger\Console as Logger;
use Zend\Console\Console;
use DasRed\PhraseApp\Synchronize\Files\Type\Php;
use DasRed\PhraseApp\Synchronize\Files;
use DasRed\PhraseApp\Config;

// create logger
$writer = new Writer(Console::getInstance(), Writer::DEBUG);
$logger = new Logger();
$logger->addWriter($writer);

// create the config for synchronizer and co
$projectId = 'This is the project id.';
$accessToken = 'This is the authentication token for your user.';
$localeDefault = 'This is your default or main locale.';
$config = new Config($projectId, $accessToken, $localeDefault);

// This is the user agent which will reported to PhraseApp http://docs.phraseapp.com/api/v2/#identification-via-user-agent
$config->setApplicationName('Fancy Application Name (nuff@example.com)');

// set the direction, which is prefered. If all from PhraseApp is always correct, then REMOTE ist prefered. Otherwise LOCAL
$config->setPreferDirection(Config::PREFER_REMOTE);

// set a default translation key tag which will be setted on translations keys, which will be written to phraseapp
$config->setTagForContentChangeFromLocalToRemote('newContent');

// create the synchronizer for many files
$synchronizer = new Files($logger, $config);

// create and append the handler for file loading and writing
$path = 'This is the path to translation in which the sub pathes defines the locales.';
$excludeNames = ['This is an array of regex to exclude if it match with by file name and file path'];
$handler = new Php($path, $excludeNames);
$synchronizer->appendHandler($handler);


// synchronize everything
if ($synchronizer->synchronize() === false)
{
	throw new \Exception();
}

PHP Usage for Inline Translation of PhraseApp

Instead of using the original translator from \DasRed\Translation\Translator use the Translator (\DasRed\PhraseApp\Translator\PhraseApp) in this client:

// instead of
$translator = new \DasRed\Translation\Translator('de-DE', __DIR__);

// use
$translator = new \DasRed\PhraseApp\Translator\PhraseApp('de-DE', __DIR__);

and then do the rest of the explanation from PhraseApp. The inline key prefix will be "{{__phrase_" and the suffix will be "__}}".

统计信息

  • 总下载量: 20
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-08-11