Documentation

TemporaryTextDomain
in package

Allows to set a given text domain to be translated from a .mo file.

Table of Contents

Properties

$currentlyActiveLocale  : mixed
List of currently active temporary text domains per domain.
$domain  : mixed
$fallbackDomain  : mixed
$languageFile  : mixed
$locale  : mixed
$pomo  : MO|PO
PO/MO instance. Can be null if the given language file is not found.
$pomoInstances  : array<string|int, MO|PO>
Mo-file to MO instances for caching purposes to avoid a lot of `import_from_file` calls as they are not very performant.
$previousActiveLocale  : TemporaryTextDomain
Previous active temporary text domain.
$skipFallbackTranslation  : mixed

Methods

__construct()  : mixed
C'tor.
fromPluginReceiver()  : mixed
Create a temporary text domain from a given WP React Starter plugin receiver.
getEntries()  : mixed
Get all translation entries of the given MO file.
getLocale()  : mixed
Getter.
gettext()  : mixed
Gettext filter.
gettext_with_context()  : mixed
Gettext with context filter.
isCurrentlyActive()  : mixed
Checs if this temporary text domain is the latest registered one in stack?
teardown()  : mixed
Teardown the `gettext` filter.
createPomo()  : mixed
Create a PO or MO instance with memory caching enabled.
fromLanguageFiles()  : mixed
Create PO/MO instance from language file(s).
hooks()  : mixed
Create `gettext` hooks.

Properties

$currentlyActiveLocale

List of currently active temporary text domains per domain.

private static mixed $currentlyActiveLocale = []

$pomo

PO/MO instance. Can be null if the given language file is not found.

private MO|PO $pomo = null

$pomoInstances

Mo-file to MO instances for caching purposes to avoid a lot of `import_from_file` calls as they are not very performant.

private static array<string|int, MO|PO> $pomoInstances = []

Methods

__construct()

C'tor.

public __construct(string $domain, string $fallbackDomain, string|array<string|int, string> $languageFile, string $locale[, bool $skipFallbackTranslation = false ]) : mixed
Parameters
$domain : string
$fallbackDomain : string
$languageFile : string|array<string|int, string>

Can be a .po, .pot or .mo file. When passed as array, the translation entries are merged from right to left.

$locale : string
$skipFallbackTranslation : bool = false
Tags
codeCoverageIgnore

fromPluginReceiver()

Create a temporary text domain from a given WP React Starter plugin receiver.

public static fromPluginReceiver(string $domain, string $fallbackDomain, PluginReceiver $receiver, AbstractSyncPlugin|string $compLanguageOrLocale[, string $overrideClass = null ]) : mixed
Parameters
$domain : string
$fallbackDomain : string
$receiver : PluginReceiver
$compLanguageOrLocale : AbstractSyncPlugin|string
$overrideClass : string = null

A class with a getPotLanguages method

getEntries()

Get all translation entries of the given MO file.

public getEntries() : mixed

gettext()

Gettext filter.

public gettext(string $translation, string $text, string $domain) : mixed
Parameters
$translation : string

Translated text.

$text : string

Text to translate.

$domain : string

Text domain. Unique identifier for retrieving translated strings.

gettext_with_context()

Gettext with context filter.

public gettext_with_context(string $translation, string $text, string $context, string $domain) : mixed
Parameters
$translation : string

Translated text.

$text : string

Text to translate.

$context : string

Text context.

$domain : string

Text domain. Unique identifier for retrieving translated strings.

isCurrentlyActive()

Checs if this temporary text domain is the latest registered one in stack?

public isCurrentlyActive() : mixed

fromLanguageFiles()

Create PO/MO instance from language file(s).

protected fromLanguageFiles(string|array<string|int, string> $languageFile) : mixed
Parameters
$languageFile : string|array<string|int, string>

Can be a .po, .pot or .mo file. When passed as array, the translation entries are merged from right to left.


        
On this page

Search results