Documentation

Footnotes_Language

Loads text domain of current or default language for localization.

Tags
since
1.5.0

Table of Contents

load_text_domain()  : mixed
Loads the text domain for current WordPress language if exists.
register_hooks()  : mixed
Register WordPress Hook.
load()  : bool
Loads a specific text domain.

Methods

load_text_domain()

Loads the text domain for current WordPress language if exists.

public static load_text_domain() : mixed

Otherwise fallback "en_GB" will be loaded.

Tags
since
1.5.0
  • Bugfix: Correct function call apply_filters() with all required arguments after PHP 7.1 promoted warning to error, thanks to @matkus2 bug report and code contribution.
since
2.0.0
contributor

@matkus2

link

Add 3rd (empty) argument in apply_filters() to prevent PHP from throwing an error. “Fatal error: Uncaught ArgumentCountError: Too few arguments to function apply_filters()”

Yet get_locale() is defined w/o parameters in wp-includes/l10n.php:30, and apply_filters() is defined as apply_filters( $tag, $value ) in wp-includes/plugin.php:181.

link

But apply_filters() is defined with a 3rd parameter (and w/o the first one) in wp-includes/class-wp-hook.php:264, as public function apply_filters( $value, $args ).

Taking it all together, probably the full function definition would be public function apply_filters( $tag, $value, $args ). In the case of get_locale(), $args is empty.

The bug was lurking in WP. PHP 7.1 promoted the warning to an error.

link
https://www.php.net/manual/en/migration71.incompatible.php
link
https://www.php.net/manual/en/migration71.incompatible.php#migration71.incompatible.too-few-arguments-exception
Return values
mixed

register_hooks()

Register WordPress Hook.

public static register_hooks() : mixed
Tags
since
1.5.0
Return values
mixed

load()

Loads a specific text domain.

private static load(string $p_str_language_code) : bool
Parameters
$p_str_language_code : string

Language Code to load a specific text domain.

Tags
since
1.5.1
since
2.1.6
reporter

@nikelaos

link

That is done by using load_plugin_textdomain(). “The .mo file should be named based on the text domain with a dash, and then the locale exactly.”

see

wp-includes/l10n.php:857

Return values
bool
  • Bugfix: Localization: conform to WordPress plugin language file name scheme, thanks to @nikelaos bug report.

Search results