Skip to content

Commit 3ed2918

Browse files
committed
feat: add internationalization support with 13 languages
Enable plugin localization with support for 13 languages matching PrestaShop plugin coverage. - Enable load_plugin_textdomain() with conditional translation loading - Add translation files (.pot, .po, .mo) for 13 languages: Catalan, German, Spanish, Estonian, Finnish, French, Italian, Latvian, Dutch, Norwegian, Polish, Portuguese, Russian - Implement smart translation loading: prioritize user customizations, then use local translations if newer than WordPress.org, fallback to WordPress.org translations - Add multiline formatting to credit card settings description for better readability - Add wp-cli/i18n-command for translation management - All 258+ strings professionally translated per language Translation priority: 1. User customizations (wp-content/languages/) 2. Local bundled (if newer or WP.org doesn't exist) 3. WordPress.org community translations
1 parent ea72233 commit 3ed2918

32 files changed

+18780
-7
lines changed

class-woocommerce-gateway-monei.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@ public function init() {
258258
$moneiPaymentServices = new MoneiPaymentServices( $sdkClient );
259259
new MoneiApplePayVerificationService( $moneiPaymentServices );
260260

261-
// todo: not translation yet.
262-
//$this->load_plugin_textdomain();
261+
$this->load_plugin_textdomain();
263262

264263
add_filter( 'option_woocommerce_monei_bizum_settings', array( $this, 'monei_settings_by_default' ), 1 );
265264
add_filter( 'option_woocommerce_monei_paypal_settings', array( $this, 'monei_settings_by_default' ), 1 );
@@ -342,8 +341,35 @@ public function add_gateways( $methods ) {
342341
return $methods;
343342
}
344343

345-
/**private function load_plugin_textdomain() {
346-
}**/
344+
/**
345+
* Load plugin text domain for translations.
346+
*
347+
* @since 6.4.0
348+
*/
349+
private function load_plugin_textdomain() {
350+
// Use local translations only if they're newer than WordPress.org translations or if WP.org version doesn't exist
351+
add_filter(
352+
'load_textdomain_mofile',
353+
function ( $mofile, $domain ) {
354+
if ( 'monei' === $domain ) {
355+
$locale = determine_locale();
356+
$custom_mofile = WP_PLUGIN_DIR . '/' . dirname( plugin_basename( MONEI_MAIN_FILE ) ) . '/languages/monei-' . $locale . '.mo';
357+
358+
if ( file_exists( $custom_mofile ) ) {
359+
// Use local file if WordPress.org version doesn't exist OR if local is newer
360+
if ( ! file_exists( $mofile ) || filemtime( $custom_mofile ) > filemtime( $mofile ) ) {
361+
return $custom_mofile;
362+
}
363+
}
364+
}
365+
return $mofile;
366+
},
367+
10,
368+
2
369+
);
370+
371+
load_plugin_textdomain( 'monei', false, dirname( plugin_basename( MONEI_MAIN_FILE ) ) . '/languages/' );
372+
}
347373

348374
/**
349375
* Get installed version. For retro compat we keep "hide-new-version-monei-notice"

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"php-stubs/wordpress-stubs": "^6.6",
1818
"php-stubs/woocommerce-stubs": "^9.0",
1919
"phpstan/extension-installer": "*",
20-
"slevomat/coding-standard": "^8.22"
20+
"slevomat/coding-standard": "^8.22",
21+
"wp-cli/i18n-command": "^2.6"
2122
},
2223
"scripts": {
2324
"phpcs": "phpcs -n",

0 commit comments

Comments
 (0)