PluginProbe
YayMail – WooCommerce Email Customizer / 4.3.4
YayMail – WooCommerce Email Customizer v4.3.4
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
yaymail / src / I18n.php

I18n.php in YayMail – WooCommerce Email Customizer 4.3.4, at src/I18n.php

50 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace YayMail;
3
4 use YayMail\Utils\SingletonTrait;
5
6 defined( 'ABSPATH' ) || exit;
7 /**
8 * I18n Logic
9 *
10 * @method static I18n get_instance()
11 */
12 class I18n {
13
14 use SingletonTrait;
15
16 private function __construct() {
17 add_action( 'init', [ $this, 'load_plugin_text_domain' ] );
18 add_filter( 'yaymail_translations', [ $this, 'get_translations' ] );
19 }
20
21 public static function load_plugin_text_domain() {
22 if ( function_exists( 'determine_locale' ) ) {
23 $locale = determine_locale();
24 } else {
25 $locale = is_admin() ? get_user_locale() : get_locale();
26 }
27
28 unload_textdomain( 'yaymail' );
29 load_textdomain( 'yaymail', YAYMAIL_PLUGIN_PATH . 'i18n/languages/yaymail-' . $locale . '.mo' );
30
31 load_plugin_textdomain( 'yaymail', false, YAYMAIL_PLUGIN_PATH . 'i18n/languages/' );
32 }
33
34 public function get_translations() {
35 $translations = get_translations_for_domain( 'yaymail' );
36 $messages = [];
37
38 $entries = $translations->entries;
39 foreach ( $entries as $key => $entry ) {
40 $messages[ $entry->singular ] = $entry->translations;
41 }
42
43 return [
44 'locale_data' => [
45 'messages' => $messages,
46 ],
47 ];
48 }
49 }
50