Skip to content
Permalink
Browse files

Ignore LC_TIME category when extracting messages.

Given that we use the specific LC_TIME file format, it doesn't make much
sense to extract translated strings into a PO file that cannot be used
later on.

Refs #5933
  • Loading branch information...
markstory committed Feb 23, 2015
1 parent ffab0c1 commit 831fe53f793e13fbef42633ed85ee6da5a3ba928
@@ -432,6 +432,7 @@ protected function _parse($functionName, $map) {
$category = isset($category) ? $category : 6;
$category = (int)$category;
$categoryName = $categories[$category];
$domain = isset($domain) ? $domain : 'default';
$details = array(
'file' => $this->_file,
@@ -443,7 +444,10 @@ protected function _parse($functionName, $map) {
if (isset($context)) {
$details['msgctxt'] = $context;
}
$this->_addTranslation($categoryName, $domain, $singular, $details);
// Skip LC_TIME files as we use a special file format for them.
if ($categoryName !== 'LC_TIME') {
$this->_addTranslation($categoryName, $domain, $singular, $details);
}
} else {
$this->_markerError($this->_file, $line, $functionName, $count);
}
@@ -162,19 +162,19 @@ public function testExecute() {
$this->assertContains('msgid "double \\"quoted\\""', $result, 'Strings with quotes not handled correctly');
$this->assertContains("msgid \"single 'quoted'\"", $result, 'Strings with quotes not handled correctly');
$pattern = '/\#: (\\\\|\/)extract\.ctp:34\nmsgid "letter"/';
$pattern = '/\#: (\\\\|\/)extract\.ctp:36\nmsgid "letter"/';
$this->assertRegExp($pattern, $result, 'Strings with context should not overwrite strings without context');
$pattern = '/\#: (\\\\|\/)extract\.ctp:35;37\nmsgctxt "A"\nmsgid "letter"/';
$pattern = '/\#: (\\\\|\/)extract\.ctp:37;39\nmsgctxt "A"\nmsgid "letter"/';
$this->assertRegExp($pattern, $result, 'Should contain string with context "A"');
$pattern = '/\#: (\\\\|\/)extract\.ctp:36\nmsgctxt "B"\nmsgid "letter"/';
$pattern = '/\#: (\\\\|\/)extract\.ctp:38\nmsgctxt "B"\nmsgid "letter"/';
$this->assertRegExp($pattern, $result, 'Should contain string with context "B"');
$pattern = '/\#: (\\\\|\/)extract\.ctp:38\nmsgid "%d letter"\nmsgid_plural "%d letters"/';
$pattern = '/\#: (\\\\|\/)extract\.ctp:40\nmsgid "%d letter"\nmsgid_plural "%d letters"/';
$this->assertRegExp($pattern, $result, 'Plural strings with context should not overwrite strings without context');
$pattern = '/\#: (\\\\|\/)extract\.ctp:39\nmsgctxt "A"\nmsgid "%d letter"\nmsgid_plural "%d letters"/';
$pattern = '/\#: (\\\\|\/)extract\.ctp:41\nmsgctxt "A"\nmsgid "%d letter"\nmsgid_plural "%d letters"/';
$this->assertRegExp($pattern, $result, 'Should contain plural string with context "A"');
// extract.ctp - reading the domain.pot
@@ -209,12 +209,16 @@ public function testExtractCategory() {
$this->Task->expects($this->never())->method('_stop');
$this->Task->execute();
$this->assertTrue(file_exists($this->path . DS . 'LC_TIME' . DS . 'default.pot'));
$this->assertTrue(file_exists($this->path . DS . 'LC_NUMERIC' . DS . 'default.pot'));
$this->assertFalse(file_exists($this->path . DS . 'LC_TIME' . DS . 'default.pot'));
$result = file_get_contents($this->path . DS . 'default.pot');
$pattern = '/\#: .*extract\.ctp:31\n/';
$this->assertNotRegExp($pattern, $result);
$pattern = '/\#: .*extract\.ctp:33\n/';
$this->assertNotRegExp($pattern, $result);
}
/**
@@ -28,6 +28,8 @@ __('Hot features!'
. ' Join us #cakephp on IRC. We\'d love to help you get started');
// Category
echo __c('You have a new message (category: LC_NUMERIC).', 4);
// LC_TIME is skipped.
echo __c('You have a new message (category: LC_TIME).', 5);
// Context

0 comments on commit 831fe53

Please sign in to comment.
You can’t perform that action at this time.