Weglot Translate – Translate your WP website - Version 3.0.5

Version Description

(22/05/2019) = * Bugfix: Prevent array key exists for Gravity Form * Bugfix: Save menu Weglot Switcher * Bugfix: Check DOM on json-ld and inactive by default

Download this release

Release Info

Developer remyb92
Plugin Icon 128x128 Weglot Translate – Translate your WP website
Version 3.0.5
Comparing to
See all releases

Code changes from version 3.0.4 to 3.0.5

Files changed (33) hide show
  1. readme.txt +6 -1
  2. src/actions/admin/class-customize-menu-weglot.php +1 -0
  3. src/services/class-option-service-weglot.php +4 -1
  4. src/services/class-translate-json-ld.php +6 -2
  5. src/services/class-translate-service-weglot.php +1 -1
  6. src/third/gravityforms/class-gf-filter-urls.php +3 -0
  7. vendor/autoload.php +1 -1
  8. vendor/composer/autoload_classmap.php +1 -0
  9. vendor/composer/autoload_real.php +7 -7
  10. vendor/composer/autoload_static.php +9 -4
  11. vendor/composer/installed.json +46 -7
  12. vendor/weglot/translation-definitions/.gitignore +6 -0
  13. vendor/weglot/translation-definitions/LICENSE +21 -0
  14. vendor/weglot/translation-definitions/README.md +138 -0
  15. vendor/weglot/translation-definitions/composer.json +20 -0
  16. vendor/weglot/translation-definitions/data/available-languages.json +542 -0
  17. vendor/weglot/{weglot-php/tests/unit/Parser/tests_parser_1.json → translation-definitions/data/cases/cases-v1.json} +139 -1
  18. vendor/weglot/translation-definitions/data/cases/cases-v2-js.json +226 -0
  19. vendor/weglot/{weglot-php/tests/unit/Parser/tests_parser_2.json → translation-definitions/data/cases/cases-v2-php.json} +0 -0
  20. vendor/weglot/{weglot-php/tests/unit/Parser/tests_parser_3.json → translation-definitions/data/cases/cases-v3.json} +32 -28
  21. vendor/weglot/translation-definitions/data/merge-nodes.json +21 -0
  22. vendor/weglot/translation-definitions/index.js +25 -0
  23. vendor/weglot/translation-definitions/index.php +45 -0
  24. vendor/weglot/translation-definitions/jsconfig.json +7 -0
  25. vendor/weglot/translation-definitions/mergeNodesList.js +4 -0
  26. vendor/weglot/translation-definitions/package.json +15 -0
  27. vendor/weglot/weglot-php/.travis.yml +1 -0
  28. vendor/weglot/weglot-php/README.md +7 -0
  29. vendor/weglot/weglot-php/composer.json +8 -1
  30. vendor/weglot/weglot-php/src/Parser/Check/DomCheckerProvider.php +15 -1
  31. vendor/weglot/weglot-php/src/Parser/Formatter/DomFormatter.php +26 -0
  32. vendor/weglot/weglot-php/tests/unit/Parser/ParserTest.php +10 -38
  33. weglot.php +2 -2
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: translate, multilingual, language, translation, localization
4
  Requires at least: 4.5
5
  Tested up to: 5.1
6
  Requires PHP: 5.4
7
- Stable tag: 3.0.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -153,6 +153,11 @@ See changelog for upgrade changes.
153
 
154
  == Changelog ==
155
 
 
 
 
 
 
156
  = 3.0.4 (10/05/2019) =
157
  * Bugfix: Prevent errors due to the parser of the JSON-LD
158
 
4
  Requires at least: 4.5
5
  Tested up to: 5.1
6
  Requires PHP: 5.4
7
+ Stable tag: 3.0.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
153
 
154
  == Changelog ==
155
 
156
+ = 3.0.5 (22/05/2019) =
157
+ * Bugfix: Prevent array key exists for Gravity Form
158
+ * Bugfix: Save menu Weglot Switcher
159
+ * Bugfix: Check DOM on json-ld and inactive by default
160
+
161
  = 3.0.4 (10/05/2019) =
162
  * Bugfix: Prevent errors due to the parser of the JSON-LD
163
 
src/actions/admin/class-customize-menu-weglot.php CHANGED
@@ -83,6 +83,7 @@ class Customize_Menu_Weglot implements Hooks_Interface_Weglot {
83
  }
84
 
85
  $this->option_services->set_option_by_key( 'menu_switcher', $options_menu );
 
86
  }
87
 
88
  /**
83
  }
84
 
85
  $this->option_services->set_option_by_key( 'menu_switcher', $options_menu );
86
+
87
  }
88
 
89
  /**
src/services/class-option-service-weglot.php CHANGED
@@ -469,7 +469,10 @@ class Option_Service_Weglot {
469
  * @return Option_Service_Weglot
470
  */
471
  public function set_options( $options ) {
472
- update_option( sprintf( '%s-%s', WEGLOT_SLUG, 'v3' ), $options );
 
 
 
473
  return $this;
474
  }
475
 
469
  * @return Option_Service_Weglot
470
  */
471
  public function set_options( $options ) {
472
+ $key = sprintf( '%s-%s', WEGLOT_SLUG, 'v3' );
473
+ update_option( $key, $options );
474
+ wp_cache_delete ( $key );
475
+
476
  return $this;
477
  }
478
 
