From fc0580cc6397cf76f1905ad8424d77d0b09ad37f Mon Sep 17 00:00:00 2001 From: ozh Date: Mon, 28 Dec 2015 11:58:48 +0100 Subject: [PATCH] Load custom textdomain only if locale set Fixes #2009 --- includes/functions-l10n.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/functions-l10n.php b/includes/functions-l10n.php index 1c536b0..3b09658 100644 --- a/includes/functions-l10n.php +++ b/includes/functions-l10n.php @@ -1031,7 +1031,7 @@ function is_rtl() { } /** - * Loads a custom translation file (for a plugin, a theme, a public interface...) + * Loads a custom translation file (for a plugin, a theme, a public interface...) if locale is defined * * The .mo file should be named based on the domain with a dash, and then the locale exactly, * eg 'myplugin-pt_BR.mo' @@ -1040,13 +1040,14 @@ function is_rtl() { * * @param string $domain Unique identifier (the "domain") for retrieving translated strings * @param string $path Full path to directory containing MO files. - * @return bool True on success, false on failure + * @return mixed Returns nothing if locale undefined, otherwise return bool: true on success, false on failure */ function yourls_load_custom_textdomain( $domain, $path ) { $locale = yourls_apply_filter( 'load_custom_textdomain', yourls_get_locale(), $domain ); - $mofile = rtrim( $path, '/' ) . '/'. $domain . '-' . $locale . '.mo'; - - return yourls_load_textdomain( $domain, $mofile ); + if( !empty( $locale ) ) { + $mofile = rtrim( $path, '/' ) . '/'. $domain . '-' . $locale . '.mo'; + return yourls_load_textdomain( $domain, $mofile ); + } } /** -- 2.45.0