Plugin_Loader::load_textdomain()

Load Plugin Text Domain.


Description

This will load the translation textdomain depending on the file priorities.

  1. Global Languages /wp-content/languages/bsf-utm-analytics/ folder
  2. Local directory /wp-content/plugins/bsf-utm-analytics/languages/ folder

Return

(void)


Source

File: inc/lib/utm-analytics/plugin-loader.php

	public function load_textdomain() {
		// Default languages directory.
		$lang_dir = BSF_UTM_ANALYTICS_DIR . 'languages/';

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

		// Traditional WordPress plugin locale filter.
		global $wp_version;

		$get_locale = get_locale();

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

		/**
		 * Language Locale for plugin
		 *
		 * @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, 'bsf-utm-analytics' );
		$mofile = sprintf( '%1$s-%2$s.mo', 'bsf-utm-analytics', $locale );

		// Setup paths to current locale file.
		$mofile_global = WP_LANG_DIR . '/plugins/' . $mofile;
		$mofile_local  = $lang_dir . $mofile;

		if ( file_exists( $mofile_global ) ) {
			// Look in global /wp-content/languages/bsf-utm-analytics/ folder.
			load_textdomain( 'bsf-utm-analytics', $mofile_global );
		} elseif ( file_exists( $mofile_local ) ) {
			// Look in local /wp-content/plugins/bsf-utm-analytics/languages/ folder.
			load_textdomain( 'bsf-utm-analytics', $mofile_local );
		} else {
			// Load the default language files.
			load_plugin_textdomain( 'bsf-utm-analytics', false, $lang_dir );
		}
	}

Changelog

Changelog
Version Description
0.0.1 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.