Localization of WP theme

Wrap the elements of $search and $replace arrays into __() function to get the translated strings: function search_replace_search() { $search_term = esc_attr( apply_filters( ‘the_search_query’, get_search_query( false ) ) ); // Get search term $search = array( __(‘word1’), __(‘word2’) ); $replace = array( __(‘something 1’), __(‘something 2’) ); $replacePairs = array_combine($search, $replace); echo strtr($search_term, $replacePairs); } … Read more

Can I set WordPress to display languages based on system language without a plugin?

PHP can read the ‘HTTP_ACCEPT_LANGUAGE’ header from the browser request, but this might not be easy to parse if there is more than one accepted language set. For the simplest case, when one language is set as accepted, you need to read only first 2 characters from this header: $language = substr($_SERVER[‘HTTP_ACCEPT_LANGUAGE’], 0, 2); But, … Read more