jamespot-react-core 1.1.108 → 1.1.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,10 +5,12 @@
5
5
  * the jamespot-react-components and all the extensions of the jamespot-react-extensions projects
6
6
  * for all languages based on the default english values
7
7
  */
8
- class Translator {
8
+ class Translator
9
+ {
9
10
 
10
11
  const JAMESPOT_RESOURCE_PATH = "../../jamespot-pro/jpro/lang/%s.i.php";
11
12
  const EXTENSION_RESOURCE_PATH = "../../jamespot-react-extensions/src/extensions/*/translation/lang.json";
13
+ const EXTENSION_RESOURCE_PATH_SUB = "../../jamespot-react-extensions/src/extensions/*/*/translation/lang.json";
12
14
  const COMPONENT_RESOURCE_PATH = "../../jamespot-react-components/src/translation/lang.json";
13
15
 
14
16
  const LANGUAGES = ['en', 'fr', 'es', 'fl', 'nl', 'de', 'it', 'pl', 'pt', 'ro', 'tr'];
@@ -17,9 +19,10 @@ class Translator {
17
19
  public $traductionKeysTmp = [];
18
20
 
19
21
  // Load all traduction keys in $traductionKeys
20
- function loadJameslationResources() {
22
+ function loadJameslationResources()
23
+ {
21
24
  echo "\nLoading resources";
22
- foreach(self::LANGUAGES as $language) {
25
+ foreach (self::LANGUAGES as $language) {
23
26
  $this->traductionKeysTmp = [];
24
27
  require(sprintf(self::JAMESPOT_RESOURCE_PATH, $language));
25
28
  $this->traductionKeys[$language] = $this->traductionKeysTmp;
@@ -27,14 +30,18 @@ class Translator {
27
30
  echo "\nDONE";
28
31
  }
29
32
 
30
- function translateReactResources() {
33
+ function translateReactResources()
34
+ {
31
35
  $this->translateResource(self::COMPONENT_RESOURCE_PATH);
32
- foreach (glob(self::EXTENSION_RESOURCE_PATH) as $file) {
33
- $this->translateResource($file);
36
+ foreach ([self::EXTENSION_RESOURCE_PATH, self::EXTENSION_RESOURCE_PATH_SUB] as $path) {
37
+ foreach (glob($path) as $file) {
38
+ $this->translateResource($file);
39
+ }
34
40
  }
35
41
  }
36
42
 
37
- function translateResource($file) {
43
+ function translateResource($file)
44
+ {
38
45
  $json = json_decode(file_get_contents($file), false);
39
46
  $json = $json->en;
40
47
  $outputAllTranslations = [];
@@ -63,7 +70,7 @@ class Translator {
63
70
  }
64
71
  $outputAllTranslations[$language] = $output;
65
72
  }
66
- file_put_contents($file, json_encode($outputAllTranslations, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
73
+ file_put_contents($file, json_encode($outputAllTranslations, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
67
74
  }
68
75
  }
69
76
 
@@ -72,7 +79,8 @@ $translator->loadJameslationResources();
72
79
  $translator->translateReactResources();
73
80
 
74
81
  // override addTrans method called in every jameslation language files
75
- function addTrans($key, $value) {
82
+ function addTrans($key, $value)
83
+ {
76
84
  global $translator;
77
85
  $str = preg_replace('/\\\\/', '', $value);
78
86
  $translator->traductionKeysTmp[$key] = stripslashes($str);