Even if GlotPress generated language pack and push to the sites, this plugin cannot read them

`$current_locale = get_locale();
if (!empty($current_locale)) {
    $mo_file = dirname(__FILE__) . '/languages/wpicp-license-' . $current_locale . ".mo";
    if (@file_exists($mo_file) && is_readable($mo_file)) {
        load_textdomain('wpicp-license', $mo_file);
    }
}`

The above code made this plugin cannot read the language pack file generated from GlotPress system, please check them.

After I commented on the above code, this plugin can read the MO file generated from GlotPress. The MO file generated from GlotPress always stores the default system path `/wp-content/languages/plugins`.

Don't only make your plugin read the MO file under `languages` folder on the plugin installation path.
This commit is contained in:
Alex Lion 2023-03-04 18:18:08 -08:00 committed by GitHub
parent b9589bf810
commit 820941128e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,12 +38,9 @@ function wpicp_license_menu() {
}
/** Load translation */
$current_locale = get_locale();
if (!empty($current_locale)) {
$mo_file = dirname(__FILE__) . '/languages/wpicp-license-' . $current_locale . ".mo";
if (@file_exists($mo_file) && is_readable($mo_file)) {
load_textdomain('wpicp-license', $mo_file);
}
add_action( 'init', 'wpicp_load_textdomain' );
function wpicp_load_textdomain() {
load_plugin_textdomain( 'wpicp-license', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
// Add settings page and field