<?php

/**
 * Define the internationalization functionality.
 *
 * @link       https://example.com
 * @since      0.1.0
 *
 * @package    PinnerPress
 */

/**
 * Define the internationalization functionality.
 *
 * Loads and defines the internationalization files for this plugin
 * so that it is ready for translation.
 *
 * @since      0.1.0
 * @package    PinnerPress
 */
if (!class_exists('PinnerPress_i18n')) {
class PinnerPress_i18n {

    /**
     * Set up translations without using load_plugin_textdomain().
     *
     * Since WordPress 4.6, translations hosted on WordPress.org are loaded
     * automatically from wp-content/languages/plugins. For bundled translations
     * (non.org installs), attempt a safe fallback via load_textdomain().
     *
     * @since 0.1.0
     */
    public function load_plugin_textdomain() {
        // Core auto-loads language packs; no action needed in that case.
        // Provide a fallback for bundled MO files in this plugin's /languages directory.
        if ( function_exists('determine_locale') ) {
            $locale = determine_locale();
        } else {
            $locale = get_locale();
        }

        // Use consistent text domain for both free and premium versions
        $text_domain = 'pinnerpress';

        // Try to load a bundled MO file if present.
        $mofile = trailingslashit( plugin_dir_path( dirname( __FILE__ ) ) ) . 'languages/' . $text_domain . '-' . $locale . '.mo';
        if ( file_exists( $mofile ) ) {
            load_textdomain( $text_domain, $mofile );
        }
    }

}
}
