Documentation

None extends AbstractLanguagePlugin
in package

No known plugin installed, fallback to this implementation.

Table of Contents

Constants

TEMPORARY_TEXT_DOMAIN_PREFIX  = 'multilingual-temporary-text-domain'

Properties

$currentTranslationEntries  : mixed
Current translations hold as an instance.
$findI18nKeyOfTranslationCache  : mixed
$lockCurrentTranslations  : mixed
$domain  : string
Use this as text domain for translations. E. g. `post_title` is automatically passed while duplicating a post to another language.
$localesBeforeSwitch  : array<string|int, string>
List of locales before switching locale via `switchToLanguage`.
$moFile  : mixed
$overrideClass  : mixed
$sync  : Sync
The sync instance for this plugin.
$temporaryTextDomain  : TemporaryTextDomain
Temporary text domain, if given.

Methods

__construct()  : mixed
C'tor.
createTemporaryTextDomain()  : mixed
Create a temporary text domain.
determineImplementation()  : AbstractLanguagePlugin
Determine implementation class.
disableCopyAndSync()  : mixed
Disable sync mechanism of our language plugin as it is handled by `Sync.php`.
findI18nKeyOfTranslation()  : mixed
The same as `findI18nKeyOfTranslationRaw`, but with caching enabled as this could be called very often.
findI18nKeyOfTranslationRaw()  : mixed
Find an i18n key for `__()` from a given translated string.
getActiveCountriesFlags()  : mixed
Get the flags of all active languages.
getActiveLanguages()  : array<string|int, string>
Get all active languages.
getCountryFlag()  : string|false
Get a `src` compatible link to the country flag.
getCurrentLanguage()  : string
Get current language.
getCurrentLanguageFallback()  : mixed
Get current language or fallback to default language when the multilingual is in a state like "Show all languages" (option known in the admin toolbar).
getCurrentPostId()  : int
Get current id of passed post id and fallback to passed id, when no translation found.
getCurrentTermId()  : int
Get current id of passed term id and fallback to `0` when not translation found.
getDefaultLanguage()  : string
Get default language.
getLanguageSwitcher()  : array<string|int, array<string|int, mixed>>
Get a language switcher for the current page.
getLocalesBeforeSwitch()  : mixed
List of locales before switching locale via `switchToLanguage`.
getOriginalPostId()  : int
Get original id of passed post id.
getOriginalTermId()  : int
Get original id of passed term id.
getOverrideClassInstance()  : mixed
Get an instance of the `overrideClass`.
getPermalink()  : string
Get the URL of a given URL for another locale.
getPostTranslationIds()  : array<string|int, int>
Get all translations of a given post type.
getSkipHTMLForTag()  : string
Get the HTML attribute so the "dynamic" replacement gets disabled on frontend side. This can be useful for texts which are directly translated in PHP already and gets translated via JavaScript again.
getSync()  : mixed
Get `Sync` instance for this plugin. Can be `null` if not given.
getTaxonomyTranslationIds()  : array<string|int, int>
Get all translations of a given taxonomy.
getTemporaryTextDomainName()  : mixed
Get the current temporary text domain name which can be used for `__` when e.g. inside `switchToLanguage`.
getTranslatedName()  : string
Get translated name for a given locale.
getWordPressCompatibleLanguageCode()  : string
Get the WordPress compatible language code of a given locale.
isActive()  : mixed
Is a multilingual plugin active?
isCurrentlyInEditorPreview()  : bool
Check if the translate plugin is currently in edit mode (preview).
iterateAllLanguagesContext()  : mixed
Iterate all language contexts.
iterateOtherLanguagesContext()  : mixed
Iterate all other languages than current one and get their context.
lockCurrentTranslations()  : mixed
Do not allow to take another snapshot of current translations.
maybePersistTranslation()  : mixed
Maybe persist a translation in the database of available translations.
rest_prepare_post()  : mixed
Add a `multilingual` section to a given post type.
rest_prepare_taxonomy()  : mixed
Add a `multilingual` section to a given taxonomy.
setSync()  : mixed
Set `Sync` instance for this plugin. Can be `null` if not given.
snapshotCurrentTranslations()  : mixed
Snapshot the current translations.
switch()  : mixed
Switch to a given language code. Please do not use this function directly, use `switchToLanguage` instead!
switchToLanguage()  : mixed
Open given language and get their context. Context = switch to the language.
teardownTemporaryTextDomain()  : mixed
Teardown the known temporary text domain.
translateArray()  : array<string|int, mixed>
Translate a complete array to a given locale (recursively).
translateInput()  : mixed
Translate a given input from known translations (.po, .pot).
translateStrings()  : mixed
Translate strings to a given locale. Do not use this function directly, use `translateArray` instead!
unsetCurrentTranslations()  : mixed
Unset current translations.
translateStringFromMo()  : array<string|int, mixed>
Translate string from `.mo` file. Please consider to create a temporary text domain before!

Constants

TEMPORARY_TEXT_DOMAIN_PREFIX