src/services/class-translate-json-ld.php CHANGED
@@ -267,16 +267,20 @@ class Translate_Json_Ld {
267
  * @param string $dom
268
  * @return string
269
  */
270
- public function handle( $dom ) {
271
 
272
  $dom = \WGSimpleHtmlDom\str_get_html(
273
- $dom,
274
  true,
275
  true,
276
  WG_DEFAULT_TARGET_CHARSET,
277
  false
278
  );
279
 
 
 
 
 
280
  $this->keys_json_ld_translate = apply_filters( 'weglot_keys_json_ld_translate', $this->keys_json_ld_translate );
281
 
282
  $jsons = $dom->find( 'script[type="application/ld+json"]' );
267
  * @param string $dom
268
  * @return string
269
  */
270
+ public function handle( $domString ) {
271
 
272
  $dom = \WGSimpleHtmlDom\str_get_html(
273
+ $domString,
274
  true,
275
  true,
276
  WG_DEFAULT_TARGET_CHARSET,
277
  false
278
  );
279
 
280
+ if ($dom === false) {
281
+ return $domString;
282
+ }
283
+
284
  $this->keys_json_ld_translate = apply_filters( 'weglot_keys_json_ld_translate', $this->keys_json_ld_translate );
285
 
286
  $jsons = $dom->find( 'script[type="application/ld+json"]' );
src/services/class-translate-service-weglot.php CHANGED
@@ -119,7 +119,7 @@ class Translate_Service_Weglot {
119
  $translated_content = weglot_get_service( 'Caldera_Translate' )->translate_words( $translated_content );
120
  }
121
 
122
- if( apply_filters( 'weglot_translate_json_ld', true ) ){
123
  $translated_content = $this->translate_json_ld_services->handle( $translated_content );
124
  }
125
 
119
  $translated_content = weglot_get_service( 'Caldera_Translate' )->translate_words( $translated_content );
120
  }
121
 
122
+ if( apply_filters( 'weglot_translate_json_ld', false ) ) {
123
  $translated_content = $this->translate_json_ld_services->handle( $translated_content );
124
  }
125
 
src/third/gravityforms/class-gf-filter-urls.php CHANGED
@@ -42,6 +42,9 @@ class GF_Filter_Urls implements Hooks_Interface_Weglot {
42
  * @return array
43
  */
44
  public function weglot_gform_confirmation( $data ) {
 
 
 
45
  if( ! array_key_exists( 'redirect', $data ) ){
46
  return $data;
47
  }
42
  * @return array
43
  */
44
  public function weglot_gform_confirmation( $data ) {
45
+ if( !is_array( $data ) ){
46
+ return $data;
47
+ }
48
  if( ! array_key_exists( 'redirect', $data ) ){
49
  return $data;
50
  }
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInitbf7b9589f81bc8286e1e2b3333897541::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit5a48b6a52756caca80d21143021a26b9::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -6,4 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
 
9
  );
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
+ 'Weglot\\TranslationDefinitions' => $vendorDir . '/weglot/translation-definitions/index.php',
10
  );
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInitbf7b9589f81bc8286e1e2b3333897541
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInitbf7b9589f81bc8286e1e2b3333897541
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInitbf7b9589f81bc8286e1e2b3333897541', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInitbf7b9589f81bc8286e1e2b3333897541', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
- call_user_func(\Composer\Autoload\ComposerStaticInitbf7b9589f81bc8286e1e2b3333897541::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInitbf7b9589f81bc8286e1e2b3333897541
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInitbf7b9589f81bc8286e1e2b3333897541::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequirebf7b9589f81bc8286e1e2b3333897541($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
- function composerRequirebf7b9589f81bc8286e1e2b3333897541($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit5a48b6a52756caca80d21143021a26b9
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit5a48b6a52756caca80d21143021a26b9', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit5a48b6a52756caca80d21143021a26b9', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit5a48b6a52756caca80d21143021a26b9::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInit5a48b6a52756caca80d21143021a26b9::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequire5a48b6a52756caca80d21143021a26b9($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
+ function composerRequire5a48b6a52756caca80d21143021a26b9($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInitbf7b9589f81bc8286e1e2b3333897541
8
  {
9
  public static $files = array (
10
  '6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
@@ -64,12 +64,17 @@ class ComposerStaticInitbf7b9589f81bc8286e1e2b3333897541
64
  ),
65
  );
66
 
 
 
 
 
67
  public static function getInitializer(ClassLoader $loader)
68
  {
69
  return \Closure::bind(function () use ($loader) {
70
- $loader->prefixLengthsPsr4 = ComposerStaticInitbf7b9589f81bc8286e1e2b3333897541::$prefixLengthsPsr4;
71
- $loader->prefixDirsPsr4 = ComposerStaticInitbf7b9589f81bc8286e1e2b3333897541::$prefixDirsPsr4;
72
- $loader->prefixesPsr0 = ComposerStaticInitbf7b9589f81bc8286e1e2b3333897541::$prefixesPsr0;
 
73
 
74
  }, null, ClassLoader::class);
75
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit5a48b6a52756caca80d21143021a26b9
8
  {
9
  public static $files = array (
10
  '6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
64
  ),
65
  );
66
 
67
+ public static $classMap = array (
68
+ 'Weglot\\TranslationDefinitions' => __DIR__ . '/..' . '/weglot/translation-definitions/index.php',
69
+ );
70
+
71
  public static function getInitializer(ClassLoader $loader)
72
  {
73
  return \Closure::bind(function () use ($loader) {
74
+ $loader->prefixLengthsPsr4 = ComposerStaticInit5a48b6a52756caca80d21143021a26b9::$prefixLengthsPsr4;
75
+ $loader->prefixDirsPsr4 = ComposerStaticInit5a48b6a52756caca80d21143021a26b9::$prefixDirsPsr4;
76
+ $loader->prefixesPsr0 = ComposerStaticInit5a48b6a52756caca80d21143021a26b9::$prefixesPsr0;
77
+ $loader->classMap = ComposerStaticInit5a48b6a52756caca80d21143021a26b9::$classMap;
78
 
79
  }, null, ClassLoader::class);
80
  }
vendor/composer/installed.json CHANGED
@@ -181,31 +181,70 @@
181
  "html"
182
  ]
183
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  {
185
  "name": "weglot/weglot-php",
186
- "version": "0.5.23",
187
- "version_normalized": "0.5.23.0",
188
  "source": {
189
  "type": "git",
190
  "url": "https://github.com/weglot/weglot-php.git",
191
- "reference": "bf09ff1dbb21e694b65518153c78593608a61f74"
192
  },
193
  "dist": {
194
  "type": "zip",
195
- "url": "https://api.github.com/repos/weglot/weglot-php/zipball/bf09ff1dbb21e694b65518153c78593608a61f74",
196
- "reference": "bf09ff1dbb21e694b65518153c78593608a61f74",
197
  "shasum": ""
198
  },
199
  "require": {
200
  "php": ">=5.4",
201
  "psr/cache": "^1.0",
202
- "weglot/simplehtmldom": "^0.5"
 
203
  },
204
  "require-dev": {
205
  "codeception/codeception": "^2.4",
206
  "vlucas/phpdotenv": "^2.4"
207
  },
208
- "time": "2019-03-19T13:24:47+00:00",
209
  "type": "library",
210
  "installation-source": "dist",
211
  "autoload": {
181
  "html"
182
  ]
183
  },
184
+ {
185
+ "name": "weglot/translation-definitions",
186
+ "version": "v2.1.4",
187
+ "version_normalized": "2.1.4.0",
188
+ "source": {
189
+ "type": "git",
190
+ "url": "https://github.com/weglot/weglot-translation-definitions.git",
191
+ "reference": "d2d1ef460c8b7d690e3699569dd08ab631b1308e"
192
+ },
193
+ "dist": {
194
+ "type": "zip",
195
+ "url": "https://api.github.com/repos/weglot/weglot-translation-definitions/zipball/d2d1ef460c8b7d690e3699569dd08ab631b1308e",
196
+ "reference": "d2d1ef460c8b7d690e3699569dd08ab631b1308e",
197
+ "shasum": ""
198
+ },
199
+ "require": {
200
+ "php": ">=5"
201
+ },
202
+ "time": "2019-05-17T09:36:33+00:00",
203
+ "type": "library",
204
+ "installation-source": "dist",
205
+ "autoload": {
206
+ "classmap": [
207
+ "index.php"
208
+ ]
209
+ },
210
+ "notification-url": "https://packagist.org/downloads/",
211
+ "license": [
212
+ "MIT"
213
+ ],
214
+ "authors": [
215
+ {
216
+ "name": "Mehdi Rejraji",
217
+ "email": "mehdi@weglot.com"
218
+ }
219
+ ],
220
+ "description": "Weglot's shared definitions"
221
+ },
222
  {
223
  "name": "weglot/weglot-php",
224
+ "version": "0.5.24",
225
+ "version_normalized": "0.5.24.0",
226
  "source": {
227
  "type": "git",
228
  "url": "https://github.com/weglot/weglot-php.git",
229
+ "reference": "49e1a559d2b1e73539148ec00c701a87065b3d31"
230
  },
231
  "dist": {
232
  "type": "zip",
233
+ "url": "https://api.github.com/repos/weglot/weglot-php/zipball/49e1a559d2b1e73539148ec00c701a87065b3d31",
234
+ "reference": "49e1a559d2b1e73539148ec00c701a87065b3d31",
235
  "shasum": ""
236
  },
237
  "require": {
238
  "php": ">=5.4",
239
  "psr/cache": "^1.0",
240
+ "weglot/simplehtmldom": "^0.5",
241
+ "weglot/translation-definitions": "^2.0"
242
  },
243
  "require-dev": {
244
  "codeception/codeception": "^2.4",
245
  "vlucas/phpdotenv": "^2.4"
246
  },
247
+ "time": "2019-05-17T13:01:34+00:00",
248
  "type": "library",
249
  "installation-source": "dist",
250
  "autoload": {
vendor/weglot/translation-definitions/.gitignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ # The project has no dependency
2
+ composer.lock
3
+ /vendor/
4
+ node_modules
5
+ yarn.lock
6
+ test*
vendor/weglot/translation-definitions/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Weglot
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
vendor/weglot/translation-definitions/README.md ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # weglot-translation-definitions
2
+
3
+ ## Project structure
4
+
5
+ - The `data` folder is meant to only contain data files (preferrably JSON)
6
+ - The root folder can contain files mean to
7
+
8
+ The project may itself contain test files and be subject to CI validation in the future, to test for the integrity of the data files.
9
+
10
+ ## Javascript
11
+
12
+ ### Publish a new version
13
+
14
+ You can run `yarn version` and select a new version. Alternatively, run `yarn version --{type}` where type=(major|minor|patch).
15
+ This will update both the `package.json`, create a git tag following the standard `v1.0.0` for version `1.0.0`, and push that tag to origin.
16
+
17
+ ### Reference this package in other projects
18
+
19
+ Check which version you'd like to use if you don't want to use the last version (master branch). Add an entry in the dependencies:
20
+
21
+ ```
22
+ {
23
+ "weglot-translation-definitions": "weglot/weglot-translation-definitions#v1.1.0"
24
+ }
25
+
26
+ ```
27
+
28
+ You can also a command with the following structure:
29
+ `yarn add weglot/weglot-translation-definitions#v1.1.0`
30
+
31
+ ## Routine scripts
32
+
33
+ ### Update available languages
34
+
35
+ If you have HTTPie on your system, run the following command to update the list of available languages:
36
+
37
+ `http --pretty=format https://api.weglot.com/public/languages > data/available-languages.json`
38
+
39
+ You can also run `yarn update-languages`.
40
+
41
+ ## PHP
42
+
43
+ ### Add the dependency
44
+
45
+ In your `composer.json#repositories`, add the following entry:
46
+
47
+ ```json
48
+ {
49
+ "type": "vcs",
50
+ "url": "https://github.com/weglot/weglot-translation-definitions"
51
+ }
52
+ ```
53
+
54
+ In your `composer.json#require`, add the following line:
55
+
56
+ ```json
57
+ "weglot/translation-definitions": "dev-master",
58
+ ```
59
+
60
+ If you wish to use a specific version ([check available tags here](https://github.com/weglot/weglot-translation-definitions/tags)), just replace `master` with the tag name, like so:
61
+
62
+ ```json
63
+ "weglot/translation-definitions": "dev-v1.3.2",
64
+ ```
65
+ ### Update the package
66
+
67
+ `composer update weglot/translation-definitions:dev-master`
68
+
69
+
70
+ ### Usage
71
+
72
+ This assumes you've added the dependency through `composer.json`
73
+
74
+ ```php
75
+
76
+ use Weglot\TranslationDefinitions;
77
+
78
+ print_r(TranslationDefinitions::$languages);
79
+ // Array
80
+ // (
81
+ // [0] => Array
82
+ // (
83
+ // [value] => af
84
+ // [label] => Afrikaans
85
+ // )
86
+
87
+ // [1] => Array
88
+ // (
89
+ // [value] => sq
90
+ // [label] => Albanian
91
+ // )
92
+ // etc.
93
+
94
+ print_r(TranslationDefinitions::$cases);
95
+ // Array
96
+ // (
97
+ // [v1] => Array
98
+ // (
99
+ // [0] => Array
100
+ // (
101
+ // [name] => Simple tag #1
102
+ // [body] => <p>Hello, <b>this is</b> a test!</p>
103
+ // [expected] => Array
104
+ // (
105
+ // [0] => Array
106
+ // (
107
+ // [t] => 1
108
+ // [w] => Hello,
109
+ // )
110
+
111
+ // [1] => Array
112
+ // (
113
+ // [t] => 1
114
+ // [w] => this is
115
+ // )
116
+ // etc.
117
+
118
+ print_r(TranslationDefinitions::$mergeNodesList);
119
+ // Array
120
+ // (
121
+ // [v1] => Array
122
+ // (
123
+ // )
124
+
125
+ // [v2] => Array
126
+ // (
127
+ // [0] => ABBR
128
+ // [1] => ACRONYM
129
+ // [2] => B
130
+ // [3] => BDO
131
+ // [4] => BIG
132
+ // [5] => CITE
133
+ // [6] => EM
134
+ // [7] => I
135
+ // [8] => KBD
136
+ // [9] => Q
137
+ // etc.
138
+ ```
vendor/weglot/translation-definitions/composer.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "weglot/translation-definitions",
3
+ "type": "library",
4
+ "description": "Weglot's shared definitions",
5
+ "license": "MIT",
6
+ "require": {
7
+ "php": ">=5"
8
+ },
9
+ "authors": [
10
+ {
11
+ "name": "Mehdi Rejraji",
12
+ "email": "mehdi@weglot.com"
13
+ }
14
+ ],
15
+ "autoload": {
16
+ "classmap": [
17
+ "index.php"
18
+ ]
19
+ }
20
+ }
vendor/weglot/translation-definitions/data/available-languages.json ADDED
@@ -0,0 +1,542 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "code": "af",
4
+ "english_name": "Afrikaans",
5
+ "local_name": "Afrikaans"
6
+ },
7
+ {
8
+ "code": "am",
9
+ "english_name": "Amharic",
10
+ "local_name": "አማርኛ"
11
+ },
12
+ {
13
+ "code": "ar",
14
+ "english_name": "Arabic",
15
+ "local_name": "العربية‏"
16
+ },
17
+ {
18
+ "code": "az",
19
+ "english_name": "Azerbaijani",
20
+ "local_name": "Azərbaycan dili"
21
+ },
22
+ {
23
+ "code": "ba",
24
+ "english_name": "Bashkir",
25
+ "local_name": "башҡорт теле"
26
+ },
27
+ {
28
+ "code": "be",
29
+ "english_name": "Belarusian",
30
+ "local_name": "Беларуская"
31
+ },
32
+ {
33
+ "code": "bg",
34
+ "english_name": "Bulgarian",
35
+ "local_name": "български"
36
+ },
37
+ {
38
+ "code": "bn",
39
+ "english_name": "Bengali",
40
+ "local_name": "বাংলা"
41
+ },
42
+ {
43
+ "code": "bs",
44
+ "english_name": "Bosnian",
45
+ "local_name": "Bosanski"
46
+ },
47
+ {
48
+ "code": "ca",
49
+ "english_name": "Catalan",
50
+ "local_name": "Català"
51
+ },
52
+ {
53
+ "code": "co",
54
+ "english_name": "Corsican",
55
+ "local_name": "Corsu"
56
+ },
57
+ {
58
+ "code": "cs",
59
+ "english_name": "Czech",
60
+ "local_name": "Čeština"
61
+ },
62
+ {
63
+ "code": "cy",
64
+ "english_name": "Welsh",
65
+ "local_name": "Cymraeg"
66
+ },
67
+ {
68
+ "code": "da",
69
+ "english_name": "Danish",
70
+ "local_name": "Dansk"
71
+ },
72
+ {
73
+ "code": "de",
74
+ "english_name": "German",
75
+ "local_name": "Deutsch"
76
+ },
77
+ {
78
+ "code": "el",
79
+ "english_name": "Greek",
80
+ "local_name": "Ελληνικά"
81
+ },
82
+ {
83
+ "code": "en",
84
+ "english_name": "English",
85
+ "local_name": "English"
86
+ },
87
+ {
88
+ "code": "eo",
89
+ "english_name": "Esperanto",
90
+ "local_name": "Esperanto"
91
+ },
92
+ {
93
+ "code": "es",
94
+ "english_name": "Spanish",
95
+ "local_name": "Español"
96
+ },
97
+ {
98
+ "code": "et",
99
+ "english_name": "Estonian",
100
+ "local_name": "Eesti"
101
+ },
102
+ {
103
+ "code": "eu",
104
+ "english_name": "Basque",
105
+ "local_name": "Euskara"
106
+ },
107
+ {
108
+ "code": "fa",
109
+ "english_name": "Persian",
110
+ "local_name": "فارسی"
111
+ },
112
+ {
113
+ "code": "fi",
114
+ "english_name": "Finnish",
115
+ "local_name": "Suomi"
116
+ },
117
+ {
118
+ "code": "fj",
119
+ "english_name": "Fijian",
120
+ "local_name": "Vosa Vakaviti"
121
+ },
122
+ {
123
+ "code": "fl",
124
+ "english_name": "Filipino",
125
+ "local_name": "Pilipino"
126
+ },
127
+ {
128
+ "code": "fr",
129
+ "english_name": "French",
130
+ "local_name": "Français"
131
+ },
132
+ {
133
+ "code": "fy",
134
+ "english_name": "Western Frisian",
135
+ "local_name": "frysk"
136
+ },
137
+ {
138
+ "code": "ga",
139
+ "english_name": "Irish",
140
+ "local_name": "Gaeilge"
141
+ },
142
+ {
143
+ "code": "gd",
144
+ "english_name": "Scottish Gaelic",
145
+ "local_name": "Gàidhlig"
146
+ },
147
+ {
148
+ "code": "gl",
149
+ "english_name": "Galician",
150
+ "local_name": "Galego"
151
+ },
152
+ {
153
+ "code": "gu",
154
+ "english_name": "Gujarati",
155
+ "local_name": "ગુજરાતી"
156
+ },
157
+ {
158
+ "code": "ha",
159
+ "english_name": "Hausa",
160
+ "local_name": "هَوُسَ"
161
+ },
162
+ {
163
+ "code": "he",
164
+ "english_name": "Hebrew",
165
+ "local_name": "עברית"
166
+ },
167
+ {
168
+ "code": "hi",
169
+ "english_name": "Hindi",
170
+ "local_name": "हिंदी"
171
+ },
172
+ {
173
+ "code": "hr",
174
+ "english_name": "Croatian",
175
+ "local_name": "Hrvatski"
176
+ },
177
+ {
178
+ "code": "ht",
179
+ "english_name": "Haitian",
180
+ "local_name": "Kreyòl ayisyen"
181
+ },
182
+ {
183
+ "code": "hu",
184
+ "english_name": "Hungarian",
185
+ "local_name": "Magyar"
186
+ },
187
+ {
188
+ "code": "hw",
189
+ "english_name": "Hawaiian",
190
+ "local_name": "‘Ōlelo Hawai‘i"
191
+ },
192
+ {
193
+ "code": "hy",
194
+ "english_name": "Armenian",
195
+ "local_name": "հայերեն"
196
+ },
197
+ {
198
+ "code": "id",
199
+ "english_name": "Indonesian",
200
+ "local_name": "Bahasa Indonesia"
201
+ },
202
+ {
203
+ "code": "ig",
204
+ "english_name": "Igbo",
205
+ "local_name": "Igbo"
206
+ },
207
+ {
208
+ "code": "is",
209
+ "english_name": "Icelandic",
210
+ "local_name": "Íslenska"
211
+ },
212
+ {
213
+ "code": "it",
214
+ "english_name": "Italian",
215
+ "local_name": "Italiano"
216
+ },
217
+ {
218
+ "code": "ja",
219
+ "english_name": "Japanese",
220
+ "local_name": "日本語"
221
+ },
222
+ {
223
+ "code": "jv",
224
+ "english_name": "Javanese",
225
+ "local_name": "Wong Jawa"
226
+ },
227
+ {
228
+ "code": "ka",
229
+ "english_name": "Georgian",
230
+ "local_name": "ქართული"
231
+ },
232
+ {
233
+ "code": "kk",
234
+ "english_name": "Kazakh",
235
+ "local_name": "Қазақша"
236
+ },
237
+ {
238
+ "code": "km",
239
+ "english_name": "Central Khmer",
240
+ "local_name": "ភាសាខ្មែរ"
241
+ },
242
+ {
243
+ "code": "kn",
244
+ "english_name": "Kannada",
245
+ "local_name": "ಕನ್ನಡ"
246
+ },
247
+ {
248
+ "code": "ko",
249
+ "english_name": "Korean",
250
+ "local_name": "한국어"
251
+ },
252
+ {
253
+ "code": "ku",
254
+ "english_name": "Kurdish",
255
+ "local_name": "كوردی"
256
+ },
257
+ {
258
+ "code": "ky",
259
+ "english_name": "Kyrgyz",
260
+ "local_name": "кыргызча"
261
+ },
262
+ {
263
+ "code": "la",
264
+ "english_name": "Latin",
265
+ "local_name": "Latine"
266
+ },
267
+ {
268
+ "code": "lb",
269
+ "english_name": "Luxembourgish",
270
+ "local_name": "Lëtzebuergesch"
271
+ },
272
+ {
273
+ "code": "lo",
274
+ "english_name": "Lao",
275
+ "local_name": "ພາສາລາວ"
276
+ },
277
+ {
278
+ "code": "lt",
279
+ "english_name": "Lithuanian",
280
+ "local_name": "Lietuvių"
281
+ },
282
+ {
283
+ "code": "lv",
284
+ "english_name": "Latvian",
285
+ "local_name": "Latviešu"
286
+ },
287
+ {
288
+ "code": "mg",
289
+ "english_name": "Malagasy",
290
+ "local_name": "Malagasy"
291
+ },
292
+ {
293
+ "code": "mi",
294
+ "english_name": "Māori",
295
+ "local_name": "te reo Māori"
296
+ },
297
+ {
298
+ "code": "mk",
299
+ "english_name": "Macedonian",
300
+ "local_name": "Македонски"
301
+ },
302
+ {
303
+ "code": "ml",
304
+ "english_name": "Malayalam",
305
+ "local_name": "മലയാളം"
306
+ },
307
+ {
308
+ "code": "mn",
309
+ "english_name": "Mongolian",
310
+ "local_name": "Монгол"
311
+ },
312
+ {
313
+ "code": "mr",
314
+ "english_name": "Marathi",
315
+ "local_name": "मराठी"
316
+ },
317
+ {
318
+ "code": "ms",
319
+ "english_name": "Malay",
320
+ "local_name": "Bahasa Melayu"
321
+ },
322
+ {
323
+ "code": "mt",
324
+ "english_name": "Maltese",
325
+ "local_name": "Malti"
326
+ },
327
+ {
328
+ "code": "my",
329
+ "english_name": "Burmese",
330
+ "local_name": "မျန္မာစာ"
331
+ },
332
+ {
333
+ "code": "ne",
334
+ "english_name": "Nepali",
335
+ "local_name": "नेपाली"
336
+ },
337
+ {
338
+ "code": "nl",
339
+ "english_name": "Dutch",
340
+ "local_name": "Nederlands"
341
+ },
342
+ {
343
+ "code": "no",
344
+ "english_name": "Norwegian",
345
+ "local_name": "Norsk"
346
+ },
347
+ {
348
+ "code": "ny",
349
+ "english_name": "Chichewa",
350
+ "local_name": "chiCheŵa"
351
+ },
352
+ {
353
+ "code": "pa",
354
+ "english_name": "Punjabi",
355
+ "local_name": "ਪੰਜਾਬੀ"
356
+ },
357
+ {
358
+ "code": "pl",
359
+ "english_name": "Polish",
360
+ "local_name": "Polski"
361
+ },
362
+ {
363
+ "code": "ps",
364
+ "english_name": "Pashto",
365
+ "local_name": "پښت"
366
+ },
367
+ {
368
+ "code": "pt",
369
+ "english_name": "Portuguese",
370
+ "local_name": "Português"
371
+ },
372
+ {
373
+ "code": "ro",
374
+ "english_name": "Romanian",
375
+ "local_name": "Română"
376
+ },
377
+ {
378
+ "code": "ru",
379
+ "english_name": "Russian",
380
+ "local_name": "Русский"
381
+ },
382
+ {
383
+ "code": "sd",
384
+ "english_name": "Sindhi",
385
+ "local_name": "سنڌي، سندھی, सिन्धी"
386
+ },
387
+ {
388
+ "code": "si",
389
+ "english_name": "Sinhalese",
390
+ "local_name": "සිංහල"
391
+ },
392
+ {
393
+ "code": "sk",
394
+ "english_name": "Slovak",
395
+ "local_name": "Slovenčina"
396
+ },
397
+ {
398
+ "code": "sl",
399
+ "english_name": "Slovenian",
400
+ "local_name": "Slovenščina"
401
+ },
402
+ {
403
+ "code": "sm",
404
+ "english_name": "Samoan",
405
+ "local_name": "gagana fa'a Samoa"
406
+ },
407
+ {
408
+ "code": "sn",
409
+ "english_name": "Shona",
410
+ "local_name": "chiShona"
411
+ },
412
+ {
413
+ "code": "so",
414
+ "english_name": "Somali",
415
+ "local_name": "Soomaaliga"
416
+ },
417
+ {
418
+ "code": "sq",
419
+ "english_name": "Albanian",
420
+ "local_name": "Shqip"
421
+ },
422
+ {
423
+ "code": "sr",
424
+ "english_name": "Serbian",
425
+ "local_name": "Српски"
426
+ },
427
+ {
428
+ "code": "st",
429
+ "english_name": "Southern Sotho",
430
+ "local_name": "seSotho"
431
+ },
432
+ {
433
+ "code": "su",
434
+ "english_name": "Sundanese",
435
+ "local_name": "Sundanese"
436
+ },
437
+ {
438
+ "code": "sv",
439
+ "english_name": "Swedish",
440
+ "local_name": "Svenska"
441
+ },
442
+ {
443
+ "code": "sw",
444
+ "english_name": "Swahili",
445
+ "local_name": "Kiswahili"
446
+ },
447
+ {
448
+ "code": "ta",
449
+ "english_name": "Tamil",
450
+ "local_name": "தமிழ்"
451
+ },
452
+ {
453
+ "code": "te",
454
+ "english_name": "Telugu",
455
+ "local_name": "తెలుగు"
456
+ },
457
+ {
458
+ "code": "tg",
459
+ "english_name": "Tajik",
460
+ "local_name": "Тоҷикӣ"
461
+ },
462
+ {
463
+ "code": "th",
464
+ "english_name": "Thai",
465
+ "local_name": "ภาษาไทย"
466
+ },
467
+ {
468
+ "code": "tl",
469
+ "english_name": "Tagalog",
470
+ "local_name": "Tagalog"
471
+ },
472
+ {
473
+ "code": "to",
474
+ "english_name": "Tongan",
475
+ "local_name": "faka-Tonga"
476
+ },
477
+ {
478
+ "code": "tr",
479
+ "english_name": "Turkish",
480
+ "local_name": "Türkçe"
481
+ },
482
+ {
483
+ "code": "tt",
484
+ "english_name": "Tatar",
485
+ "local_name": "Tatar"
486
+ },
487
+ {
488
+ "code": "tw",
489
+ "english_name": "Traditional Chinese",
490
+ "local_name": "中文 (繁體)"
491
+ },
492
+ {
493
+ "code": "ty",
494
+ "english_name": "Tahitian",
495
+ "local_name": "te reo Tahiti, te reo Māʼohi"
496
+ },
497
+ {
498
+ "code": "uk",
499
+ "english_name": "Ukrainian",
500
+ "local_name": "Українська"
501
+ },
502
+ {
503
+ "code": "ur",
504
+ "english_name": "Urdu",
505
+ "local_name": "اردو"
506
+ },
507
+ {
508
+ "code": "uz",
509
+ "english_name": "Uzbek",
510
+ "local_name": "O'zbek"
511
+ },
512
+ {
513
+ "code": "vi",
514
+ "english_name": "Vietnamese",
515
+ "local_name": "Tiếng Việt"
516
+ },
517
+ {
518
+ "code": "xh",
519
+ "english_name": "Xhosa",
520
+ "local_name": "isiXhosa"
521
+ },
522
+ {
523
+ "code": "yi",
524
+ "english_name": "Yiddish",
525
+ "local_name": "ייִדיש"
526
+ },
527
+ {
528
+ "code": "yo",
529
+ "english_name": "Yoruba",
530
+ "local_name": "Yorùbá"
531
+ },
532
+ {
533
+ "code": "zh",
534
+ "english_name": "Simplified Chinese",
535
+ "local_name": "中文 (简体)"
536
+ },
537
+ {
538
+ "code": "zu",
539
+ "english_name": "Zulu",
540
+ "local_name": "isiZulu"
541
+ }
542
+ ]
vendor/weglot/{weglot-php/tests/unit/Parser/tests_parser_1.json → translation-definitions/data/cases/cases-v1.json} RENAMED
@@ -17,6 +17,88 @@
17
  }
18
  ]
19
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  {
21
  "name": "Nested tags 3",
22
  "body": "<p>This is a sentence with <strong>bolded</strong> text and <em>italic text</em> and <div>other</div> text.</p>",
@@ -83,6 +165,62 @@
83
  }
84
  ]
85
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  {
87
  "name": "Link tag",
88
  "body": "<p>Hello, <a href='#'>this is</a> a test!</p>",
@@ -159,4 +297,4 @@
159
  }
160
  ]
161
  }
162
- ]
17
  }
18
  ]
19
  },
20
+ {
21
+ "name": "Simple tag #2",
22
+ "body": "<p>Hello, <strong>this is</strong> a test!</p>",
23
+ "expected": [
24
+ {
25
+ "t": 1,
26
+ "w": "Hello, "
27
+ },
28
+ {
29
+ "t": 1,
30
+ "w": "this is"
31
+ },
32
+ {
33
+ "t": 1,
34
+ "w": " a test!"
35
+ }
36
+ ]
37
+ },
38
+ {
39
+ "name": "Simple tag #3",
40
+ "body": "<p>Hello, <em>this is</em> a test!</p>",
41
+ "expected": [
42
+ {
43
+ "t": 1,
44
+ "w": "Hello, "
45
+ },
46
+ {
47
+ "t": 1,
48
+ "w": "this is"
49
+ },
50
+ {
51
+ "t": 1,
52
+ "w": " a test!"
53
+ }
54
+ ]
55
+ },
56
+ {
57
+ "name": "Simple tag #4",
58
+ "body": "<p>This is a normal sentence</p>",
59
+ "expected": [
60
+ {
61
+ "t": 1,
62
+ "w": "This is a normal sentence"
63
+ }
64
+ ]
65
+ },
66
+ {
67
+ "name": "Nested simple tags",
68
+ "body": "<p>Hello, <i><b>this is</b></i> a test!</p>",
69
+ "expected": [
70
+ {
71
+ "t": 1,
72
+ "w": "Hello, "
73
+ },
74
+ {
75
+ "t": 1,
76
+ "w": "this is"
77
+ },
78
+ {
79
+ "t": 1,
80
+ "w": " a test!"
81
+ }
82
+ ]
83
+ },
84
+ {
85
+ "name": "Nested tags 2",
86
+ "body": "<p>This is a sentence with <strong>bolded</strong> text.</p>",
87
+ "expected": [
88
+ {
89
+ "t": 1,
90
+ "w": "This is a sentence with "
91
+ },
92
+ {
93
+ "t": 1,
94
+ "w": "bolded"
95
+ },
96
+ {
97
+ "t": 1,
98
+ "w": " text."
99
+ }
100
+ ]
101
+ },
102
  {
103
  "name": "Nested tags 3",
104
  "body": "<p>This is a sentence with <strong>bolded</strong> text and <em>italic text</em> and <div>other</div> text.</p>",
165
  }
166
  ]
167
  },
168
+ {
169
+ "name": "Nested tags 6",
170
+ "body": "<p>We believe <strong><strong>everything</strong></strong><em><em> is important</em></em></p>",
171
+ "expected": [
172
+ {
173
+ "t": 1,
174
+ "w": "We believe "
175
+ },
176
+ {
177
+ "t": 1,
178
+ "w": "everything"
179
+ },
180
+ {
181
+ "t": 1,
182
+ "w": " is important"
183
+ }
184
+ ]
185
+ },
186
+ {
187
+ "name": "Nested tags 7",
188
+ "body": "<p><abbr><i></i><i></i><strong><strong>Hello, </strong></strong><em><em>how are you</em></em><i></i></abbr></p>",
189
+ "expected": [
190
+ {
191
+ "t": 1,
192
+ "w": "Hello, "
193
+ },
194
+ {
195
+ "t": 1,
196
+ "w": "how are you"
197
+ }
198
+ ]
199
+ },
200
+ {
201
+ "name": "Nested tags 8",
202
+ "body": "<p><abbr><i></i><i></i><b><strong><strong>Hello, </strong></strong><em><em>how are you</em></em></b><i></i></abbr></p>",
203
+ "expected": [
204
+ {
205
+ "t": 1,
206
+ "w": "Hello, "
207
+ },
208
+ {
209
+ "t": 1,
210
+ "w": "how are you"
211
+ }
212
+ ]
213
+ },
214
+ {
215
+ "name": "Nested tags 9",
216
+ "body": "<p><abbr><i></i><i></i><b><strong><strong>Hello, </strong></strong></b><i></i></abbr></p>",
217
+ "expected": [
218
+ {
219
+ "t": 1,
220
+ "w": "Hello, "
221
+ }
222
+ ]
223
+ },
224
  {
225
  "name": "Link tag",
226
  "body": "<p>Hello, <a href='#'>this is</a> a test!</p>",
297
  }
298
  ]
299
  }
300
+ ]
vendor/weglot/translation-definitions/data/cases/cases-v2-js.json ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "name": "Simple tag #1",
4
+ "body": "<p>Hello, <b>this is</b> a test!</p>",
5
+ "expected": [
6
+ {
7
+ "t": 1,
8
+ "w": "Hello, <b>this is</b> a test!"
9
+ }
10
+ ]
11
+ },
12
+ {
13
+ "name": "Simple tag #2",
14
+ "body": "<p>Hello, <strong>this is</strong> a test!</p>",
15
+ "expected": [
16
+ {
17
+ "t": 1,
18
+ "w": "Hello, <strong>this is</strong> a test!"
19
+ }
20
+ ]
21
+ },
22
+ {
23
+ "name": "Simple tag #3",
24
+ "body": "<p>Hello, <em>this is</em> a test!</p>",
25
+ "expected": [
26
+ {
27
+ "t": 1,
28
+ "w": "Hello, <em>this is</em> a test!"
29
+ }
30
+ ]
31
+ },
32
+ {
33
+ "name": "Simple tag #4",
34
+ "body": "<p>This is a normal sentence</p>",
35
+ "expected": [
36
+ {
37
+ "t": 1,
38
+ "w": "This is a normal sentence"
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ "name": "Nested simple tags",
44
+ "body": "<p>Hello, <i><b>this is</b></i> a test!</p>",
45
+ "expected": [
46
+ {
47
+ "t": 1,
48
+ "w": "Hello, <i><b>this is</b></i> a test!"
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ "name": "Nested tags 2",
54
+ "body": "<p>This is a sentence with <strong>bolded</strong> text.</p>",
55
+ "expected": [
56
+ {
57
+ "t": 1,
58
+ "w": "This is a sentence with <strong>bolded</strong> text."
59
+ }
60
+ ]
61
+ },
62
+ {
63
+ "name": "Nested tags 3",
64
+ "body": "<p>This is a sentence with <strong>bolded</strong> text and <em>italic text</em> and <div>other</div> text.</p>",
65
+ "expected": [
66
+ {
67
+ "t": 1,
68
+ "w": "This is a sentence with <strong>bolded</strong> text and <em>italic text</em> and "
69
+ },
70
+ {
71
+ "t": 1,
72
+ "w": "other"
73
+ },
74
+ {
75
+ "t": 1,
76
+ "w": " text."
77
+ }
78
+ ]
79
+ },
80
+ {
81
+ "name": "Nested tags 4",
82
+ "body": "<p><strong>Everything is important</strong></p>",
83
+ "expected": [
84
+ {
85
+ "t": 1,
86
+ "w": "Everything is important"
87
+ }
88
+ ]
89
+ },
90
+ {
91
+ "name": "Nested tags 5",
92
+ "body": "<p>We believe <strong>everything is <em>really</em> important</strong></p>",
93
+ "expected": [
94
+ {
95
+ "t": 1,
96
+ "w": "We believe <strong>everything is <em>really</em> important</strong>"
97
+ }
98
+ ]
99
+ },
100
+ {
101
+ "name": "Nested tags 6",
102
+ "body": "<p>We believe <strong><strong>everything</strong></strong><em><em> is important</em></em></p>",
103
+ "expected": [
104
+ {
105
+ "t": 1,
106
+ "w": "We believe <strong><strong>everything</strong></strong><em><em> is important</em></em>"
107
+ }
108
+ ]
109
+ },
110
+ {
111
+ "name": "Nested tags 7",
112
+ "body": "<p><abbr><i></i><i></i><strong><strong>Hello, </strong></strong><em><em>how are you</em></em><i></i></abbr></p>",
113
+ "expected": [
114
+ {
115
+ "t": 1,
116
+ "w": "<i></i><i></i><strong><strong>Hello, </strong></strong><em><em>how are you</em></em><i></i>"
117
+ }
118
+ ]
119
+ },
120
+ {
121
+ "name": "Nested tags 8",
122
+ "body": "<p><abbr><i></i><i></i><b><strong><strong>Hello, </strong></strong><em><em>how are you</em></em></b><i></i></abbr></p>",
123
+ "expected": [
124
+ {
125
+ "t": 1,
126
+ "w": "<strong><strong>Hello, </strong></strong><em><em>how are you</em></em>"
127
+ }
128
+ ]
129
+ },
130
+ {
131
+ "name": "Nested tags 9",
132
+ "body": "<p><abbr><i></i><i></i><b><strong><strong>Hello, </strong></strong></b><i></i></abbr></p>",
133
+ "expected": [
134
+ {
135
+ "t": 1,
136
+ "w": "Hello, "
137
+ }
138
+ ]
139
+ },
140
+ {
141
+ "name": "Nested tags 10",
142
+ "body": "<p><abbr><i></i><i></i><b><strong> <strong>Hello, </strong></strong> <em> <em> how are you</em></em></b><i></i></abbr></p>",
143
+ "expected": [
144
+ {
145
+ "t": 1,
146
+ "w": "<strong> <strong>Hello, </strong></strong> <em> <em> how are you</em></em>"
147
+ }
148
+ ]
149
+ },
150
+ {
151
+ "name": "Link tag",
152
+ "body": "<p>Hello, <a href='#'>this is</a> a test!</p>",
153
+ "expected": [
154
+ {
155
+ "t": 1,
156
+ "w": "Hello, "
157
+ },
158
+ {
159
+ "t": 1,
160
+ "w": "this is"
161
+ },
162
+ {
163
+ "t": 1,
164
+ "w": " a test!"
165
+ }
166
+ ]
167
+ },
168
+ {
169
+ "name": "Button tag",
170
+ "body": "<form><button value='Click me!'></button></form>",
171
+ "expected": [
172
+ {
173
+ "t": 2,
174
+ "w": "Click me!"
175
+ }
176
+ ]
177
+ },
178
+ {
179
+ "name": "Input tag",
180
+ "body": "<form><input type='text' placeholder='This is a placeholder!'></form>",
181
+ "expected": [
182
+ {
183
+ "t": 3,
184
+ "w": "This is a placeholder!"
185
+ }
186
+ ]
187
+ },
188
+ {
189
+ "name": "Meta tag",
190
+ "body": "<meta name='description' content='This is a website description!'>",
191
+ "expected": [
192
+ {
193
+ "t": 4,
194
+ "w": "This is a website description!"
195
+ }
196
+ ]
197
+ },
198
+ {
199
+ "name": "Image tag",
200
+ "body": "<p><img src='/an-image.png' alt='This is an image!'></p>",
201
+ "expected": [
202
+ {
203
+ "t": 7,
204
+ "w": "This is an image!"
205
+ },
206
+ {
207
+ "t": 6,
208
+ "w": "/an-image.png"
209
+ }
210
+ ]
211
+ },
212
+ {
213
+ "name": "Link tag with pdf",
214
+ "body": "<p><a href='/my-document.pdf'>Click here!</a></p>",
215
+ "expected": [
216
+ {
217
+ "t": 8,
218
+ "w": "/my-document.pdf"
219
+ },
220
+ {
221
+ "t": 1,
222
+ "w": "Click here!"
223
+ }
224
+ ]
225
+ }
226
+ ]
vendor/weglot/{weglot-php/tests/unit/Parser/tests_parser_2.json → translation-definitions/data/cases/cases-v2-php.json} RENAMED
File without changes
vendor/weglot/{weglot-php/tests/unit/Parser/tests_parser_3.json → translation-definitions/data/cases/cases-v3.json} RENAMED
@@ -61,35 +61,11 @@
61
  },
62
  {
63
  "name": "Nested tags 3",
64
- "body": "<p>This is a sentence with <strong>bolded</strong> text and <em>italic text</em> and <div>other</div> text.</p>",
65
  "expected": [
66
  {
67
  "t": 1,
68
- "w": "This is a sentence with "
69
- },
70
- {
71
- "t": 1,
72
- "w": "bolded"
73
- },
74
- {
75
- "t": 1,
76
- "w": " text and "
77
- },
78
- {
79
- "t": 1,
80
- "w": "italic text"
81
- },
82
- {
83
- "t": 1,
84
- "w": " and "
85
- },
86
- {
87
- "t": 1,
88
- "w": "other"
89
- },
90
- {
91
- "t": 1,
92
- "w": " text."
93
  }
94
  ]
95
  },
@@ -225,13 +201,31 @@
225
  }
226
  ]
227
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  {
229
  "name": "tag with br",
230
- "body": "<p>Hello, <br /> a test!</p>",
231
  "expected": [
232
  {
233
  "t": 1,
234
- "w": "Hello, <br wg-1=\"\" /> a test!"
235
  }
236
  ]
237
  },
@@ -354,5 +348,15 @@
354
  "w": "Click here!"
355
  }
356
  ]
 
 
 
 
 
 
 
 
 
 
357
  }
358
  ]
61
  },
62
  {
63
  "name": "Nested tags 3",
64
+ "body": "<p>This is a sentence with <strong>bolded</strong> text and <em>italic text</em> and other text.</p>",
65
  "expected": [
66
  {
67
  "t": 1,
68
+ "w": "This is a sentence with <strong wg-1=\"\">bolded</strong> text and <em wg-2=\"\">italic text</em> and other text."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  }
70
  ]
71
  },
201
  }
202
  ]
203
  },
204
+ {
205
+ "name": "Nested tags 14",
206
+ "body": "<li><a><h2>Banho Floral</h2><span>A first link</span></a><a>Another link</a></li>",
207
+ "expected": [
208
+ {
209
+ "t": 1,
210
+ "w": "Banho Floral"
211
+ },
212
+ {
213
+ "t": 1,
214
+ "w": "A first link"
215
+ },
216
+ {
217
+ "t": 1,
218
+ "w": "Another link"
219
+ }
220
+ ]
221
+ },
222
  {
223
  "name": "tag with br",
224
+ "body": "<p>Hello, <br> a test!</p>",
225
  "expected": [
226
  {
227
  "t": 1,
228
+ "w": "Hello, <br wg-1=\"\"> a test!"
229
  }
230
  ]
231
  },
