Skip to content

Commit c93691f

Browse files
Translations loading fix112 (#114)
* Add French translations. * load any available translations with code in the plugin
1 parent 1b30e71 commit c93691f

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

aspire-update.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,19 @@
3030
define( 'AP_VERSION', '0.5' );
3131
}
3232

33+
34+
add_action( 'plugins_loaded', 'define_constant' );
35+
function define_constant() {
36+
if ( ! defined( 'AP_PATH' ) ) {
37+
define( 'AP_PATH', dirname( plugin_basename( __FILE__ ) ) );
38+
}
39+
}
40+
3341
require_once __DIR__ . '/includes/autoload.php';
3442

35-
if ( ! defined( 'AP_RUN_TESTS' ) ) {
36-
new AspireUpdate\Controller();
43+
add_action( 'plugins_loaded', 'aspire_update' );
44+
function aspire_update() {
45+
if ( ! defined( 'AP_RUN_TESTS' ) ) {
46+
new AspireUpdate\Controller();
47+
}
3748
}

includes/class-controller.php

+11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public function __construct() {
2020
Themes_Screens::get_instance();
2121

2222
$this->api_rewrite();
23+
24+
add_action( 'init', array( $this, 'load_textdomain' ) );
2325
}
2426

2527
/**
@@ -46,4 +48,13 @@ private function api_rewrite() {
4648
}
4749
}
4850
}
51+
52+
/**
53+
* Load translations.
54+
* @return void
55+
*/
56+
public function load_textdomain() {
57+
\load_plugin_textdomain( 'AspireUpdate', false, AP_PATH . '/languages/' );
58+
}
59+
4960
}

0 commit comments

Comments
 (0)