public mixed TEMPORARY_TEXT_DOMAIN_PREFIX = 'multilingual-temporary-text-domain'

Properties

$currentTranslationEntries

Current translations hold as an instance.

protected mixed $currentTranslationEntries = null

$domain

Use this as text domain for translations. E. g. `post_title` is automatically passed while duplicating a post to another language.

private string $domain

$localesBeforeSwitch

List of locales before switching locale via `switchToLanguage`.

private array<string|int, string> $localesBeforeSwitch = []

Methods

__construct()

C'tor.

public __construct(string $domain[, string $moFile = null ][, mixed $overrideClass = null ]) : mixed
Parameters
$domain : string

Original text domain where post_title and so on are translated

$moFile : string = null

Needed for TemporaryTextDomain. E. g. /var/www/html/wp-content/plugins/real-cookie-banner/languages/real-cookie-banner-%s.mo

$overrideClass : mixed = null

A class with a getPotLanguages method

Tags
codeCoverageIgnore

createTemporaryTextDomain()

Create a temporary text domain.

public createTemporaryTextDomain(string $locale[, bool $force = false ]) : mixed
Parameters
$locale : string
$force : bool = false

determineImplementation()

Determine implementation class.

public static determineImplementation([string $domain = '' ][, string $moFile = null ][, mixed $overrideClass = null ]) : AbstractLanguagePlugin
Parameters
$domain : string = ''
$moFile : string = null

Needed for TemporaryTextDomain. E. g. /var/www/html/wp-content/plugins/real-cookie-banner/languages/real-cookie-banner-%s.mo

$overrideClass : mixed = null

A class with a override method (arguments: locale)

Return values
AbstractLanguagePlugin

disableCopyAndSync()

Disable sync mechanism of our language plugin as it is handled by `Sync.php`.

public disableCopyAndSync(mixed $sync) : mixed
Parameters
$sync : mixed

findI18nKeyOfTranslation()

The same as `findI18nKeyOfTranslationRaw`, but with caching enabled as this could be called very often.

public findI18nKeyOfTranslation(string $input, bool &$found, array<string|int, string> &$contexts) : mixed
Parameters
$input : string
$found : bool
$contexts : array<string|int, string>

findI18nKeyOfTranslationRaw()

Find an i18n key for `__()` from a given translated string.

public findI18nKeyOfTranslationRaw(string $input, bool &$found, array<string|int, string> &$contexts) : mixed
Parameters
$input : string
$found : bool

Sets to true when a translation got found

$contexts : array<string|int, string>

getActiveCountriesFlags()

Get the flags of all active languages.

public getActiveCountriesFlags() : mixed

getActiveLanguages()

Get all active languages.

public getActiveLanguages() : array<string|int, string>
Return values
array<string|int, string>

getCountryFlag()

Get a `src` compatible link to the country flag.

public getCountryFlag(mixed $locale) : string|false
Parameters
$locale : mixed
Return values
string|false

getCurrentLanguage()

Get current language.

public getCurrentLanguage() : string
Return values
string

getCurrentLanguageFallback()

Get current language or fallback to default language when the multilingual is in a state like "Show all languages" (option known in the admin toolbar).

public getCurrentLanguageFallback() : mixed

getCurrentPostId()

Get current id of passed post id and fallback to passed id, when no translation found.

public getCurrentPostId(mixed $id, mixed $post_type[, mixed $locale = null ]) : int
Parameters
$id : mixed
$post_type : mixed
$locale : mixed = null

Get item of this language

Return values
int

getCurrentTermId()

Get current id of passed term id and fallback to `0` when not translation found.

public getCurrentTermId(mixed $id, mixed $taxonomy[, mixed $locale = null ]) : int
Parameters
$id : mixed
$taxonomy : mixed
$locale : mixed = null

Get item of this language

Return values
int

getDefaultLanguage()

Get default language.

public getDefaultLanguage() : string
Return values
string

getLanguageSwitcher()

Get a language switcher for the current page.

public getLanguageSwitcher() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>>

getLocalesBeforeSwitch()

List of locales before switching locale via `switchToLanguage`.

public getLocalesBeforeSwitch() : mixed

getOriginalPostId()

Get original id of passed post id.

public getOriginalPostId(mixed $id, mixed $post_type) : int
Parameters
$id : mixed
$post_type : mixed
Return values
int

getOriginalTermId()

Get original id of passed term id.

public getOriginalTermId(mixed $id, mixed $taxonomy) : int
Parameters
$id : mixed
$taxonomy : mixed
Return values
int

getOverrideClassInstance()

Get an instance of the `overrideClass`.

public getOverrideClassInstance() : mixed

Get the URL of a given URL for another locale.

public getPermalink(mixed $url, mixed $locale) : string
Parameters
$url : mixed
$locale : mixed
Return values
string

getPostTranslationIds()

Get all translations of a given post type.

public getPostTranslationIds(mixed $id, mixed $post_type) : array<string|int, int>
Parameters
$id : mixed
$post_type : mixed
Return values
array<string|int, int>