348
  "w": "Click here!"
349
  }
350
  ]
351
+ },
352
+ {
353
+ "name": "Tag with new line and blanks",
354
+ "body": "<p> \n\n <strong>test</strong> \n\n </p>",
355
+ "expected": [
356
+ {
357
+ "t": 1,
358
+ "w": "test"
359
+ }
360
+ ]
361
  }
362
  ]
vendor/weglot/translation-definitions/data/merge-nodes.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "v1": [],
3
+ "v2": [
4
+ "ABBR",
5
+ "ACRONYM",
6
+ "B",
7
+ "BDO",
8
+ "BIG",
9
+ "CITE",
10
+ "EM",
11
+ "I",
12
+ "KBD",
13
+ "Q",
14
+ "SMALL",
15
+ "STRONG",
16
+ "SUB",
17
+ "SUP",
18
+ "U"
19
+ ],
20
+ "v3": ["A", "BDI", "BR", "DEL", "DFN", "INS", "S", "SPAN"]
21
+ }
vendor/weglot/translation-definitions/index.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // NOTE: This file should not contain any data itself.
2
+ var labelKey = "english_name"; // local_name | english_name
3
+
4
+ var cases = {
5
+ v1: require("./data/cases/cases-v1.json"),
6
+ v2: require("./data/cases/cases-v2-js.json"),
7
+ v3: require("./data/cases/cases-v3.json")
8
+ };
9
+
10
+ var languages = require("./data/available-languages.json")
11
+ .sort(function(a, b) {
12
+ return a[labelKey].localeCompare(b[labelKey]);
13
+ })
14
+ .map(function(language) {
15
+ return {
16
+ label: language[labelKey],
17
+ value: language.code
18
+ };
19
+ });
20
+
21
+ module.exports = {
22
+ cases: cases,
23
+ mergeNodesList: require("./mergeNodesList").mergeNodesList,
24
+ languages: languages
25
+ };
vendor/weglot/translation-definitions/index.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Weglot;
4
+
5
+ class TranslationDefinitions
6
+ {
7
+ public static $languages;
8
+ public static $cases;
9
+ public static $mergeNodesList;
10
+ private static $labelKey = "english_name";
11
+
12
+ private static function loadJSON($key)
13
+ {
14
+ return json_decode(file_get_contents(__DIR__ . "/data/" . $key . ".json"), true);
15
+ }
16
+
17
+ private static function sortedJSONArray($pathKey, $sortKey, $sortOrder = SORT_ASC)
18
+ {
19
+ $array = self::loadJSON($pathKey);
20
+ array_multisort(array_map(function ($el) use ($sortKey) {
21
+ return $el[$sortKey];
22
+ }, $array), $sortOrder, $array);
23
+ return $array;
24
+ }
25
+
26
+ static function init()
27
+ {
28
+ self::$languages = array_map(function ($language) {
29
+ return array(
30
+ 'label' => $language[self::$labelKey],
31
+ 'value' => $language['code']
32
+ );
33
+ }, self::sortedJSONArray("available-languages", self::$labelKey));
34
+
35
+ self::$cases = array(
36
+ 'v1' => self::loadJSON("cases/cases-v1"),
37
+ 'v2' => self::loadJSON("cases/cases-v2-php"),
38
+ 'v3' => self::loadJSON("cases/cases-v3")
39
+ );
40
+
41
+ self::$mergeNodesList = self::loadJSON("merge-nodes");
42
+ }
43
+ }
44
+
45
+ TranslationDefinitions::init();
vendor/weglot/translation-definitions/jsconfig.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "resolveJsonModule": true,
5
+ "checkJs": true
6
+ }
7
+ }
vendor/weglot/translation-definitions/mergeNodesList.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ // NOTE: This file should not contain any data itself.
2
+ var mergeNodesList = require("./data/merge-nodes.json");
3
+ mergeNodesList.v2.unshift("#text");
4
+ exports.mergeNodesList = mergeNodesList;
vendor/weglot/translation-definitions/package.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "weglot-translation-definitions",
3
+ "version": "2.1.4",
4
+ "main": "index.js",
5
+ "private": true,
6
+ "repository": "https://github.com/weglot/weglot-translation-definitions.git",
7
+ "author": "Mehdi Rejraji <mehdi.rejraji@gmail.com>",
8
+ "license": "MIT",
9
+ "scripts": {
10
+ "test": "echo \"Running tests before publishing...\"",
11
+ "preversion": "yarn test",
12
+ "postversion": "git push origin v$npm_package_version",
13
+ "update-languages": "http --pretty=format https://api.weglot.com/public/languages > data/available-languages.json"
14
+ }
15
+ }
vendor/weglot/weglot-php/.travis.yml CHANGED
@@ -30,6 +30,7 @@ matrix:
30
  env: COVERAGE=true TEST_FLAGS="--coverage --coverage-xml"
31
 
32
  install:
 
33
  - |
34
  if [[ $prefer = low ]]; then
35
  $COMPOSER_UP --prefer-lowest --prefer-stable
30
  env: COVERAGE=true TEST_FLAGS="--coverage --coverage-xml"
31
 
32
  install:
33
+ - composer config -g github-oauth.github.com "$TOKEN"
34
  - |
35
  if [[ $prefer = low ]]; then
36
  $COMPOSER_UP --prefer-lowest --prefer-stable
vendor/weglot/weglot-php/README.md CHANGED
@@ -226,6 +226,13 @@ $hreflang = $url->generateHrefLangsTags()
226
  */
227
  ```
228
 
 
 
 
 
 
 
 
229
  ## About
230
  `weglot-php` is guided and supported by the Weglot Developer Team.
231
 
226
  */
227
  ```
228
 
229
+ ##Tests
230
+ Only parser
231
+ `./vendor/codeception/codeception/codecept run -g parser`
232
+
233
+ Full test
234
+ `./vendor/codeception/codeception/codecept run`
235
+
236
  ## About
237
  `weglot-php` is guided and supported by the Weglot Developer Team.
238
 
vendor/weglot/weglot-php/composer.json CHANGED
@@ -33,10 +33,17 @@
33
  "languages",
34
  "i18n"
35
  ],
 
 
 
 
 
 
36
  "require": {
37
  "php": ">=5.4",
38
  "weglot/simplehtmldom": "^0.5",
39
- "psr/cache": "^1.0"
 
40
  },
