Documentation

MCI_Footnotes_Language

Loads text domain of current or default language for localization.

Tags
author

Stefan Herndler

since
1.5.0

Table of Contents

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

Methods

loadTextDomain()

Loads the text domain for current WordPress language if exists.

public static loadTextDomain() : mixed

Otherwise fallback "en_GB" will be loaded.

Tags
author

Stefan Herndler

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
date

2020-10-26T1609+0100

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

registerHooks()

Register WordPress Hook.

public static registerHooks() : mixed
Tags
author

Stefan Herndler

since
1.5.0
Return values
mixed

load()

Loads a specific text domain.

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

Language Code to load a specific text domain.

Tags
author

Stefan Herndler

since
1.5.1
since
2.1.6
date

2020-12-08T1931+0100

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