Make WordPress Core


Ignore:
Timestamp:
01/19/2023 02:11:08 PM (2 years ago)
Author:
swissspidy
Message:

I18N: Allow installing new translations when changing the user locale on the profile page.

Up until now, new translations could only be installed via Settings -> General.
When editing the user profile, one could only select locales that were already installed.

This change allows also installing new translations if the editing user has the necessary capabilities.

Props barryceelen, johnbillion, ocean90, swissspidy.
Fixes #38664.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/user.php

    r54891 r55099  
    120120            $locale = 'en_US';
    121121        } elseif ( ! in_array( $locale, get_available_languages(), true ) ) {
    122             $locale = '';
     122            if ( current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) {
     123                if ( ! wp_download_language_pack( $locale ) ) {
     124                    $locale = '';
     125                }
     126            } else {
     127                $locale = '';
     128            }
    123129        }
    124130
Note: See TracChangeset for help on using the changeset viewer.