Skip to content

Commit

Permalink
Sync.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Scherer committed Jan 20, 2015
1 parent 92a5d6f commit 1c065cb
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 10 deletions.
56 changes: 49 additions & 7 deletions Console/Command/TransifexShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class TransifexShell extends AppShell {
public function startup() {
parent::startup();

$settings = array();
$settings = array(
'debug' => $this->params['debug']
);
if (!empty($this->params['project'])) {
$settings['project'] = $this->params['project'];
}
Expand Down Expand Up @@ -57,6 +59,34 @@ public function languages() {
}
}

/**
* TransifexShell::languages()
*
* @return void
*/
public function language() {
$lang = !empty($this->args[0]) ? $this->args[0] : null;
if (!$lang) {
return $this->error('No language specified, please use two-letter-code, e.g. "de" or "en".');
}
$language = $this->Transifex->getLanguage($lang);
$this->out(print_r($language, true));
}

/**
* TransifexShell::languages()
*
* @return void
*/
public function language_info() {
$lang = !empty($this->args[0]) ? $this->args[0] : null;
if (!$lang) {
return $this->error('No language specified, please use two-letter-code, e.g. "de" or "en".');
}
$language = $this->Transifex->getLanguageInfo($lang);
$this->out(print_r($language, true));
}

/**
* TransifexShell::statistics()
*
Expand Down Expand Up @@ -376,6 +406,10 @@ public function getOptionParser() {
'help' => 'Project',
'default' => '',
),
'debug' => array(
'help' => 'Debug output (for network/connection details).',
'boolean' => true
),
)
);
$subcommandParserPull = $subcommandParser;
Expand Down Expand Up @@ -410,28 +444,36 @@ public function getOptionParser() {
return parent::getOptionParser()
->description("The Convert Shell converts files from dos/unix/mac to another system")
->addSubcommand('resources', array(
'help' => 'List all resources',
'help' => 'List all resources.',
'parser' => $subcommandParser
))
->addSubcommand('languages', array(
'help' => 'List all languages',
'help' => 'List all languages.',
'parser' => $subcommandParser
))
->addSubcommand('language', array(
'help' => 'Get project infos to a specific language.',
'parser' => $subcommandParser
))
->addSubcommand('statistics', array(
'help' => 'Display project statistics',
'help' => 'Display project statistics.',
'parser' => $subcommandParser
))
->addSubcommand('pull', array(
'help' => 'Pull PO files',
'help' => 'Pull PO files.',
'parser' => $subcommandParserPull
))
->addSubcommand('push', array(
'help' => 'Push PO files',
'help' => 'Push PO files.',
'parser' => $subcommandParserPull
))
->addSubcommand('update', array(
'help' => 'Update POT files',
'help' => 'Update POT files.',
'parser' => $subcommandParserPull
))
->addSubcommand('language_info', array(
'help' => 'Get infos to a specific language.',
'parser' => $subcommandParser
));
}

Expand Down
12 changes: 11 additions & 1 deletion Lib/TransifexLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TransifexLib {
'project' => '',
'user' => '',
'password' => '',
'debug' => false,
'debug' => false, // Verbose debugging for curl (when putting)
);

/**
Expand Down Expand Up @@ -94,6 +94,16 @@ public function getLanguage($language) {
return $this->_get($url);
}

/**
* TransifexLib::getLanguageInfo()
*
* @return array
*/
public function getLanguageInfo($language) {
$url = static::BASE_URL . 'language/' . $language . '/';
return $this->_get($url);
}

/**
* TransifexLib::getTranslations()
*
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[![License](https://poser.pugx.org/dereuromark/cakephp-transifex/license.png)](https://packagist.org/packages/dereuromark/cakephp-transifex)
[![Total Downloads](https://poser.pugx.org/dereuromark/cakephp-transifex/d/total.png)](https://packagist.org/packages/dereuromark/cakephp-transifex)

A CakePHP 2.x Plugin that works with Transifex and pulls/pushes translations.
A CakePHP 2.x Plugin that works with [Transifex](https://www.transifex.com/) and pulls/pushes translations.
It uses the [Transifex API v2](http://docs.transifex.com/developer/api/).

Please note: New functionality has been tested against latest CakePHP v2.x only. Please upgrade if possible.

Expand Down Expand Up @@ -68,6 +69,9 @@ If you happen to have one primary project and several other (plugin or CakePHP c

Tip: If you want to dry-run it first, use `-d -v`. This will not modify your locale files but simulate the import.

### Debugging
Use `--debug` to have more verbose debugging output when pushing via cURL.

## TODO

* More tests
Expand Down
4 changes: 4 additions & 0 deletions Test/Case/Console/Command/TransifexShellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class TransifexShellTest extends CakeTestCase {
public function setUp() {
parent::setUp();

CakePlugin::load(array(
'Transifex'
));

$this->TransifexShell = new TransifexShell();
}

Expand Down
2 changes: 1 addition & 1 deletion Test/Case/Lib/TransifexLibTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testPutTranslations() {
'strings_updated' => 0,
'strings_delete' => 0,
);
$file = 'C:\xampp\htdocs\repo\cakefest\Plugin\Transifex\Test\test_files\test.pot';
$file = dirname(__FILE__) . '/../../test_files/test.pot';
$this->Transifex->expects($this->any())
->method('_put')
->will($this->returnValue($mockedResponse));
Expand Down

0 comments on commit 1c065cb

Please sign in to comment.