dasred / php-phraseapp-client
This package is abandoned and no longer maintained.
No replacement package was suggested.
There is no license information available for the latest version (v2.1.1) of this package.
v2.1.1
2015-10-22 09:59 UTC
Requires
- php: >=5.5
- ext-curl: *
- dasred/translation: @stable
- dasred/zend-console: @stable
- dasred/zend-log: @stable
- zendframework/zend-http: @stable
- zendframework/zend-progressbar: ~2.5
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 "__}}".