TranslatePress – Translate Multilingual sites - Version 1.3.1

Version Description

  • Fixed Woocommerce translation of permalinks
  • Added support for remove_accents to be based on default language when called from the sanitize_title function
  • Added support for translating JSON found in custom ajax request
  • Added better REST compatibility
  • Added compatibility for Peepso plugin
  • Fixed TranslatePress roken link to google translate set up api key on settings page
  • Corrected flags for Arabic and Bengali languages
  • Fixed issue with multiple slashes being added when the URL had extra get parameters
Download this release

Release Info

Developer madalin.ungureanu
Plugin Icon 128x128 TranslatePress – Translate Multilingual sites
Version 1.3.1
Comparing to
See all releases

Code changes from version 1.3.0 to 1.3.1

assets/images/flags/ar.png CHANGED
Binary file
assets/images/flags/bn_BD.png CHANGED
Binary file
class-translate-press.php CHANGED
@@ -39,7 +39,7 @@ class TRP_Translate_Press{
39
define( 'TRP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
40
define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
41
define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
42
- define( 'TRP_PLUGIN_VERSION', '1.3.0' );
43
44
$this->load_dependencies();
45
$this->initialize_components();
@@ -138,6 +138,14 @@ class TRP_Translate_Press{
138
$this->loader->add_filter( 'trp_before_translate_content', $this->translation_render, 'force_form_language_on_url_in_ajax', 20 );
139
/* handle CDATA str replacement from the content as it is messing up the renderer */
140
$this->loader->add_filter( "trp_before_translate_content", $this->translation_render, 'handle_cdata', 1000 );
141
142
143
$this->loader->add_action( 'wp_enqueue_scripts', $this->language_switcher, 'enqueue_language_switcher_scripts' );
@@ -208,6 +216,8 @@ class TRP_Translate_Press{
208
* we can't flush the permalinks on every page load so we filter the rewrite_rules option
209
*/
210
$this->loader->add_filter( "option_rewrite_rules", $this->url_converter, 'woocommerce_filter_permalinks_on_other_languages' );
211
212
/* add to the body class the current language */
213
$this->loader->add_filter( "body_class", $this->translation_manager, 'add_language_to_body_class' );
39
define( 'TRP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
40
define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
41
define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
42
+ define( 'TRP_PLUGIN_VERSION', '1.3.1' );
43
44
$this->load_dependencies();
45
$this->initialize_components();
138
$this->loader->add_filter( 'trp_before_translate_content', $this->translation_render, 'force_form_language_on_url_in_ajax', 20 );
139
/* handle CDATA str replacement from the content as it is messing up the renderer */
140
$this->loader->add_filter( "trp_before_translate_content", $this->translation_render, 'handle_cdata', 1000 );
141
+
142
+ /* apply translation filters for REST API response */
143
+ $post_types = get_post_types();
144
+ foreach ( $post_types as $post_type ) {
145
+ $this->loader->add_filter( 'rest_prepare_'.$post_type, $this->translation_render, 'handle_rest_api_translations' );
146
+ }
147
+
148
+
149
150
151
$this->loader->add_action( 'wp_enqueue_scripts', $this->language_switcher, 'enqueue_language_switcher_scripts' );
216
* we can't flush the permalinks on every page load so we filter the rewrite_rules option
217
*/
218
$this->loader->add_filter( "option_rewrite_rules", $this->url_converter, 'woocommerce_filter_permalinks_on_other_languages' );
219
+ $this->loader->add_filter( "option_woocommerce_permalinks", $this->url_converter, 'woocommerce_filter_permalink_option' );
220
+ $this->loader->add_filter( "pre_update_option_woocommerce_permalinks", $this->url_converter, 'woocommerce_handle_permalink_option_on_frontend', 10, 2 );
221
222
/* add to the body class the current language */
223
$this->loader->add_filter( "body_class", $this->translation_manager, 'add_language_to_body_class' );
includes/class-translation-render.php CHANGED
@@ -36,6 +36,10 @@ class TRP_Translation_Render{
36
return;
37
}
38
39
mb_http_output("UTF-8");
40
ob_start(array($this, 'translate_page'));
41
}
@@ -256,6 +260,18 @@ class TRP_Translation_Render{
256
return null;
257
}
258
259
/**
260
* Finding translateable strings and replacing with translations.
261
*
@@ -271,6 +287,16 @@ class TRP_Translation_Render{
271
return $output;
272
}
273
274
global $TRP_LANGUAGE;
275
$language_code = $this->force_language_in_preview();
276
if ($language_code === false) {
@@ -279,39 +305,43 @@ class TRP_Translation_Render{
279
280
$preview_mode = isset( $_REQUEST['trp-edit-translation'] ) && $_REQUEST['trp-edit-translation'] == 'preview';
281
282
- /* if there is an ajax request and we have a json response we need to parse it and only translate the nodes that contain html */
283
- if( TRP_Translation_Manager::is_ajax_on_frontend() ) {
284
285
- /* if it's one of our own ajax calls don't do nothing */
286
- if( !empty( $_REQUEST['action'] ) && strpos( $_REQUEST['action'], 'trp_' ) === 0 && $_REQUEST['action'] != 'trp_split_translation_block' ){
287
- return $output;
288
- }
289
290
- //check if we have a json response
291
- if (is_array($json_array = json_decode($output, true))) {
292
- if (!empty($json_array)) {
293
- foreach ($json_array as $key => $value) {
294
- if (!empty($value)) {
295
- if (!is_array($value)) { //if the current element is not an array check if it a html text and translate
296
- if (html_entity_decode((string)$value) != strip_tags(html_entity_decode((string)$value))) {
297
- $json_array[$key] = $this->translate_page(stripslashes($value));
298
- }
299
- } else {//look for the html elements
300
- foreach( $value as $k => $v ){
301
- if( !empty( $v ) ) {
302
- if (!is_array($v)) {
303
- if (html_entity_decode((string)$v) != strip_tags(html_entity_decode((string)$v))) {
304
- $json_array[$key][$k] = $this->translate_page(stripslashes($v));
305
- }
306
- }
307
- }
308
- }
309
- }
310
- }
311
- }
312
- }
313
- return trp_safe_json_encode($json_array);
314
- }
315
}
316
317
/**
@@ -625,10 +655,6 @@ class TRP_Translation_Render{
625
626
}
627
628
- if ( ! $this->url_converter ) {
629
- $trp = TRP_Translate_Press::get_trp_instance();
630
- $this->url_converter = $trp->get_component('url_converter');
631
- }
632
633
// We need to save here in order to access the translated links too.
634
$html = $html->save();
36
return;
37
}
38
39
+
40
+ /*if($_SERVER['REQUEST_URI'] == '/it/wp-json/wp/v2/posts/')
41
+ return;*/
42
+
43
mb_http_output("UTF-8");
44
ob_start(array($this, 'translate_page'));
45
}
260
return null;
261
}
262
263
+ /**
264
+ * Function that translates the content excerpt and post title in the REST API
265
+ * @param $response
266
+ * @return mixed
267
+ */
268
+ public function handle_rest_api_translations($response){
269
+ $response->data['title']['rendered'] = $this->translate_page( $response->data['title']['rendered'] );
270
+ $response->data['excerpt']['rendered'] = $this->translate_page( $response->data['excerpt']['rendered'] );
271
+ $response->data['content']['rendered'] = $this->translate_page( $response->data['content']['rendered'] );
272
+ return $response;
273
+ }
274
+
275
/**
276
* Finding translateable strings and replacing with translations.
277
*
287
return $output;
288
}
289
290
+ if ( ! $this->url_converter ) {
291
+ $trp = TRP_Translate_Press::get_trp_instance();
292
+ $this->url_converter = $trp->get_component('url_converter');
293
+ }
294
+
295
+ /* make sure we only translate on the rest_prepare_$post_type filter in REST requests and not the whole json */
296
+ if( strpos( $this->url_converter->cur_page_url(), get_rest_url() ) !== false && strpos( current_filter(), 'rest_prepare_' ) !== 0){
297
+ return $output;
298
+ }
299
+
300
global $TRP_LANGUAGE;
301
$language_code = $this->force_language_in_preview();
302
if ($language_code === false) {
305
306
$preview_mode = isset( $_REQUEST['trp-edit-translation'] ) && $_REQUEST['trp-edit-translation'] == 'preview';
307
308
+ $is_json = is_array( $json_array = json_decode( $output, true ) );
309
+ /* If we have a json response we need to parse it and only translate the nodes that contain html
310
+ *
311
+ * Removed is_ajax_on_frontend() check because we need to capture custom ajax events.
312
+ * Decided that if $output is json decodable it's a good enough check to handle it this way.
313
+ * We have necessary checks so that we don't get to this point when is_admin(), or when language is not default.
314
+ */
315
+ if( $is_json ) {
316
+ /* if it's one of our own ajax calls don't do nothing */
317
+ if ( ! empty( $_REQUEST['action'] ) && strpos( $_REQUEST['action'], 'trp_' ) === 0 && $_REQUEST['action'] != 'trp_split_translation_block' ) {
318
+ return $output;
319
+ }
320
321
+ //check if we have a json response
322
+ if ( ! empty( $json_array ) ) {
323
+ foreach ( $json_array as $key => $value ) {
324
+ if ( ! empty( $value ) ) {
325
+ if ( ! is_array( $value ) ) { //if the current element is not an array check if it a html text and translate
326
+ if ( html_entity_decode( (string) $value ) != strip_tags( html_entity_decode( (string) $value ) ) ) {
327
+ $json_array[ $key ] = $this->translate_page( stripslashes( $value ) );
328
+ }
329
+ } else {//look for the html elements
330
+ foreach ( $value as $k => $v ) {
331
+ if ( ! empty( $v ) ) {
332
+ if ( ! is_array( $v ) ) {
333
+ if ( html_entity_decode( (string) $v ) != strip_tags( html_entity_decode( (string) $v ) ) ) {
334
+ $json_array[ $key ][ $k ] = $this->translate_page( stripslashes( $v ) );
335
+ }
336
+ }
337
+ }
338
+ }
339
+ }
340
+ }
341
+ }
342
+ }
343
344
+ return trp_safe_json_encode( $json_array );
345
}
346
347
/**
655
656
}
657
658
659
// We need to save here in order to access the translated links too.
660
$html = $html->save();
includes/class-url-converter.php CHANGED
@@ -185,8 +185,8 @@ class TRP_Url_Converter {
185
* so we can get the correct permalink (slug and all) and add the remaining arguments that might exist.
186
*/
187
$TRP_LANGUAGE = $language;
188
- if ( !empty ( $arguments ) ){
189
- $arguments = apply_filters( 'trp_get_url_for_language_custom_arguments', '/' . ltrim($arguments, '/' ), $language, $url, $post_id );
190
}
191
$new_url = get_permalink( $post_id ) . $arguments;
192
$TRP_LANGUAGE = $trp_language_copy;
@@ -219,6 +219,11 @@ class TRP_Url_Converter {
219
$translated_tag_slug = trp_x( 'product-tag', 'slug', 'woocommerce', $language );
220
$new_url = str_replace( '/'.$current_tag_slug.'/', '/'.$translated_tag_slug.'/', $new_url );
221
}
222
}
223
224
if ( empty( $new_url ) ) {
@@ -380,16 +385,13 @@ class TRP_Url_Converter {
380
$default_language_wc_permalink_structure['category_rewrite_slug'] = trp_x( 'product-category', 'slug', 'woocommerce', $this->settings['default-language'] );
381
$default_language_wc_permalink_structure['tag_rewrite_slug'] = trp_x( 'product-tag', 'slug', 'woocommerce', $this->settings['default-language'] );
382
}
383
384
- if( function_exists( 'wc_get_permalink_structure' ) ){
385
- $current_language_permalink_structure = wc_get_permalink_structure();
386
- }
387
- else{
388
- $current_language_permalink_structure = array();
389
- $current_language_permalink_structure['product_rewrite_slug'] = trp_x( 'product', 'slug', 'woocommerce', $TRP_LANGUAGE );
390
- $current_language_permalink_structure['category_rewrite_slug'] = trp_x( 'product-category', 'slug', 'woocommerce', $TRP_LANGUAGE );
391
- $current_language_permalink_structure['tag_rewrite_slug'] = trp_x( 'product-tag', 'slug', 'woocommerce', $TRP_LANGUAGE );
392
- }
393
394
$new_rewrite_rules = array();
395
@@ -412,4 +414,34 @@ class TRP_Url_Converter {
412
return $rewrite_rules;
413
}
414
415
}
185
* so we can get the correct permalink (slug and all) and add the remaining arguments that might exist.
186
*/
187
$TRP_LANGUAGE = $language;
188
+ if ( !empty ( $arguments ) ) {
189
+ $arguments = apply_filters('trp_get_url_for_language_custom_arguments', $arguments, $language, $url, $post_id);
190
}
191
$new_url = get_permalink( $post_id ) . $arguments;
192
$TRP_LANGUAGE = $trp_language_copy;
219
$translated_tag_slug = trp_x( 'product-tag', 'slug', 'woocommerce', $language );
220
$new_url = str_replace( '/'.$current_tag_slug.'/', '/'.$translated_tag_slug.'/', $new_url );
221
}
222
+ elseif( is_product() ){
223
+ $current_product_slug = trp_x( 'product', 'slug', 'woocommerce', $TRP_LANGUAGE );
224
+ $translated_product_slug = trp_x( 'product', 'slug', 'woocommerce', $language );
225
+ $new_url = str_replace( '/'.$current_product_slug.'/', '/'.$translated_product_slug.'/', $new_url );
226
+ }
227
}
228
229
if ( empty( $new_url ) ) {
385
$default_language_wc_permalink_structure['category_rewrite_slug'] = trp_x( 'product-category', 'slug', 'woocommerce', $this->settings['default-language'] );
386
$default_language_wc_permalink_structure['tag_rewrite_slug'] = trp_x( 'product-tag', 'slug', 'woocommerce', $this->settings['default-language'] );
387
}
388
+
389
+ //always generate the slugs for defaults on the current language
390
+ $current_language_permalink_structure = array();
391
+ $current_language_permalink_structure['product_rewrite_slug'] = trp_x( 'product', 'slug', 'woocommerce', $TRP_LANGUAGE );
392
+ $current_language_permalink_structure['category_rewrite_slug'] = trp_x( 'product-category', 'slug', 'woocommerce', $TRP_LANGUAGE );
393
+ $current_language_permalink_structure['tag_rewrite_slug'] = trp_x( 'product-tag', 'slug', 'woocommerce', $TRP_LANGUAGE );
394
395
396
$new_rewrite_rules = array();
397
414
return $rewrite_rules;
415
}
416
417
+ /* on frontend on other languages dinamically generate the woo permalink structure for the default slugs */
418
+ function woocommerce_filter_permalink_option( $value ){
419
+ global $TRP_LANGUAGE;
420
+ if( $TRP_LANGUAGE != $this->settings['default-language'] ) {
421
+ if( trim($value['product_base'], '/') === trp_x( 'product', 'slug', 'woocommerce', $this->settings['default-language'] ) ){
422
+ $value['product_base'] = '';
423
+ }
424
+
425
+ if( trim($value['category_base'], '/') === trp_x( 'product-category', 'slug', 'woocommerce', $this->settings['default-language'] ) ){
426
+ $value['category_base'] = '';
427
+ }
428
+
429
+ if( trim($value['tag_base'], '/') === trp_x( 'product-tag', 'slug', 'woocommerce', $this->settings['default-language'] ) ){
430
+ $value['tag_base'] = '';
431
+ }
432
+
433
+ }
434
+
435
+ return $value;
436
+ }
437
+
438
+ /* don't update the woocommerce_permalink option on the frontend if we are not on the default language */
439
+ function woocommerce_handle_permalink_option_on_frontend($value, $old_value){
440
+ global $TRP_LANGUAGE;
441
+ if( isset($TRP_LANGUAGE) && $TRP_LANGUAGE != $this->settings['default-language'] ){
442
+ $value = $old_value;
443
+ }
444
+ return $value;
445
+ }
446
+
447
}
includes/functions.php CHANGED
@@ -254,3 +254,282 @@ function trp_wp_trim_words( $text, $num_words = 55, $more = null, $original_text
254
return $text;
255
}
256
add_filter('wp_trim_words', 'trp_wp_trim_words', 100, 4);
254
return $text;
255
}
256
add_filter('wp_trim_words', 'trp_wp_trim_words', 100, 4);
257
+
258
+
259
+ /**
260
+ * Use home_url in the https://www.peepso.com/ ajax front-end url so strings come back translated.
261
+ *
262
+ * @since 1.3.1
263
+ *
264
+ * @param array $data Peepso data
265
+ * @return array
266
+ */
267
+ add_filter( 'peepso_data', 'trp_use_home_url_in_peepso_ajax' );
268
+ function trp_use_home_url_in_peepso_ajax( $data ){
269
+ if ( is_array( $data ) && isset( $data['ajaxurl_legacy'] ) ){
270
+ $data['ajaxurl_legacy'] = home_url( '/peepsoajax/' );
271
+ }
272
+ return $data;
273
+ }
274
+
275
+ /**
276
+ * Filter sanitize_title() to use our own remove_accents() function so it's based on the default language, not current locale.
277
+ *
278
+ * @since 1.3.1
279
+ *
280
+ * @param string $title
281
+ * @param string $raw_title
282
+ * @param string $context
283
+ * @return string
284
+ */
285
+ add_filter( 'sanitize_title', 'trp_sanitize_title', 1, 3 );
286
+ function trp_sanitize_title( $title, $raw_title, $context ){
287
+
288
+ if ( 'save' == $context )
289
+ $title = trp_remove_accents( $raw_title );
290
+
291
+ remove_filter( 'sanitize_title', 'trp_sanitize_title', 1, 3 );
292
+ $title = apply_filters( 'sanitize_title', $title, $raw_title, $context );
293
+ add_filter( 'sanitize_title', 'trp_sanitize_title', 1, 3 );
294
+
295
+ return $title;
296
+ }
297
+
298
+ function trp_remove_accents( $string ){
299
+
300
+ if ( !preg_match('/[\x80-\xff]/', $string) )
301
+ return $string;
302
+
303
+ if (seems_utf8($string)) {
304
+ $chars = array(
305
+ // Decompositions for Latin-1 Supplement
306
+ 'ª' => 'a', 'º' => 'o',
307
+ 'À' => 'A', 'Á' => 'A',
308
+ 'Â' => 'A', 'Ã' => 'A',
309
+ 'Ä' => 'A', 'Å' => 'A',
310
+ 'Æ' => 'AE','Ç' => 'C',
311
+ 'È' => 'E', 'É' => 'E',
312
+ 'Ê' => 'E', 'Ë' => 'E',
313
+ 'Ì' => 'I', 'Í' => 'I',
314
+ 'Î' => 'I', 'Ï' => 'I',
315
+ 'Ð' => 'D', 'Ñ' => 'N',
316
+ 'Ò' => 'O', 'Ó' => 'O',
317
+ 'Ô' => 'O', 'Õ' => 'O',
318
+ 'Ö' => 'O', 'Ù' => 'U',
319
+ 'Ú' => 'U', 'Û' => 'U',
320
+ 'Ü' => 'U', 'Ý' => 'Y',
321
+ 'Þ' => 'TH','ß' => 's',
322
+ 'à' => 'a', 'á' => 'a',
323
+ 'â' => 'a', 'ã' => 'a',
324
+ 'ä' => 'a', 'å' => 'a',
325
+ 'æ' => 'ae','ç' => 'c',
326
+ 'è' => 'e', 'é' => 'e',
327
+ 'ê' => 'e', 'ë' => 'e',
328
+ 'ì' => 'i', 'í' => 'i',
329
+ 'î' => 'i', 'ï' => 'i',
330
+ 'ð' => 'd', 'ñ' => 'n',
331
+ 'ò' => 'o', 'ó' => 'o',
332
+ 'ô' => 'o', 'õ' => 'o',
333
+ 'ö' => 'o', 'ø' => 'o',
334
+ 'ù' => 'u', 'ú' => 'u',
335
+ 'û' => 'u', 'ü' => 'u',
336
+ 'ý' => 'y', 'þ' => 'th',
337
+ 'ÿ' => 'y', 'Ø' => 'O',
338
+ // Decompositions for Latin Extended-A
339
+ 'Ā' => 'A', 'ā' => 'a',
340
+ 'Ă' => 'A', 'ă' => 'a',
341
+ 'Ą' => 'A', 'ą' => 'a',
342
+ 'Ć' => 'C', 'ć' => 'c',
343
+ 'Ĉ' => 'C', 'ĉ' => 'c',
344
+ 'Ċ' => 'C', 'ċ' => 'c',
345
+ 'Č' => 'C', 'č' => 'c',
346
+ 'Ď' => 'D', 'ď' => 'd',
347
+ 'Đ' => 'D', 'đ' => 'd',
348
+ 'Ē' => 'E', 'ē' => 'e',
349
+ 'Ĕ' => 'E', 'ĕ' => 'e',
350
+ 'Ė' => 'E', 'ė' => 'e',
351
+ 'Ę' => 'E', 'ę' => 'e',
352
+ 'Ě' => 'E', 'ě' => 'e',
353
+ 'Ĝ' => 'G', 'ĝ' => 'g',
354
+ 'Ğ' => 'G', 'ğ' => 'g',
355
+ 'Ġ' => 'G', 'ġ' => 'g',
356
+ 'Ģ' => 'G', 'ģ' => 'g',
357
+ 'Ĥ' => 'H', 'ĥ' => 'h',
358
+ 'Ħ' => 'H', 'ħ' => 'h',
359
+ 'Ĩ' => 'I', 'ĩ' => 'i',
360
+ 'Ī' => 'I', 'ī' => 'i',
361
+ 'Ĭ' => 'I', 'ĭ' => 'i',
362
+ 'Į' => 'I', 'į' => 'i',
363
+ 'İ' => 'I', 'ı' => 'i',
364
+ 'IJ' => 'IJ','ij' => 'ij',
365
+ 'Ĵ' => 'J', 'ĵ' => 'j',
366
+ 'Ķ' => 'K', 'ķ' => 'k',
367
+ 'ĸ' => 'k', 'Ĺ' => 'L',
368
+ 'ĺ' => 'l', 'Ļ' => 'L',
369
+ 'ļ' => 'l', 'Ľ' => 'L',
370
+ 'ľ' => 'l', 'Ŀ' => 'L',
371
+ 'ŀ' => 'l', 'Ł' => 'L',
372
+ 'ł' => 'l', 'Ń' => 'N',
373
+ 'ń' => 'n', 'Ņ' => 'N',
374
+ 'ņ' => 'n', 'Ň' => 'N',
375
+ 'ň' => 'n', 'ʼn' => 'n',
376
+ 'Ŋ' => 'N', 'ŋ' => 'n',
377
+ 'Ō' => 'O', 'ō' => 'o',
378
+ 'Ŏ' => 'O', 'ŏ' => 'o',
379
+ 'Ő' => 'O', 'ő' => 'o',
380
+ 'Œ' => 'OE','œ' => 'oe',
381
+ 'Ŕ' => 'R','ŕ' => 'r',
382
+ 'Ŗ' => 'R','ŗ' => 'r',
383
+ 'Ř' => 'R','ř' => 'r',
384
+ 'Ś' => 'S','ś' => 's',
385
+ 'Ŝ' => 'S','ŝ' => 's',
386
+ 'Ş' => 'S','ş' => 's',
387
+ 'Š' => 'S', 'š' => 's',
388
+ 'Ţ' => 'T', 'ţ' => 't',
389
+ 'Ť' => 'T', 'ť' => 't',
390
+ 'Ŧ' => 'T', 'ŧ' => 't',
391
+ 'Ũ' => 'U', 'ũ' => 'u',
392
+ 'Ū' => 'U', 'ū' => 'u',
393
+ 'Ŭ' => 'U', 'ŭ' => 'u',
394
+ 'Ů' => 'U', 'ů' => 'u',
395
+ 'Ű' => 'U', 'ű' => 'u',
396
+ 'Ų' => 'U', 'ų' => 'u',
397
+ 'Ŵ' => 'W', 'ŵ' => 'w',
398
+ 'Ŷ' => 'Y', 'ŷ' => 'y',
399
+ 'Ÿ' => 'Y', 'Ź' => 'Z',
400
+ 'ź' => 'z', 'Ż' => 'Z',
401
+ 'ż' => 'z', 'Ž' => 'Z',
402
+ 'ž' => 'z', 'ſ' => 's',
403
+ // Decompositions for Latin Extended-B
404
+ 'Ș' => 'S', 'ș' => 's',
405
+ 'Ț' => 'T', 'ț' => 't',
406
+ // Euro Sign
407
+ '€' => 'E',
408
+ // GBP (Pound) Sign
409
+ '£' => '',
410
+ // Vowels with diacritic (Vietnamese)
411
+ // unmarked
412
+ 'Ơ' => 'O', 'ơ' => 'o',
413
+ 'Ư' => 'U', 'ư' => 'u',
414
+ // grave accent
415
+ 'Ầ' => 'A', 'ầ' => 'a',
416
+ 'Ằ' => 'A', 'ằ' => 'a',
417
+ 'Ề' => 'E', 'ề' => 'e',
418
+ 'Ồ' => 'O', 'ồ' => 'o',
419
+ 'Ờ' => 'O', 'ờ' => 'o',
420
+ 'Ừ' => 'U', 'ừ' => 'u',
421
+ 'Ỳ' => 'Y', 'ỳ' => 'y',
422
+ // hook
423
+ 'Ả' => 'A', 'ả' => 'a',
424
+ 'Ẩ' => 'A', 'ẩ' => 'a',
425
+ 'Ẳ' => 'A', 'ẳ' => 'a',
426
+ 'Ẻ' => 'E', 'ẻ' => 'e',
427
+ 'Ể' => 'E', 'ể' => 'e',
428
+ 'Ỉ' => 'I', 'ỉ' => 'i',
429
+ 'Ỏ' => 'O', 'ỏ' => 'o',
430
+ 'Ổ' => 'O', 'ổ' => 'o',
431
+ 'Ở' => 'O', 'ở' => 'o',
432
+ 'Ủ' => 'U', 'ủ' => 'u',
433
+ 'Ử' => 'U', 'ử' => 'u',
434
+ 'Ỷ' => 'Y', 'ỷ' => 'y',
435
+ // tilde
436
+ 'Ẫ' => 'A', 'ẫ' => 'a',
437
+ 'Ẵ' => 'A', 'ẵ' => 'a',
438
+ 'Ẽ' => 'E', 'ẽ' => 'e',
439
+ 'Ễ' => 'E', 'ễ' => 'e',
440
+ 'Ỗ' => 'O', 'ỗ' => 'o',
441
+ 'Ỡ' => 'O', 'ỡ' => 'o',
442
+ 'Ữ' => 'U', 'ữ' => 'u',
443
+ 'Ỹ' => 'Y', 'ỹ' => 'y',
444
+ // acute accent
445
+ 'Ấ' => 'A', 'ấ' => 'a',
446
+ 'Ắ' => 'A', 'ắ' => 'a',
447
+ 'Ế' => 'E', 'ế' => 'e',
448
+ 'Ố' => 'O', 'ố' => 'o',
449
+ 'Ớ' => 'O', 'ớ' => 'o',
450
+ 'Ứ' => 'U', 'ứ' => 'u',
451
+ // dot below
452
+ 'Ạ' => 'A', 'ạ' => 'a',
453
+ 'Ậ' => 'A', 'ậ' => 'a',
454
+ 'Ặ' => 'A', 'ặ' => 'a',
455
+ 'Ẹ' => 'E', 'ẹ' => 'e',
456
+ 'Ệ' => 'E', 'ệ' => 'e',
457
+ 'Ị' => 'I', 'ị' => 'i',
458
+ 'Ọ' => 'O', 'ọ' => 'o',
459
+ 'Ộ' => 'O', 'ộ' => 'o',
460
+ 'Ợ' => 'O', 'ợ' => 'o',
461
+ 'Ụ' => 'U', 'ụ' => 'u',
462
+ 'Ự' => 'U', 'ự' => 'u',
463
+ 'Ỵ' => 'Y', 'ỵ' => 'y',
464
+ // Vowels with diacritic (Chinese, Hanyu Pinyin)
465
+ 'ɑ' => 'a',
466
+ // macron
467
+ 'Ǖ' => 'U', 'ǖ' => 'u',
468
+ // acute accent
469
+ 'Ǘ' => 'U', 'ǘ' => 'u',
470
+ // caron
471
+ 'Ǎ' => 'A', 'ǎ' => 'a',
472
+ 'Ǐ' => 'I', 'ǐ' => 'i',
473
+ 'Ǒ' => 'O', 'ǒ' => 'o',
474
+ 'Ǔ' => 'U', 'ǔ' => 'u',
475
+ 'Ǚ' => 'U', 'ǚ' => 'u',
476
+ // grave accent
477
+ 'Ǜ' => 'U', 'ǜ' => 'u',
478
+ );
479
+
480
+ // Used for locale-specific rules
481
+ $trp = TRP_Translate_Press::get_trp_instance();
482
+ $trp_settings = $trp->get_component( 'settings' );
483
+ $settings = $trp_settings->get_settings();
484
+
485
+ $default_language= $settings["default-language"];
486
+ $locale = $default_language;
487
+
488
+ if ( 'de_DE' == $locale || 'de_DE_formal' == $locale || 'de_CH' == $locale || 'de_CH_informal' == $locale ) {
489
+ $chars[ 'Ä' ] = 'Ae';
490
+ $chars[ 'ä' ] = 'ae';
491
+ $chars[ 'Ö' ] = 'Oe';
492
+ $chars[ 'ö' ] = 'oe';
493
+ $chars[ 'Ü' ] = 'Ue';
494
+ $chars[ 'ü' ] = 'ue';
495
+ $chars[ 'ß' ] = 'ss';
496
+ } elseif ( 'da_DK' === $locale ) {
497
+ $chars[ 'Æ' ] = 'Ae';
498
+ $chars[ 'æ' ] = 'ae';
499
+ $chars[ 'Ø' ] = 'Oe';
500
+ $chars[ 'ø' ] = 'oe';
501
+ $chars[ 'Å' ] = 'Aa';
502
+ $chars[ 'å' ] = 'aa';
503
+ } elseif ( 'ca' === $locale ) {
504
+ $chars[ 'l·l' ] = 'll';
505
+ } elseif ( 'sr_RS' === $locale || 'bs_BA' === $locale ) {
506
+ $chars[ 'Đ' ] = 'DJ';
507
+ $chars[ 'đ' ] = 'dj';
508
+ }
509
+
510
+ $string = strtr($string, $chars);
511
+ } else {
512
+ $chars = array();
513
+ // Assume ISO-8859-1 if not UTF-8
514
+ $chars['in'] = "\x80\x83\x8a\x8e\x9a\x9e"
515
+ ."\x9f\xa2\xa5\xb5\xc0\xc1\xc2"
516
+ ."\xc3\xc4\xc5\xc7\xc8\xc9\xca"
517
+ ."\xcb\xcc\xcd\xce\xcf\xd1\xd2"
518
+ ."\xd3\xd4\xd5\xd6\xd8\xd9\xda"
519
+ ."\xdb\xdc\xdd\xe0\xe1\xe2\xe3"
520
+ ."\xe4\xe5\xe7\xe8\xe9\xea\xeb"
521
+ ."\xec\xed\xee\xef\xf1\xf2\xf3"
522
+ ."\xf4\xf5\xf6\xf8\xf9\xfa\xfb"
523
+ ."\xfc\xfd\xff";
524
+
525
+ $chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy";
526
+
527
+ $string = strtr($string, $chars['in'], $chars['out']);
528
+ $double_chars = array();
529
+ $double_chars['in'] = array("\x8c", "\x9c", "\xc6", "\xd0", "\xde", "\xdf", "\xe6", "\xf0", "\xfe");
530
+ $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th');
531
+ $string = str_replace($double_chars['in'], $double_chars['out'], $string);
532
+ }
533
+
534
+ return $string;
535
+ };
index.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: TranslatePress - Multilingual
4
Plugin URI: https://translatepress.com/
5
Description: Experience a better way of translating your WordPress site, with full support for WooCommerce and site builders.
6
- Version: 1.3.0
7
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
Author URI: https://cozmoslabs.com/
9
Text Domain: translatepress-multilingual
3
Plugin Name: TranslatePress - Multilingual
4
Plugin URI: https://translatepress.com/
5
Description: Experience a better way of translating your WordPress site, with full support for WooCommerce and site builders.
6
+ Version: 1.3.1
7
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
Author URI: https://cozmoslabs.com/
9
Text Domain: translatepress-multilingual
languages/translatepress-multilingual.catalog.php CHANGED
@@ -77,8 +77,8 @@
77
<?php __("Google Translate", "translatepress-multilingual"); ?>
78
<?php __("Enable or disable the automatic translation of the site with Google Translate. Only untranslated strings will receive a translation.<br>You can later edit these automatic translations.<br>Note: Not all languages support automatic translation. Please consult the <a href=\"https://cloud.google.com/translate/docs/languages\" target=\"_blank\" title=\"Automatic translation supported languages.\">supported languages list</a>. ", "translatepress-multilingual"); ?>
79
<?php __("Google Translate API Key", "translatepress-multilingual"); ?>
80
- <?php __("Test api key.", "translatepress-multilingual"); ?>
81
- <?php __("Visit this <a href=\"https://support.google.com/cloud/answer/6158862\" target=\"_blank\">link</a> to see how you can set up an API key. ", "translatepress-multilingual"); ?>
82
<?php __("Language Switcher", "translatepress-multilingual"); ?>
83
<?php __("Shortcode ", "translatepress-multilingual"); ?>
84
<?php __("Use shortcode on any page or widget.", "translatepress-multilingual"); ?>
77
<?php __("Google Translate", "translatepress-multilingual"); ?>
78
<?php __("Enable or disable the automatic translation of the site with Google Translate. Only untranslated strings will receive a translation.<br>You can later edit these automatic translations.<br>Note: Not all languages support automatic translation. Please consult the <a href=\"https://cloud.google.com/translate/docs/languages\" target=\"_blank\" title=\"Automatic translation supported languages.\">supported languages list</a>. ", "translatepress-multilingual"); ?>
79
<?php __("Google Translate API Key", "translatepress-multilingual"); ?>
80
+ <?php __("Test api key", "translatepress-multilingual"); ?>
81
+ <?php __("Visit this <a href=\"https://cloud.google.com/docs/authentication/api-keys\" target=\"_blank\">link</a> to see how you can set up an API key. ", "translatepress-multilingual"); ?>
82
<?php __("Language Switcher", "translatepress-multilingual"); ?>
83
<?php __("Shortcode ", "translatepress-multilingual"); ?>
84
<?php __("Use shortcode on any page or widget.", "translatepress-multilingual"); ?>
languages/translatepress-multilingual.pot CHANGED
@@ -21,7 +21,7 @@ msgstr ""
21
msgid "Limit this menu item to the following languages"
22
msgstr ""
23
24
- #: ../tp-add-on-seo-pack/class-seo-pack.php:154
25
msgid "The Yoast SEO Sitemaps will now contain the default language slug: example.com/en/sitemap_index.xml <br/> This works perfectly, just take it into account when you submit the sitemap to Google."
26
msgstr ""
27
@@ -205,35 +205,35 @@ msgstr ""
205
msgid "Security check"
206
msgstr ""
207
208
- #: ../translatepress/includes/class-translation-render.php:159
209
msgid "Description"
210
msgstr ""
211
212
- #: ../translatepress/includes/class-translation-render.php:165
213
msgid "OG Title"
214
msgstr ""
215
216
- #: ../translatepress/includes/class-translation-render.php:171
217
msgid "OG Site Name"
218
msgstr ""
219
220
- #: ../translatepress/includes/class-translation-render.php:177
221
msgid "OG Description"
222
msgstr ""
223
224
- #: ../translatepress/includes/class-translation-render.php:183
225
msgid "Twitter Title"
226
msgstr ""
227
228
- #: ../translatepress/includes/class-translation-render.php:189
229
msgid "Twitter Description"
230
msgstr ""
231
232
- #: ../translatepress/includes/class-translation-render.php:195
233
msgid "Post Slug"
234
msgstr ""
235
236
- #: ../translatepress/includes/class-translation-render.php:199
237
msgid "Page Title"
238
msgstr ""
239
@@ -326,11 +326,11 @@ msgid "Google Translate API Key"
326
msgstr ""
327
328
#: ../translatepress/partials/main-settings-page.php:92
329
- msgid "Test api key."
330
msgstr ""
331
332
#: ../translatepress/partials/main-settings-page.php:94
333
- msgid "Visit this <a href=\"https://support.google.com/cloud/answer/6158862\" target=\"_blank\">link</a> to see how you can set up an API key. "
334
msgstr ""
335
336
#: ../translatepress/partials/main-settings-page.php:101
21
msgid "Limit this menu item to the following languages"
22
msgstr ""
23
24
+ #: ../tp-add-on-seo-pack/class-seo-pack.php:155
25
msgid "The Yoast SEO Sitemaps will now contain the default language slug: example.com/en/sitemap_index.xml <br/> This works perfectly, just take it into account when you submit the sitemap to Google."
26
msgstr ""
27
205
msgid "Security check"
206
msgstr ""
207
208
+ #: ../translatepress/includes/class-translation-render.php:163
209
msgid "Description"
210
msgstr ""
211
212
+ #: ../translatepress/includes/class-translation-render.php:169
213
msgid "OG Title"
214
msgstr ""
215
216
+ #: ../translatepress/includes/class-translation-render.php:175
217
msgid "OG Site Name"
218
msgstr ""
219
220
+ #: ../translatepress/includes/class-translation-render.php:181
221
msgid "OG Description"
222
msgstr ""
223
224
+ #: ../translatepress/includes/class-translation-render.php:187
225
msgid "Twitter Title"
226
msgstr ""
227
228
+ #: ../translatepress/includes/class-translation-render.php:193
229
msgid "Twitter Description"
230
msgstr ""
231
232
+ #: ../translatepress/includes/class-translation-render.php:199
233
msgid "Post Slug"
234
msgstr ""
235
236
+ #: ../translatepress/includes/class-translation-render.php:203
237
msgid "Page Title"
238
msgstr ""
239
326
msgstr ""
327
328
#: ../translatepress/partials/main-settings-page.php:92
329
+ msgid "Test api key"
330
msgstr ""
331
332
#: ../translatepress/partials/main-settings-page.php:94
333
+ msgid "Visit this <a href=\"https://cloud.google.com/docs/authentication/api-keys\" target=\"_blank\">link</a> to see how you can set up an API key. "
334
msgstr ""
335
336
#: ../translatepress/partials/main-settings-page.php:101
partials/main-settings-page.php CHANGED
@@ -89,9 +89,9 @@
89
<th scope="row"><?php _e( 'Google Translate API Key', 'translatepress-multilingual' ); ?> </th>
90
<td>
91
<input type="text" id="trp-g-translate-key" class="trp-text-input" name="trp_settings[g-translate-key]" value="<?php if( !empty( $this->settings['g-translate-key'] ) ) echo esc_attr( $this->settings['g-translate-key']);?>"/>
92
- <?php if( !empty( $this->settings['g-translate-key'] ) ) echo '<a href="'.admin_url( 'admin.php?page=trp_test_google_key_page' ).'">'.__( "Test api key.", 'translatepress-multilingual' );'.</a>'; ?>
93
<p class="description">
94
- <?php _e( 'Visit this <a href="https://support.google.com/cloud/answer/6158862" target="_blank">link</a> to see how you can set up an API key. ', 'translatepress-multilingual' ); ?>
95
</p>
96
</td>
97
89
<th scope="row"><?php _e( 'Google Translate API Key', 'translatepress-multilingual' ); ?> </th>
90
<td>
91
<input type="text" id="trp-g-translate-key" class="trp-text-input" name="trp_settings[g-translate-key]" value="<?php if( !empty( $this->settings['g-translate-key'] ) ) echo esc_attr( $this->settings['g-translate-key']);?>"/>
92
+ <?php if( !empty( $this->settings['g-translate-key'] ) ) echo '<a href="'.admin_url( 'admin.php?page=trp_test_google_key_page' ).'">'.__( "Test api key", 'translatepress-multilingual' ).'</a>'; ?>
93
<p class="description">
94
+ <?php _e( 'Visit this <a href="https://cloud.google.com/docs/authentication/api-keys" target="_blank">link</a> to see how you can set up an API key. ', 'translatepress-multilingual' ); ?>
95
</p>
96
</td>
97
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.cozmoslabs.com/
4
Tags: translate, translation, multilingual, automatic translation, bilingual, front-end translation, google translate, language
5
Requires at least: 3.1.0
6
Tested up to: 4.9.8
7
- Stable tag: 1.3.0
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -118,6 +118,16 @@ For more information please check out [TranslatePress documentation](https://tra
118
6. Menu Language Switcher
119
120
== Changelog ==
121
= 1.3.0 =
122
* Added support for word trim when the default language is japanese, chinese or thai.
123
* Exluded wp_trim_words funtion from our gettext filter to prevent som issues
4
Tags: translate, translation, multilingual, automatic translation, bilingual, front-end translation, google translate, language
5
Requires at least: 3.1.0
6
Tested up to: 4.9.8
7
+ Stable tag: 1.3.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
118
6. Menu Language Switcher
119
120
== Changelog ==
121
+ = 1.3.1 =
122
+ * Fixed Woocommerce translation of permalinks
123
+ * Added support for remove_accents to be based on default language when called from the sanitize_title function
124
+ * Added support for translating JSON found in custom ajax request
125
+ * Added better REST compatibility
126
+ * Added compatibility for Peepso plugin
127
+ * Fixed TranslatePress roken link to google translate set up api key on settings page
128
+ * Corrected flags for Arabic and Bengali languages
129
+ * Fixed issue with multiple slashes being added when the URL had extra get parameters
130
+
131
= 1.3.0 =
132
* Added support for word trim when the default language is japanese, chinese or thai.
133
* Exluded wp_trim_words funtion from our gettext filter to prevent som issues