get_locale is empty when called inside functions.php
-
Hello everyone!
I’m trying to get the user language inside the functions.php file in order to load some translations. The problem is that get_locale seems to be empty inside functions.php
This is what I have in my functions file:$locale = get_locale(); $lang = substr($locale, 0, 2); wp_enqueue_script('validate_languages', get_stylesheet_directory_uri() . '/js/localization/messages_'.$lang.'.js', array( 'jquery' ));
This is the error I see in the console:
GET https://www.mydomain.com/wp-content/themes/twentyfifteen_child/js/localization/messages_.js?ver=4.4.1
I have also tried to use $locale alone (just in case native substr() funtion was not working), but I get the same error.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘get_locale is empty when called inside functions.php’ is closed to new replies.