W3cubDocs

/Symfony 4.1

PoFileLoader

class PoFileLoader extends FileLoader

Methods

MessageCatalogue load(mixed $resource, string $locale, string $domain = 'messages')

Loads a locale.

from FileLoader
array loadResource(string $resource)

Parses portable object (PO) format.

Details

MessageCatalogue load(mixed $resource, string $locale, string $domain = 'messages')

Loads a locale.

Parameters

mixed $resource A resource
string $locale A locale
string $domain The domain

Return Value

MessageCatalogue A MessageCatalogue instance

Exceptions

NotFoundResourceException when the resource cannot be found
InvalidResourceException when the resource cannot be loaded

protected array loadResource(string $resource)

Parses portable object (PO) format.

From http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files we should be able to parse files having:

white-space

translator-comments

. extracted-comments

: reference...

, flag...

| msgid previous-untranslated-string

msgid untranslated-string msgstr translated-string

extra or different lines are:

| msgctxt previous-context

| msgid previous-untranslated-string

msgctxt context

| msgid previous-untranslated-string-singular

| msgid_plural previous-untranslated-string-plural

msgid untranslated-string-singular msgid_plural untranslated-string-plural msgstr[0] translated-string-case-0 ... msgstr[N] translated-string-case-n

The definition states: - white-space and comments are optional. - msgid "" that an empty singleline defines a header.

This parser sacrifices some features of the reference implementation the differences to that implementation are as follows. - No support for comments spanning multiple lines. - Translator and extracted comments are treated as being the same type. - Message IDs are allowed to have other encodings as just US-ASCII.

Items with an empty id are ignored.

{@inheritdoc}

Parameters

string $resource

Return Value

array

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Translation/Loader/PoFileLoader.html