<?php

if (!function_exists('determine_locale')) {
    function determine_locale()
    {
        $determined_locale = apply_filters('pre_determine_locale', null);
        if (!empty($determined_locale) && is_string($determined_locale)) {
            return $determined_locale;
        }
        $determined_locale = get_locale();
        if (function_exists('get_user_locale') && is_admin()) {
            $determined_locale = get_user_locale();
        }
        if (function_exists('get_user_locale') && isset($_GET['_locale']) && 'user' === $_GET['_locale']) {
            $determined_locale = get_user_locale();
        }
        if (!empty($_GET['wp_lang']) && !empty($GLOBALS['pagenow']) && 'wp-login.php' === $GLOBALS['pagenow']) {
            $determined_locale = sanitize_text_field($_GET['wp_lang']);
        }
        return apply_filters('determine_locale', $determined_locale);
    }
}
function acf_get_locale()
{
    $locale = determine_locale();
    $langs = array('az_TR' => 'az', 'zh_HK' => 'zh_TW', 'nl_BE' => 'nl_NL', 'fr_BE' => 'fr_FR', 'nn_NO' => 'nb_NO', 'fa_AF' => 'fa_IR', 'ru_UA' => 'ru_RU');
    if (isset($langs[$locale])) {
        $locale = $langs[$locale];
    }
    return apply_filters('acf/get_locale', $locale);
}
function acf_load_textdomain($domain = 'acf')
{
    $locale = apply_filters('plugin_locale', acf_get_locale(), $domain);
    $mofile = $domain . '-' . $locale . '.mo';
    if (load_textdomain($domain, WP_LANG_DIR . '/plugins/' . $mofile)) {
        return true;
    }
    return load_textdomain($domain, acf_get_path('lang/' . $mofile));
}
function _acf_apply_language_cache_key($key)
{
    $current_language = acf_get_setting('current_language');
    if ($current_language) {
        $key = "{$key}:{$current_language}";
    }
    return $key;
}
add_filter('acf/get_cache_key', '_acf_apply_language_cache_key');