Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0160fd5

Browse files
committed
[Intl] Moved stub data to Icu component 1.0.x
1 parentdbca3b7 commit0160fd5

File tree

8 files changed

+16
-3254
lines changed

8 files changed

+16
-3254
lines changed

‎src/Symfony/Component/Intl/Intl.php

Lines changed: 12 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,12 @@
3333
*/
3434
class Intl
3535
{
36-
/**
37-
* Load data from the Icu component.
38-
*/
39-
constICU =0;
40-
41-
/**
42-
* Load data from the stub files of the Intl component.
43-
*/
44-
constSTUB =1;
45-
4636
/**
4737
* The number of resource bundles to buffer. Loading the same resource
4838
* bundle for n locales takes up n spots in the buffer.
4939
*/
5040
constBUFFER_SIZE =10;
5141

52-
/**
53-
* The accepted values for the {@link $dataSource} property.
54-
*
55-
* @var array
56-
*/
57-
privatestatic$allowedDataSources =array(
58-
self::ICU =>'Intl::ICU',
59-
self::STUB =>'Intl::STUB',
60-
);
61-
62-
/**
63-
* @var integer
64-
*/
65-
privatestatic$dataSource;
66-
6742
/**
6843
* @var ResourceBundle\CurrencyBundleInterface
6944
*/
@@ -97,12 +72,7 @@ class Intl
9772
/**
9873
* @var ResourceBundle\Reader\StructuredBundleReaderInterface
9974
*/
100-
privatestatic$phpReader;
101-
102-
/**
103-
* @var ResourceBundle\Reader\StructuredBundleReaderInterface
104-
*/
105-
privatestatic$binaryReader;
75+
privatestatic$bundleReader;
10676

10777
/**
10878
* Returns whether the intl extension is installed.
@@ -111,66 +81,7 @@ class Intl
11181
*/
11282
publicstaticfunctionisExtensionLoaded()
11383
{
114-
return IcuData::isLoadable();
115-
}
116-
117-
/**
118-
* Sets the data source from which to load the resource bundles.
119-
*
120-
* @param integer $dataSource One of the constants {@link Intl::ICU} or
121-
* {@link Intl::STUB}.
122-
*
123-
* @throws InvalidArgumentException If the data source is invalid.
124-
*
125-
* @see getData>Source
126-
*/
127-
publicstaticfunctionsetDataSource($dataSource)
128-
{
129-
if (!isset(self::$allowedDataSources[$dataSource])) {
130-
thrownewInvalidArgumentException(sprintf(
131-
'The data sources should be one of %s',
132-
implode(',',self::$allowedDataSources)
133-
));
134-
}
135-
136-
if (self::ICU ===$dataSource && !IcuData::isLoadable()) {
137-
thrownewInvalidArgumentException(
138-
'The data source cannot be set to Intl::ICU if the intl' .
139-
'extension is not installed.'
140-
);
141-
}
142-
143-
if ($dataSource !==self::$dataSource) {
144-
self::$currencyBundle =null;
145-
self::$languageBundle =null;
146-
self::$localeBundle =null;
147-
self::$regionBundle =null;
148-
}
149-
150-
self::$dataSource =$dataSource;
151-
}
152-
153-
/**
154-
* Returns the data source from which to load the resource bundles.
155-
*
156-
* If {@link setDataSource()} has not been called, the data source will be
157-
* chosen depending on whether the intl extension is installed or not:
158-
*
159-
* * If the extension is present, the bundles will be loaded from the Icu
160-
* component;
161-
* * Otherwise, the bundles will be loaded from the stub files in the
162-
* Intl component.
163-
*
164-
* @return integer One of the constants {@link Intl::ICU} or
165-
* {@link Intl::STUB}.
166-
*/
167-
publicstaticfunctiongetDataSource()
168-
{
169-
if (null ===self::$dataSource) {
170-
self::$dataSource = IcuData::isLoadable() ?self::ICU :self::STUB;
171-
}
172-
173-
returnself::$dataSource;
84+
returnclass_exists('\ResourceBundle');
17485
}
17586

17687
/**
@@ -181,9 +92,7 @@ public static function getDataSource()
18192
publicstaticfunctiongetCurrencyBundle()
18293
{
18394
if (null ===self::$currencyBundle) {
184-
self::$currencyBundle =self::ICU ===self::getDataSource()
185-
?newIcuCurrencyBundle(self::getBinaryReader())
186-
:newStubCurrencyBundle(self::getPhpReader());
95+
self::$currencyBundle =newIcuCurrencyBundle(self::getBundleReader());
18796
}
18897

18998
returnself::$currencyBundle;
@@ -197,9 +106,7 @@ public static function getCurrencyBundle()
197106
publicstaticfunctiongetLanguageBundle()
198107
{
199108
if (null ===self::$languageBundle) {
200-
self::$languageBundle =self::ICU ===self::getDataSource()
201-
?newIcuLanguageBundle(self::getBinaryReader())
202-
:newStubLanguageBundle(self::getPhpReader());
109+
self::$languageBundle =newIcuLanguageBundle(self::getBundleReader());
203110
}
204111

205112
returnself::$languageBundle;
@@ -213,9 +120,7 @@ public static function getLanguageBundle()
213120
publicstaticfunctiongetLocaleBundle()
214121
{
215122
if (null ===self::$localeBundle) {
216-
self::$localeBundle =self::ICU ===self::getDataSource()
217-
?newIcuLocaleBundle(self::getBinaryReader())
218-
:newStubLocaleBundle(self::getPhpReader());
123+
self::$localeBundle =newIcuLocaleBundle(self::getBundleReader());
219124
}
220125

221126
returnself::$localeBundle;
@@ -229,9 +134,7 @@ public static function getLocaleBundle()
229134
publicstaticfunctiongetRegionBundle()
230135
{
231136
if (null ===self::$regionBundle) {
232-
self::$regionBundle =self::ICU ===self::getDataSource()
233-
?newIcuRegionBundle(self::getBinaryReader())
234-
:newStubRegionBundle(self::getPhpReader());
137+
self::$regionBundle =newIcuRegionBundle(self::getBundleReader());
235138
}
236139

237140
returnself::$regionBundle;
@@ -275,9 +178,7 @@ public static function getIcuVersion()
275178
publicstaticfunctiongetIcuDataVersion()
276179
{
277180
if (false ===self::$icuDataVersion) {
278-
self::$icuDataVersion =self::ICU ===self::getDataSource()
279-
? IcuData::getVersion()
280-
:file_get_contents(__DIR__ .'/Resources/version.txt');
181+
self::$icuDataVersion = IcuData::getVersion();
281182
}
282183

283184
returnself::$icuDataVersion;
@@ -298,33 +199,16 @@ public static function getIcuStubVersion()
298199
*
299200
* @return ResourceBundle\Reader\StructuredBundleReaderInterface The resource reader.
300201
*/
301-
privatestaticfunctiongetPhpReader()
302-
{
303-
if (null ===self::$phpReader) {
304-
self::$phpReader =newStructuredBundleReader(newBufferedBundleReader(
305-
newPhpBundleReader(),
306-
self::BUFFER_SIZE
307-
));
308-
}
309-
310-
returnself::$phpReader;
311-
}
312-
313-
/**
314-
* Returns a resource bundle reader for binary .res resource bundle files.
315-
*
316-
* @return ResourceBundle\Reader\StructuredBundleReaderInterface The resource reader.
317-
*/
318-
privatestaticfunctiongetBinaryReader()
202+
privatestaticfunctiongetBundleReader()
319203
{
320-
if (null ===self::$binaryReader) {
321-
self::$binaryReader =newStructuredBundleReader(newBufferedBundleReader(
322-
newBinaryBundleReader(),
204+
if (null ===self::$bundleReader) {
205+
self::$bundleReader =newStructuredBundleReader(newBufferedBundleReader(
206+
IcuData::isLoadable() ?newBinaryBundleReader() :newPhpBundleReader(),
323207
self::BUFFER_SIZE
324208
));
325209
}
326210

327-
returnself::$binaryReader;
211+
returnself::$bundleReader;
328212
}
329213

330214
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp