2014-09-14 20:32:59 +00:00
< ? php
/**
*
* @ filesource
* @ author Stefan Herndler
* @ since 1.5 . 0 14.09 . 14 17 : 47
2020-12-09 15:12:37 +00:00
*
2021-01-14 22:56:43 +00:00
* Edited :
2020-12-12 21:07:24 +00:00
*
2021-01-14 22:56:43 +00:00
* @ since 2.0 . 0 PHP - related bug fix thanks to @ matkus2 code contribution 2020 - 10 - 26 T1609 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / error - missing - parameter - if - using - php - 7 - 1 - or - later /
* @ link https :// www . php . net / manual / en / migration71 . incompatible . php
2021-01-14 22:56:43 +00:00
*
* @ since 2.1 . 6 conform to WordPress plugin language file name scheme , thanks to @ nikelaos bug report 2020 - 12 - 08 T1931 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / more - feature - ideas /
2021-01-14 22:56:43 +00:00
*
* Last modified : 2021 - 01 - 10 T1755 + 0100
2014-09-14 20:32:59 +00:00
*/
/**
*
* @ author Stefan Herndler
* @ since 1.5 . 0
*/
class MCI_Footnotes_Language {
2020-12-09 15:12:37 +00:00
/**
* Register WordPress Hook .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
*/
public static function registerHooks () {
add_action ( 'plugins_loaded' , array ( " MCI_Footnotes_Language " , " loadTextDomain " ));
}
2014-09-14 20:32:59 +00:00
2020-12-09 15:12:37 +00:00
/**
* Loads the text domain for current WordPress language if exists . Otherwise fallback " en_GB " will be loaded .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
*
2021-01-14 22:56:43 +00:00
* @ since 2.0 . 0 PHP 7.1 related bug fix thanks to @ matkus2 code contribution
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / error - missing - parameter - if - using - php - 7 - 1 - or - later /
* @ link https :// www . php . net / manual / en / migration71 . incompatible . php
2020-12-09 15:12:37 +00:00
*/
public static function loadTextDomain () {
// language file with localization exists
if ( self :: load ( apply_filters ( 'plugin_locale' , get_locale (), '' ))) {
// added 3rd (empty) parameter to prevent "Fatal error: Uncaught ArgumentCountError: Too few arguments […]"
// 2020-10-26T1609+0100
return ;
}
2020-12-25 15:14:43 +00:00
// fall back to British English:
2020-12-09 15:12:37 +00:00
self :: load ( " en_GB " );
}
2014-09-27 07:56:40 +00:00
2020-12-09 15:12:37 +00:00
/**
* Loads a specific text domain .
*
* @ author Stefan Herndler
* @ since 1.5 . 1
* @ param string $p_str_LanguageCode Language Code to load a specific text domain .
* @ return bool
*
2021-01-14 22:56:43 +00:00
* Edited :
* @ since 2.1 . 6 conform to WordPress plugin language file name scheme , thanks to @ nikelaos bug report
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / more - feature - ideas /
2021-01-14 22:56:43 +00:00
* That is done by using load_plugin_textdomain ()
2020-12-09 15:12:37 +00:00
* @ see wp - includes / l10n . php : 857
2020-12-10 12:29:50 +00:00
* “The . mo file should be named based on the text domain with a dash , and then the locale exactly . ”
2020-12-09 15:12:37 +00:00
*/
private static function load ( $p_str_LanguageCode ) {
return load_plugin_textdomain (
MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ,
2021-01-14 22:56:43 +00:00
// This argument only fills the gap left by a deprecated argument (since WP2.7):
false ,
// The plugin basedir is provided; trailing slash would be clipped:
MCI_Footnotes_Config :: C_STR_PLUGIN_NAME . '/languages'
2020-12-09 15:12:37 +00:00
);
}
2020-10-27 11:56:49 +00:00
}