getSkipHTMLForTag()

Get the HTML attribute so the "dynamic" replacement gets disabled on frontend side. This can be useful for texts which are directly translated in PHP already and gets translated via JavaScript again.

public getSkipHTMLForTag([mixed $force = false ]) : string
Parameters
$force : mixed = false

Pass true to get the attribute and do not respect isCurrentlyInEditorPreview

Return values
string

getSync()

Get `Sync` instance for this plugin. Can be `null` if not given.

public getSync() : mixed

getTaxonomyTranslationIds()

Get all translations of a given taxonomy.

public getTaxonomyTranslationIds(mixed $id, mixed $taxonomy) : array<string|int, int>
Parameters
$id : mixed
$taxonomy : mixed
Return values
array<string|int, int>

getTemporaryTextDomainName()

Get the current temporary text domain name which can be used for `__` when e.g. inside `switchToLanguage`.

public getTemporaryTextDomainName() : mixed

getTranslatedName()

Get translated name for a given locale.

public getTranslatedName(mixed $locale) : string
Parameters
$locale : mixed
Return values
string

getWordPressCompatibleLanguageCode()

Get the WordPress compatible language code of a given locale.

public getWordPressCompatibleLanguageCode(mixed $locale) : string
Parameters
$locale : mixed
Return values
string

isCurrentlyInEditorPreview()

Check if the translate plugin is currently in edit mode (preview).

public isCurrentlyInEditorPreview() : bool
Return values
bool

iterateAllLanguagesContext()

Iterate all language contexts.

public iterateAllLanguagesContext(callable $callback[, array<string|int, string> $skip = [] ]) : mixed
Parameters
$callback : callable

Arguments: $locale, $currentLanguage

$skip : array<string|int, string> = []

Skip locales

iterateOtherLanguagesContext()

Iterate all other languages than current one and get their context.

public iterateOtherLanguagesContext(callable $callback) : mixed

Context = switch to the language.

Attention: If you are using switchToLanguage in a REST API call, please consider to pass the _wp_http_referer parameter. E.g. TranslatePress checks if the referer is an admin page and behaves differently.

Parameters
$callback : callable

Arguments: $locale, $currentLanguage

lockCurrentTranslations()

Do not allow to take another snapshot of current translations.

public lockCurrentTranslations([bool $state = false ]) : mixed
Parameters
$state : bool = false

maybePersistTranslation()

Maybe persist a translation in the database of available translations.

public maybePersistTranslation(mixed $sourceContent, mixed $content, mixed $source, mixed $locale) : mixed
Parameters
$sourceContent : mixed
$content : mixed
$source : mixed
$locale : mixed

snapshotCurrentTranslations()

Snapshot the current translations.

public snapshotCurrentTranslations([bool $force = false ]) : mixed
Parameters
$force : bool = false

switch()

Switch to a given language code. Please do not use this function directly, use `switchToLanguage` instead!

public switch(mixed $locale) : mixed
Parameters
$locale : mixed

switchToLanguage()

Open given language and get their context. Context = switch to the language.

public switchToLanguage(string $locale, callable $callback) : mixed

Attention: If you are using switchToLanguage in a REST API call, please consider to pass the _wp_http_referer parameter. E.g. TranslatePress checks if the referer is an admin page and behaves differently.

Parameters
$locale : string
$callback : callable

Arguments: $locale, $currentLanguage

teardownTemporaryTextDomain()

Teardown the known temporary text domain.

public teardownTemporaryTextDomain() : mixed

translateArray()

Translate a complete array to a given locale (recursively).

public translateArray(array<string|int, mixed> $content[, array<string|int, string> $skipKeys = [] ][, string $locale = null ][, array<string|int, string> $context = null ]) : array<string|int, mixed>
Parameters
$content : array<string|int, mixed>
$skipKeys : array<string|int, string> = []
$locale : string = null
$context : array<string|int, string> = null
Return values
array<string|int, mixed>

translateInput()

Translate a given input from known translations (.po, .pot).

public translateInput(string $input[, array<string|int, string> $contexts = null ]) : mixed
Parameters
$input : string
$contexts : array<string|int, string> = null

translateStrings()

Translate strings to a given locale. Do not use this function directly, use `translateArray` instead!

public translateStrings(mixed &$content, mixed $locale[, mixed $context = null ]) : mixed
Parameters
$content : mixed

This parameter needs to be passed as reference map, see also translateArray. The implementation needs to update the references correctly

$locale : mixed
$context : mixed = null

unsetCurrentTranslations()

Unset current translations.

public unsetCurrentTranslations() : mixed

translateStringFromMo()

Translate string from `.mo` file. Please consider to create a temporary text domain before!

protected translateStringFromMo(string $content, string $targetLocale[, array<string|int, string> $context = null ]) : array<string|int, mixed>
Parameters
$content : string
$targetLocale : string
$context : array<string|int, string> = null
Return values
array<string|int, mixed>

[$found: boolean, $content: string]


        
On this page

Search results