Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

Commit

Permalink
Load custom textdomain only if locale set
Browse files Browse the repository at this point in the history
  • Loading branch information
ozh committed Dec 28, 2015
1 parent 602cc54 commit fc0580c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions includes/functions-l10n.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 );
}
}

/**
Expand Down

0 comments on commit fc0580c

Please sign in to comment.