Advertisement
retesere20

wp-install-locale-language

Nov 28th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. public function install_locale()
  2. {
  3. is_admin() or add_filter( 'locale', function($locale) {
  4. $locale = "ka_GE";
  5. return $locale;
  6. });
  7.  
  8. //check if it's not install, then install
  9. add_action('wp', 'my_locale_implemention');
  10. function my_locale_implemention()
  11. {
  12. $my_locale = get_locale(); //get_user_locale
  13. if ( !empty($my_locale) && !in_array( $my_locale, get_available_languages() ) ) {
  14. require_once( ABSPATH . 'wp-admin/includes/file.php' );
  15. require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
  16. $language = wp_download_language_pack( $my_locale );
  17. if ( $language ) {
  18. if(empty($_POST)) header("location: ".$_SERVER['REQUEST_URI']); exit; //reload page
  19. }
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement