paid-memberships-pro icon indicating copy to clipboard operation
paid-memberships-pro copied to clipboard

Plugin not using correct .mo file when setting the admin language in Users > Profile > Language

Open mrleemon opened this issue 2 years ago • 4 comments

Describe the bug I've translated the plugin into Catalan via GlotPress: https://translate.wordpress.org/projects/wp-plugins/paid-memberships-pro/dev/ca/default/

But when setting the admin language to Catalan in Users > Profile > Language the plugin is not picking the downloaded .mo file but a Spanish one if the site language setting in Settings > General is set to Spanish.

To Reproduce Steps to reproduce the behavior:

  1. Set the site language (Settings > General) into Catalan to download its .mo file from GlotPress
  2. The admin pages are picking the Catalan translation from the downloaded .mo file
  3. Set the site language (Settings > General) back into Spanish
  4. Go to Users > Profile and set the language into Catalan
  5. The admin pages of the plugin appear in Spanish

Expected behavior The admin pages of the plugin should appear in Catalan

Isolating the problem (mark completed items with an [x]):

  • [x] I have deactivated other plugins and confirmed this bug occurs when only Paid Memberships Pro plugin is active.
  • [x] This bug happens with a default WordPress theme active, or Memberlite.
  • [x] I can reproduce this bug consistently using the steps above.

WordPress Environment

``` ` ### wp-core ###

version: 5.9.1 site_language: es_ES user_language: ca timezone: Europe/Madrid permalink: /%postname%/ https_status: false multisite: false user_registration: 0 blog_public: 1 default_comment_status: open environment_type: local user_count: 1 dotorg_communication: true

wp-paths-sizes

wordpress_path: C:\Users\user\Local Sites\protea-members\app\public wordpress_size: 53.39 MB (55981304 bytes) uploads_path: C:\Users\user\Local Sites\protea-members\app\public/wp-content/uploads uploads_size: 7.36 MB (7716141 bytes) themes_path: C:\Users\user\Local Sites\protea-members\app\public/wp-content/themes themes_size: 11.29 MB (11837159 bytes) plugins_path: C:\Users\user\Local Sites\protea-members\app\public/wp-content/plugins plugins_size: 18.62 MB (19522069 bytes) database_size: 2.77 MB (2906112 bytes) total_size: 93.42 MB (97962785 bytes)

wp-active-theme

name: Site name version: 0.1 author: xxxx author_website: http://domain.com/ parent_theme: GeneratePress (generatepress) theme_features: core-block-patterns, widgets-block-editor, menus, automatic-feed-links, post-thumbnails, post-formats, woocommerce, title-tag, html5, customize-selective-refresh-widgets, align-wide, responsive-embeds, editor-color-palette, custom-logo, editor-styles, editor-style, widgets theme_path: C:\Users\user\Local Sites\protea-members\app\public/wp-content/themes/kaktos auto_update: Desactivat

wp-parent-theme

name: GeneratePress (generatepress) version: 3.1.3 author: Tom Usborne author_website: https://tomusborne.com theme_path: C:\Users\user\Local Sites\protea-members\app\public/wp-content/themes/generatepress auto_update: Desactivat

wp-themes-inactive (3)

Twenty Twenty: version: 1.9, author: L'equip del WordPress, S'han desactivat les actualitzacions automàtiques Twenty Twenty-One: version: 1.5, author: the WordPress team, S'han desactivat les actualitzacions automàtiques Twenty Twenty-Two: version: 1.1, author: the WordPress team, S'han desactivat les actualitzacions automàtiques

wp-plugins-active (4)

Classic Editor: version: 1.6.2, author: WordPress Contributors, S'han activat les actualitzacions automàtiques Contact Form 7: version: 5.5.6, author: Takayuki Miyoshi, S'han activat les actualitzacions automàtiques Paid Memberships Pro: version: 2.7.5, author: Paid Memberships Pro, S'han activat les actualitzacions automàtiques Paid Memberships Pro - Register Helper Add On: version: 1.7, author: Paid Memberships Pro, S'han activat les actualitzacions automàtiques

wp-media

image_editor: WP_Image_Editor_Imagick imagick_module_version: 1799 imagemagick_version: ImageMagick 7.0.7-11 Q16 x64 2017-11-23 http://www.imagemagick.org imagick_version: 3.4.4 file_uploads: File uploads is turned off post_max_size: 1000M upload_max_filesize: 300M max_effective_size: 300 MB max_file_uploads: 20 imagick_limits: imagick::RESOURCETYPE_AREA: 4 GB imagick::RESOURCETYPE_DISK: 1.844674407371E+19 imagick::RESOURCETYPE_FILE: 1536 imagick::RESOURCETYPE_MAP: 4 GB imagick::RESOURCETYPE_MEMORY: 2 GB imagick::RESOURCETYPE_THREAD: 4 imagemagick_file_formats: 3FR, 3G2, 3GP, AAI, AI, ART, ARW, AVI, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CLIPBOARD, CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DDS, DFONT, DJVU, DNG, DOT, DPS, DPX, DXT1, DXT5, EMF, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FILE, FITS, FLIF, FPX, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GROUP4, GV, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, PPM, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCREENSHOT, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBP, WMF, WMV, WPG, X3F, XBM, XC, XCF, XPM, XPS, XV, YCbCr, YCbCrA, YUV gd_version: bundled (2.1.0 compatible) gd_formats: GIF, JPEG, PNG, WebP, BMP, XPM ghostscript_version: not available

