Skip to content

Commit e75a906

Browse files
committed
minor #11590 [Intl] Remove "Writing and Reading Resource Bundles" section (ro0NL)
This PR was submitted for the master branch but it was squashed and merged into the 4.3 branch instead (closes #11590). Discussion ---------- [Intl] Remove "Writing and Reading Resource Bundles" section Hi, I propose to remove the section _Writing and Reading Resource Bundles_ entirely at https://symfony.com/doc/master/components/intl.html#writing-and-reading-resource-bundles The `Data` namespace (https://github.com/symfony/symfony/tree/master/src/Symfony/Component/Intl/Data) is completely `@internal`, so i dont think this is really relevant for user docs. _Accessing ICU Data_ is, and should be on top IMHO. Commits ------- a3d8a57 [Intl] Remove \"Writing and Reading Resource Bundles\" section
2 parents cb5848e + a3d8a57 commit e75a906

File tree

1 file changed

+1
-154
lines changed

1 file changed

+1
-154
lines changed

components/intl.rst

Lines changed: 1 addition & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -52,160 +52,6 @@ replace the intl classes:
5252

5353
Composer automatically exposes these classes in the global namespace.
5454

55-
Writing and Reading Resource Bundles
56-
------------------------------------
57-
58-
The :phpclass:`ResourceBundle` class is not currently supported by this component.
59-
Instead, it includes a set of readers and writers for reading and writing
60-
arrays (or array-like objects) from/to resource bundle files. The following
61-
classes are supported:
62-
63-
* `TextBundleWriter`_
64-
* `PhpBundleWriter`_
65-
* `BinaryBundleReader`_
66-
* `PhpBundleReader`_
67-
* `BufferedBundleReader`_
68-
* `StructuredBundleReader`_
69-
70-
Continue reading if you are interested in how to use these classes. Otherwise
71-
skip this section and jump to `Accessing ICU Data`_.
72-
73-
TextBundleWriter
74-
~~~~~~~~~~~~~~~~
75-
76-
The :class:`Symfony\\Component\\Intl\\ResourceBundle\\Writer\\TextBundleWriter`
77-
writes an array or an array-like object to a plain-text resource bundle. The
78-
resulting .txt file can be converted to a binary .res file with the
79-
:class:`Symfony\\Component\\Intl\\ResourceBundle\\Compiler\\BundleCompiler`
80-
class::
81-
82-
use Symfony\Component\Intl\ResourceBundle\Compiler\BundleCompiler;
83-
use Symfony\Component\Intl\ResourceBundle\Writer\TextBundleWriter;
84-
85-
$writer = new TextBundleWriter();
86-
$writer->write('/path/to/bundle', 'en', [
87-
'Data' => [
88-
'entry1',
89-
'entry2',
90-
// ...
91-
],
92-
]);
93-
94-
$compiler = new BundleCompiler();
95-
$compiler->compile('/path/to/bundle', '/path/to/binary/bundle');
96-
97-
The command "genrb" must be available for the
98-
:class:`Symfony\\Component\\Intl\\ResourceBundle\\Compiler\\BundleCompiler` to
99-
work. If the command is located in a non-standard location, you can pass its
100-
path to the
101-
:class:`Symfony\\Component\\Intl\\ResourceBundle\\Compiler\\BundleCompiler`
102-
constructor.
103-
104-
PhpBundleWriter
105-
~~~~~~~~~~~~~~~
106-
107-
The :class:`Symfony\\Component\\Intl\\ResourceBundle\\Writer\\PhpBundleWriter`
108-
writes an array or an array-like object to a .php resource bundle::
109-
110-
use Symfony\Component\Intl\ResourceBundle\Writer\PhpBundleWriter;
111-
112-
$writer = new PhpBundleWriter();
113-
$writer->write('/path/to/bundle', 'en', [
114-
'Data' => [
115-
'entry1',
116-
'entry2',
117-
// ...
118-
],
119-
]);
120-
121-
BinaryBundleReader
122-
~~~~~~~~~~~~~~~~~~
123-
124-
The :class:`Symfony\\Component\\Intl\\ResourceBundle\\Reader\\BinaryBundleReader`
125-
reads binary resource bundle files and returns an array or an array-like object.
126-
This class currently only works with the `intl extension`_ installed::
127-
128-
use Symfony\Component\Intl\ResourceBundle\Reader\BinaryBundleReader;
129-
130-
$reader = new BinaryBundleReader();
131-
$data = $reader->read('/path/to/bundle', 'en');
132-
133-
var_dump($data['Data']['entry1']);
134-
135-
PhpBundleReader
136-
~~~~~~~~~~~~~~~
137-
138-
The :class:`Symfony\\Component\\Intl\\ResourceBundle\\Reader\\PhpBundleReader`
139-
reads resource bundles from .php files and returns an array or an array-like
140-
object::
141-
142-
use Symfony\Component\Intl\ResourceBundle\Reader\PhpBundleReader;
143-
144-
$reader = new PhpBundleReader();
145-
$data = $reader->read('/path/to/bundle', 'en');
146-
147-
var_dump($data['Data']['entry1']);
148-
149-
BufferedBundleReader
150-
~~~~~~~~~~~~~~~~~~~~
151-
152-
The :class:`Symfony\\Component\\Intl\\ResourceBundle\\Reader\\BufferedBundleReader`
153-
wraps another reader, but keeps the last N reads in a buffer, where N is a
154-
buffer size passed to the constructor::
155-
156-
use Symfony\Component\Intl\ResourceBundle\Reader\BinaryBundleReader;
157-
use Symfony\Component\Intl\ResourceBundle\Reader\BufferedBundleReader;
158-
159-
$reader = new BufferedBundleReader(new BinaryBundleReader(), 10);
160-
161-
// actually reads the file
162-
$data = $reader->read('/path/to/bundle', 'en');
163-
164-
// returns data from the buffer
165-
$data = $reader->read('/path/to/bundle', 'en');
166-
167-
// actually reads the file
168-
$data = $reader->read('/path/to/bundle', 'fr');
169-
170-
StructuredBundleReader
171-
~~~~~~~~~~~~~~~~~~~~~~
172-
173-
The :class:`Symfony\\Component\\Intl\\ResourceBundle\\Reader\\StructuredBundleReader`
174-
wraps another reader and offers a
175-
:method:`Symfony\\Component\\Intl\\ResourceBundle\\Reader\\StructuredBundleReaderInterface::readEntry`
176-
method for reading an entry of the resource bundle without having to worry
177-
whether array keys are set or not. If a path cannot be resolved, ``null`` is
178-
returned::
179-
180-
use Symfony\Component\Intl\ResourceBundle\Reader\BinaryBundleReader;
181-
use Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReader;
182-
183-
$reader = new StructuredBundleReader(new BinaryBundleReader());
184-
185-
$data = $reader->read('/path/to/bundle', 'en');
186-
187-
// produces an error if the key "Data" does not exist
188-
var_dump($data['Data']['entry1']);
189-
190-
// returns null if the key "Data" does not exist
191-
var_dump($reader->readEntry('/path/to/bundle', 'en', ['Data', 'entry1']));
192-
193-
Additionally, the
194-
:method:`Symfony\\Component\\Intl\\ResourceBundle\\Reader\\StructuredBundleReaderInterface::readEntry`
195-
method resolves fallback locales. For example, the fallback locale of "en_GB" is
196-
"en". For single-valued entries (strings, numbers etc.), the entry will be read
197-
from the fallback locale if it cannot be found in the more specific locale. For
198-
multi-valued entries (arrays), the values of the more specific and the fallback
199-
locale will be merged. In order to suppress this behavior, the last parameter
200-
``$fallback`` can be set to ``false``::
201-
202-
var_dump($reader->readEntry(
203-
'/path/to/bundle',
204-
'en',
205-
['Data', 'entry1'],
206-
false
207-
));
208-
20955
Accessing ICU Data
21056
------------------
21157

@@ -442,6 +288,7 @@ Learn more
442288
/reference/forms/types/currency
443289
/reference/forms/types/language
444290
/reference/forms/types/locale
291+
/reference/forms/types/timezone
445292

446293
.. _Packagist: https://packagist.org/packages/symfony/intl
447294
.. _Icu component: https://packagist.org/packages/symfony/icu

0 commit comments

Comments
 (0)