Skip to content

Commit

Permalink
Merge pull request #150 from brainstormforce/translation-code
Browse files Browse the repository at this point in the history
Translation code merged
  • Loading branch information
sushmak02 authored Jan 30, 2025
2 parents b38d5d5 + 12c210d commit 248a259
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions classes/class-uabb-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,23 +187,48 @@ public function init() {
* @return bool
*/
public function load_plugin_textdomain() {
// Default languages directory for "ultimate-addons-for-beaver-builder-lite".
$lang_dir = BB_ULTIMATE_ADDON_DIR . 'languages/';

/**
* Filters the languages directory path to use for AffiliateWP.
*
* @param string $lang_dir The languages directory path.
*/
$lang_dir = apply_filters( 'uabb_languages_directory', $lang_dir );

// Traditional WordPress plugin locale filter.
$locale = apply_filters( 'plugin_locale', get_locale(), 'uabb' );
global $wp_version;

$get_locale = get_locale();

if ( $wp_version >= 4.7 ) {
$get_locale = get_user_locale();
}

/**
* Language Locale for Ultimate BB
*
* @var $get_locale The locale to use. Uses get_user_locale()` in WordPress 4.7 or greater,
* otherwise uses `get_locale()`.
*/
$locale = apply_filters( 'plugin_locale', $get_locale, 'uabb' );
$mofile = sprintf( '%1$s-%2$s.mo', 'uabb', $locale );

// Setup paths to current locale file.
$mofile_global = trailingslashit( WP_LANG_DIR ) . 'plugins/bb-ultimate-addon/' . $locale . '.mo';
$mofile_local = trailingslashit( BB_ULTIMATE_ADDON_DIR ) . 'languages/' . $locale . '.mo';
$mofile_local = $lang_dir . $mofile;
$mofile_global = WP_LANG_DIR . '/ultimate-addons-for-beaver-builder-lite/' . $mofile;

if ( file_exists( $mofile_global ) ) {
// Look in global /wp-content/languages/plugins/bb-ultimate-addon/ folder.
return load_textdomain( 'uabb', $mofile_global );
// Look in global /wp-content/languages/ultimate-addons-for-beaver-builder-lite/ folder.
load_textdomain( 'uabb', $mofile_global );
} elseif ( file_exists( $mofile_local ) ) {
// Look in local /wp-content/plugins/bb-ultimate-addon/languages/ folder.
return load_textdomain( 'uabb', $mofile_local );
// Look in local /wp-content/plugins/ultimate-addons-for-beaver-builder-lite/languages/ folder.
load_textdomain( 'uabb', $mofile_local );
} else {
// Load the default language files.
load_plugin_textdomain( 'uabb', false, $lang_dir );
}

// Nothing found.
return false;
}

/**
Expand Down

0 comments on commit 248a259

Please sign in to comment.