wp-server

server_architecture: Windows NT 10.0 AMD64 httpd_software: nginx/1.16.0 php_version: 7.4.1 64bit php_sapi: cgi-fcgi max_input_variables: 4000 time_limit: 1200 memory_limit: 256M max_input_time: 600 upload_max_filesize: 300M php_post_max_size: 1000M curl_version: 7.67.0 OpenSSL/1.1.1d suhosin: false imagick_availability: true pretty_permalinks: true htaccess_extra_rules: false

wp-database

extension: mysqli server_version: 8.0.16 client_version: mysqlnd 7.4.1 max_allowed_packet: 16777216 max_connections: 151

wp-constants

WP_HOME: undefined WP_SITEURL: undefined WP_CONTENT_DIR: C:\Users\user\Local Sites\protea-members\app\public/wp-content WP_PLUGIN_DIR: C:\Users\user\Local Sites\protea-members\app\public/wp-content/plugins WP_MEMORY_LIMIT: 40M WP_MAX_MEMORY_LIMIT: 256M WP_DEBUG: false WP_DEBUG_DISPLAY: true WP_DEBUG_LOG: false SCRIPT_DEBUG: false WP_CACHE: false CONCATENATE_SCRIPTS: undefined COMPRESS_SCRIPTS: undefined COMPRESS_CSS: undefined WP_ENVIRONMENT_TYPE: local DB_CHARSET: utf8 DB_COLLATE: undefined

wp-filesystem

wordpress: writable wp-content: writable uploads: writable plugins: writable themes: writable

pmpro

pmpro-cron-jobs: pmpro_cron_expire_memberships (2022-03-01 23:08:25) | pmpro_cron_admin_activity_email (2022-03-02 10:30:00) | pmpro_cron_expiration_warnings (2022-03-02 13:08:26) | pmpro_cron_credit_card_expiring_warnings (2022-03-27 01:08:25) pmpro-gateway: Només test pmpro-gateway-env: Sandbox/Proves pmpro-orders: 0 comandes pmpro-discount-codes: 1 codi de descompte pmpro-membership-levels: { "1": { "id": "1", "name": "Asociado", "description": "", "confirmation": "", "initial_payment": 25, "billing_amount": 10, "cycle_number": "1", "cycle_period": "Year", "billing_limit": "0", "trial_amount": 0, "trial_limit": "0", "allow_signups": "1", "expiration_number": "0", "expiration_period": "" } } pmpro-custom-templates: No template overrides pmpro-getfile-usage: PMPRO_GETFILE_ENABLED no està establert pmpro-htaccess-cache-usage: Inactiu pmpro-pages: account: http://protea-members.local/cuenta-de-membresia/ billing: http://protea-members.local/cuenta-de-membresia/facturacion-de-membresia/ cancel: http://protea-members.local/cuenta-de-membresia/cancelacion-de-membresia/ checkout: http://protea-members.local/cuenta-de-membresia/pago-de-membresia/ confirmation: http://protea-members.local/cuenta-de-membresia/confirmacion-de-membresia/ invoice: http://protea-members.local/cuenta-de-membresia/factura-de-membresia/ levels: http://protea-members.local/cuenta-de-membresia/niveles-de-membresia/ login: http://protea-members.local/login-3/ member_profile_edit: http://protea-members.local/cuenta-de-membresia/tu-perfil/ `

</details>

mrleemon avatar Mar 01 '22 22:03 mrleemon

Just a question.

Why the plugin is looking for global .mo files in WP_LANG_DIR . '/pmpro/' or WP_LANG_DIR . '/paid-memberships-pro/'? WordPress downloads ALL plugins .mo files in WP_LANG_DIR . '/plugins/' with no distinct subfolders for each plugin.

In localization.php:

//paths to local (plugin) and global (WP) language files
$mofile_local  = dirname(__FILE__)."/../languages/" . $mofile;
$mofile_global = WP_LANG_DIR . '/pmpro/' . $mofile;
$mofile_global2 = WP_LANG_DIR . '/paid-memberships-pro/' . $mofile;

mrleemon avatar Mar 02 '22 08:03 mrleemon

You should review the function that picks the plugin's language .mo file, as in some instances it picks the shipped .mo file instead of giving precedence to the downloaded GlotPress one. Anyway, are the shipped .mo files really necessary? Shouldn't the plugin always use the GlotPress one?

mrleemon avatar Apr 11 '22 12:04 mrleemon

In case anyone is interested I fixed my localization issues with the following code:

remove_action( 'init', 'pmpro_load_textdomain', 1 );

function custom_pmpro_load_textdomain() {
    load_plugin_textdomain( 'paid-memberships-pro' );
}
add_action( 'init', 'custom_pmpro_load_textdomain' );

Anyway, I hope you'll fix the function so it picks the GlotPress .mo file first.

mrleemon avatar Apr 11 '22 12:04 mrleemon

Is this being worked on? I'd like to remove my custom code. Thanks!

mrleemon avatar Dec 03 '22 07:12 mrleemon