| 1 |
<?php |
| 2 |
|
| 3 |
namespace Gettext\Languages\Exporter; |
| 4 |
|
| 5 |
use Exception; |
| 6 |
|
| 7 |
class Po extends Exporter |
| 8 |
{ |
| 9 |
/** |
| 10 |
* {@inheritdoc} |
| 11 |
* |
| 12 |
* @see \Gettext\Languages\Exporter\Exporter::getDescription() |
| 13 |
*/ |
| 14 |
public static function getDescription() |
| 15 |
{ |
| 16 |
return 'Build a string to be used for gettext .po files'; |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* {@inheritdoc} |
| 21 |
* |
| 22 |
* @see \Gettext\Languages\Exporter\Exporter::toStringDoWithOptions() |
| 23 |
*/ |
| 24 |
protected static function toStringDoWithOptions($languages, array $options) |
| 25 |
{ |
| 26 |
if (count($languages) !== 1) { |
| 27 |
throw new Exception('The ' . get_called_class() . ' exporter can only export one language'); |
| 28 |
} |
| 29 |
$language = $languages[0]; |
| 30 |
$lines = array(); |
| 31 |
$lines[] = '"Language: ' . $language->id . '\n"'; |
| 32 |
$lines[] = '"Plural-Forms: nplurals=' . count($language->categories) . '; plural=' . $language->formula . '\n"'; |
| 33 |
$lines[] = ''; |
| 34 |
|
| 35 |
return implode("\n", $lines); |
| 36 |
} |
| 37 |
} |
| 38 |
|