| Methods |
public
|
get(string $key, ?string $locale = null, list<scalar|Stringable|null>|null $args = null): ?string
Resolves a key like UI5's `ResourceBundle.getText`: locale → language → `en` → base bundle.
Without a locale no…
Resolves a key like UI5's ResourceBundle.getText: locale → language → en → base bundle.
Without a locale no language is requested, and the base bundle answers.
The text is formatted with {@see formatMessage()} only when $args are given; without them
the raw text is returned, as on the client.
|
#
|
public
|
getTitle(?string $locale = null): string
|
#
|
public
|
getDescription(?string $locale = null): string
|
#
|
public
|
all(?string $locale = null): array<string, string>
Returns the entries of one bundle file as written, without the fallback chain;
without a locale, the base bundle.
Returns the entries of one bundle file as written, without the fallback chain;
without a locale, the base bundle.
|
#
|
public
|
getAvailableLocales(): string[]
Returns the list of available locales derived from i18n*.properties files.
Returns the list of available locales derived from i18n*.properties files.
The implicit base locale (i18n.properties) is intentionally excluded, as it
represents the default fallback and not a concrete locale.
Returns
List of locale identifiers (e.g. ['de', 'en'])
|
#
|
public
static
|
formatMessage(string $pattern, list<scalar|Stringable|null> $args): string
Port of UI5's `sap/base/strings/formatMessage`: `{N}` (and `{N,…}`) take the N-th argument,
`''` is one apostrophe, a…
Port of UI5's sap/base/strings/formatMessage: {N} (and {N,…}) take the N-th argument,
'' is one apostrophe, a lone ' opens a quoted section, a stray brace is an error.
Arguments are stringified as JavaScript's String() does, so one bundle reads alike on
client and server — a missing argument renders undefined.
|
#
|
public
static
|
fromI18nProperties(string $path): self
|
#
|
public
static
|
fromMessageBundles(string $path, string $namespace): self
|
#
|
public
static
|
fromBundles(string $path): self
|
#
|
public
static
|
fallbackChain(?string $locale): list<string>
The locales {@see get()} tries, in order: locale → language → `en` → `default` (the base
bundle), normalized the way…
The locales {@see get()} tries, in order: locale → language → en → default (the base
bundle), normalized the way bundle files are named (de-AT → de_at). Without a locale only
the base bundle. Public so that a map keyed by bundle locale — a text resolved at build time
into every language of its bundle — is read along the same chain.
|
#
|
public
static
|
readEntries(string $file): list<array{key: string, value: string, line: int, loneSurrogate: bool}>
Every entry of a `.properties` file in file order — a duplicate key appears twice,
where the bundle keeps only the last…
Every entry of a .properties file in file order — a duplicate key appears twice,
where the bundle keeps only the last. line is the line the entry starts on;
loneSurrogate says that a \uD800–\uDFFF escape lacked its pair and became
U+FFFD. Read the way UI5 reads a bundle.
Throws
LogicException |
when the file is not UTF-8 or holds an incomplete \u escape
|
|
#
|
public
static
|
placeholders(string $pattern): list<int>
The argument indices a message pattern uses — `{0}`, `{1,number}` — read as
{@see formatMessage()} reads them: quoted…
The argument indices a message pattern uses — {0}, {1,number} — read as
{@see formatMessage()} reads them: quoted sections hold no placeholder.
Returns
|
#
|