41
  "autoload": {
42
  "psr-4": {
33
  "languages",
34
  "i18n"
35
  ],
36
+ "repositories": [
37
+ {
38
+ "type": "vcs",
39
+ "url": "https://github.com/weglot/weglot-translation-definitions"
40
+ }
41
+ ],
42
  "require": {
43
  "php": ">=5.4",
44
  "weglot/simplehtmldom": "^0.5",
45
+ "psr/cache": "^1.0",
46
+ "weglot/translation-definitions": "^2.0"
47
  },
48
  "autoload": {
49
  "psr-4": {
vendor/weglot/weglot-php/src/Parser/Check/DomCheckerProvider.php CHANGED
@@ -317,7 +317,7 @@ class DomCheckerProvider
317
 
318
  foreach($node->nodes as $n) {
319
 
320
- if($this->isBlock($n) || $n->hasAttribute(Parser::ATTRIBUTE_NO_TRANSLATE)) {
321
  return false;
322
  }
323
 
@@ -406,6 +406,20 @@ class DomCheckerProvider
406
  return (!$this->isInline($node) && !$this->isText($node) && !($node->tag === 'br'));
407
  }
408
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  public function isInlineOrText($node) {
410
  return $this->isInline($node) || $this->isText($node);
411
  }
317
 
318
  foreach($node->nodes as $n) {
319
 
320
+ if($this->containsBlock($n) || $n->hasAttribute(Parser::ATTRIBUTE_NO_TRANSLATE)) {
321
  return false;
322
  }
323
 
406
  return (!$this->isInline($node) && !$this->isText($node) && !($node->tag === 'br'));
407
  }
408
 
409
+ public function containsBlock($node) {
410
+
411
+ if($this->isBlock($node))
412
+ return true;
413
+ else {
414
+ foreach($node->nodes as $n) {
415
+ if($this->containsBlock($n))
416
+ return true;
417
+ }
418
+ return false;
419
+ }
420
+
421
+ }
422
+
423
  public function isInlineOrText($node) {
424
  return $this->isInline($node) || $this->isText($node);
425
  }
vendor/weglot/weglot-php/src/Parser/Formatter/DomFormatter.php CHANGED
@@ -5,6 +5,32 @@ namespace Weglot\Parser\Formatter;
5
  use Weglot\Parser\Check\Dom\ImageSource;
6
  use Weglot\Parser\Check\Dom\MetaContent;
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  /**
9
  * Class DomFormatter
10
  * @package Weglot\Parser\Formatter
5
  use Weglot\Parser\Check\Dom\ImageSource;
6
  use Weglot\Parser\Check\Dom\MetaContent;
7
 
8
+ if (! function_exists('array_column')) {
9
+ function array_column(array $input, $columnKey, $indexKey = null) {
10
+ $array = array();
11
+ foreach ($input as $value) {
12
+ if ( !array_key_exists($columnKey, $value)) {
13
+ trigger_error("Key \"$columnKey\" does not exist in array");
14
+ return false;
15
+ }
16
+ if (is_null($indexKey)) {
17
+ $array[] = $value[$columnKey];
18
+ }
19
+ else {
20
+ if ( !array_key_exists($indexKey, $value)) {
21
+ trigger_error("Key \"$indexKey\" does not exist in array");
22
+ return false;
23
+ }
24
+ if ( ! is_scalar($value[$indexKey])) {
25
+ trigger_error("Key \"$indexKey\" does not contain scalar value");
26
+ return false;
27
+ }
28
+ $array[$value[$indexKey]] = $value[$columnKey];
29
+ }
30
+ }
31
+ return $array;
32
+ }
33
+ }
34
  /**
35
  * Class DomFormatter
36
  * @package Weglot\Parser\Formatter
vendor/weglot/weglot-php/tests/unit/Parser/ParserTest.php CHANGED
@@ -5,6 +5,7 @@ use Weglot\Parser\ConfigProvider\ManualConfigProvider;
5
  use Weglot\Client\Api\Enum\BotType;
6
  use Weglot\Client\Client;
7
  use Weglot\Parser\Parser;
 
8
 
9
  class ParserTest extends \Codeception\Test\Unit
10
  {
@@ -87,56 +88,27 @@ class ParserTest extends \Codeception\Test\Unit
87
 
88
  public function testParserEngine1NodeSplit()
89
  {
90
- $string = file_get_contents(__DIR__ . "/tests_parser_1.json");
91
- $json_array = json_decode($string, true);
92
-
93
-
94
- foreach ($json_array as $test) {
95
-
96
- // Parser
97
- $client = new Client(getenv('WG_API_KEY') , 1);
98
- $this->parser = new Parser($client, $this->config['server']);
99
-
100
- // Run the Parser
101
- $strings = $this->parser->parse($test['body']);
102
- foreach ($strings as $k => $string) {
103
- $this->assertEquals( $test['expected'][$k]['w'], $string->getWord());
104
- $this->assertEquals( $test['expected'][$k]['t'], $string->getType());
105
- }
106
- }
107
  }
108
 
109
  public function testParserEngine2NodeSplit()
110
  {
111
- $string = file_get_contents(__DIR__ . "/tests_parser_2.json");
112
- $json_array = json_decode($string, true);
113
-
114
-
115
- foreach ($json_array as $test) {
116
-
117
- // Parser
118
- $client = new Client(getenv('WG_API_KEY') , 2);
119
- $this->parser = new Parser($client, $this->config['server']);
120
-
121
- // Run the Parser
122
- $strings = $this->parser->parse($test['body']);
123
- foreach ($strings as $k => $string) {
124
- $this->assertEquals( $test['expected'][$k]['w'], $string->getWord());
125
- $this->assertEquals( $test['expected'][$k]['t'], $string->getType());
126
- }
127
- }
128
  }
129
 
130
  public function testParserEngine3NodeSplit()
131
  {
132
- $string = file_get_contents(__DIR__ . "/tests_parser_3.json");
133
- $json_array = json_decode($string, true);
134
 
 
 
 
135
 
136
- foreach ($json_array as $test) {
137
 
138
  // Parser
139
- $client = new Client(getenv('WG_API_KEY') , 3);
140
  $this->parser = new Parser($client, $this->config['server']);
141
 
142
  // Run the Parser
5
  use Weglot\Client\Api\Enum\BotType;
6
  use Weglot\Client\Client;
7
  use Weglot\Parser\Parser;
8
+ use Weglot\TranslationDefinitions;
9
 
10
  class ParserTest extends \Codeception\Test\Unit
11
  {
88
 
89
  public function testParserEngine1NodeSplit()
90
  {
91
+ $this->_parserEngineNodeSplit(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
93
 
94
  public function testParserEngine2NodeSplit()
95
  {
96
+ $this->_parserEngineNodeSplit(2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  }
98
 
99
  public function testParserEngine3NodeSplit()
100
  {
101
+ $this->_parserEngineNodeSplit(3);
102
+ }
103
 
104
+ public function _parserEngineNodeSplit($version)
105
+ {
106
+ $cases = TranslationDefinitions::$cases["v" . $version];
107
 
108
+ foreach ($cases as $test) {
109
 
110
  // Parser
111
+ $client = new Client(getenv('WG_API_KEY') , $version);
112
  $this->parser = new Parser($client, $this->config['server']);
113
 
114
  // Run the Parser
weglot.php CHANGED
@@ -7,7 +7,7 @@ Author: Weglot Translate team
7
  Author URI: https://weglot.com/
8
  Text Domain: weglot
9
  Domain Path: /languages/
10
- Version: 3.0.4
11
  */
12
 
13
  /**
@@ -22,7 +22,7 @@ if ( ! defined('ABSPATH')) {
22
  define('WEGLOT_NAME', 'Weglot');
23
  define('WEGLOT_SLUG', 'weglot-translate');
24
  define('WEGLOT_OPTION_GROUP', 'group-weglot-translate');
25
- define('WEGLOT_VERSION', '3.0.4');
26
  define('WEGLOT_PHP_MIN', '5.4');
27
  define('WEGLOT_BNAME', plugin_basename(__FILE__));
28
  define('WEGLOT_DIR', __DIR__ );
7
  Author URI: https://weglot.com/
8
  Text Domain: weglot
9
  Domain Path: /languages/
10
+ Version: 3.0.5
11
  */
12
 
13
  /**
22
  define('WEGLOT_NAME', 'Weglot');
23
  define('WEGLOT_SLUG', 'weglot-translate');
24
  define('WEGLOT_OPTION_GROUP', 'group-weglot-translate');
25
+ define('WEGLOT_VERSION', '3.0.5');
26
  define('WEGLOT_PHP_MIN', '5.4');
27
  define('WEGLOT_BNAME', plugin_basename(__FILE__));
28
  define('WEGLOT_DIR', __DIR__ );