Skip to content

Commit f653980

Browse files
committed
Min Support Plurals
1 parent 7647fd5 commit f653980

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

src/Cli/GenerateTPL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ protected function _processMatches(array $matches, $file)
138138
$this->_writeCatalog($catalog);
139139
}
140140

141-
protected function _writeCatalog($catalog)
141+
protected function _writeCatalog(DynamicArrayCatalog $catalog)
142142
{
143143
$root = rtrim($this->getContext()->getProjectRoot(), DIRECTORY_SEPARATOR);
144144
$transDir = $root . DIRECTORY_SEPARATOR . 'translations' . DIRECTORY_SEPARATOR;

src/Cli/Potoar.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,24 @@ protected function _processLanguage($source, $output): void
7272
{
7373
foreach($translation->getReferences() as $ref)
7474
{
75+
$out[] = "'" . $ref . "' => [";
76+
7577
if($translation->getSingularTranslation())
7678
{
77-
$out[] = "'" . $ref . "' => ['_' => '"
78-
. addcslashes(stripslashes($this->_toTranslation($translation->getSingularTranslation())), "'")
79-
. "'],";
79+
$out[] = "'_' => '" . addcslashes(
80+
stripslashes($this->_toTranslation($translation->getSingularTranslation())),
81+
"'"
82+
) . "',";
83+
}
84+
85+
if($translation->getPluralTranslation())
86+
{
87+
$out[] = "'2..n' => '" . addcslashes(
88+
stripslashes($this->_toTranslation($translation->getPluralTranslation())),
89+
"'"
90+
) . "',";
8091
}
92+
$out[] = "],";
8193
}
8294
}
8395
}

src/Cli/Translate.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,16 @@ protected function _createTranslations($mid, $options, $lang, PoFile $poEdit): v
8484
unset($options['n']);
8585
}
8686

87-
$tran->setAdditionalPluralTranslations($options);
87+
if(isset($options['n..0,2..n']))
88+
{
89+
$tran->setSingularSource($options[1]);
90+
$tran->setPluralSource($options['n..0,2..n']);
91+
92+
$tran->setSingularTranslation($this->_getTranslation($options[1], $lang));
93+
$tran->setPluralTranslation($this->_getTranslation($options['n..0,2..n'], $lang));
94+
unset($options['n..0,2..n']);
95+
}
96+
8897
$poEdit->addTranslation($tran);
8998
}
9099

0 commit comments

Comments
 (0)