diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
commit | 4f5b44bd3bd490309eb2ba7b44df4769816ba729 (patch) | |
tree | 6cefe170dfe0a5a361cb1e2d1fc4d580a3316d02 /vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php | |
parent | 2b840e0cfb63a453bea67a98541f3df9c273c5f5 (diff) | |
download | wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.gz wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.zst wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.zip |
twig implementation
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php')
-rw-r--r-- | vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php new file mode 100644 index 00000000..95783b3b --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php | |||
@@ -0,0 +1,94 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\ResourceBundle\Transformer\Rule; | ||
13 | |||
14 | use Symfony\Component\Intl\Intl; | ||
15 | use Symfony\Component\Intl\ResourceBundle\CurrencyBundle; | ||
16 | use Symfony\Component\Intl\ResourceBundle\Transformer\CompilationContextInterface; | ||
17 | use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContextInterface; | ||
18 | use Symfony\Component\Intl\Util\IcuVersion; | ||
19 | |||
20 | /** | ||
21 | * The rule for compiling the currency bundle. | ||
22 | * | ||
23 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
24 | */ | ||
25 | class CurrencyBundleTransformationRule implements TransformationRuleInterface | ||
26 | { | ||
27 | /** | ||
28 | * {@inheritdoc} | ||
29 | */ | ||
30 | public function getBundleName() | ||
31 | { | ||
32 | return 'curr'; | ||
33 | } | ||
34 | |||
35 | /** | ||
36 | * {@inheritdoc} | ||
37 | */ | ||
38 | public function beforeCompile(CompilationContextInterface $context) | ||
39 | { | ||
40 | // The currency data is contained in the locales and misc bundles | ||
41 | // in ICU <= 4.2 | ||
42 | if (IcuVersion::compare($context->getIcuVersion(), '4.2', '<=', 1)) { | ||
43 | return array( | ||
44 | $context->getSourceDir() . '/misc/supplementalData.txt', | ||
45 | $context->getSourceDir() . '/locales' | ||
46 | ); | ||
47 | } | ||
48 | |||
49 | return $context->getSourceDir() . '/curr'; | ||
50 | } | ||
51 | |||
52 | /** | ||
53 | * {@inheritdoc} | ||
54 | */ | ||
55 | public function afterCompile(CompilationContextInterface $context) | ||
56 | { | ||
57 | // \ResourceBundle does not like locale names with uppercase chars, so rename | ||
58 | // the resource file | ||
59 | // See: http://bugs.php.net/bug.php?id=54025 | ||
60 | $fileName = $context->getBinaryDir() . '/curr/supplementalData.res'; | ||
61 | $fileNameLower = $context->getBinaryDir() . '/curr/supplementaldata.res'; | ||
62 | |||
63 | $context->getFilesystem()->rename($fileName, $fileNameLower); | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * {@inheritdoc} | ||
68 | */ | ||
69 | public function beforeCreateStub(StubbingContextInterface $context) | ||
70 | { | ||
71 | $currencies = array(); | ||
72 | $currencyBundle = Intl::getCurrencyBundle(); | ||
73 | |||
74 | foreach ($currencyBundle->getCurrencyNames('en') as $code => $name) { | ||
75 | $currencies[$code] = array( | ||
76 | CurrencyBundle::INDEX_NAME => $name, | ||
77 | CurrencyBundle::INDEX_SYMBOL => $currencyBundle->getCurrencySymbol($code, 'en'), | ||
78 | CurrencyBundle::INDEX_FRACTION_DIGITS => $currencyBundle->getFractionDigits($code), | ||
79 | CurrencyBundle::INDEX_ROUNDING_INCREMENT => $currencyBundle->getRoundingIncrement($code), | ||
80 | ); | ||
81 | } | ||
82 | |||
83 | return array( | ||
84 | 'Currencies' => $currencies, | ||
85 | ); | ||
86 | } | ||
87 | |||
88 | /** | ||
89 | * {@inheritdoc} | ||
90 | */ | ||
91 | public function afterCreateStub(StubbingContextInterface $context) | ||
92 | { | ||
93 | } | ||
94 | } | ||