Version Description
- Added a conditional language shortcode: [trp_language language="en_US"] English only content [/trp_language]
- Create link to test out Google API key.
- Improvements to Woocommerce compatibility
- Fixed json_encode error that was causing js errors
- Changed 'template_include' hook priority to improve compatibility with some themes
Download this release
Release Info
Developer | madalin.ungureanu |
Plugin | TranslatePress – Translate Multilingual sites |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
- assets/css/trp-preview-iframe-style.css +4 -0
- class-translate-press.php +3 -2
- includes/class-settings.php +9 -1
- includes/class-translation-manager.php +13 -10
- includes/class-translation-render.php +3 -3
- includes/functions.php +47 -0
- includes/shortcodes.php +23 -0
- index.php +1 -1
- partials/main-settings-page.php +1 -0
- partials/test-google-key-settings-page.php +41 -0
- readme.txt +18 -9
assets/css/trp-preview-iframe-style.css
CHANGED
@@ -57,4 +57,8 @@ span.trp-edit-translation svg {
|
|
57 |
|
58 |
*[data-trpgettextoriginal] span.trp-edit-translation:hover, .trpgettext-wrap span.trp-edit-translation:hover{
|
59 |
background: #00ce44 !important;
|
|
|
|
|
|
|
|
|
60 |
}
|
57 |
|
58 |
*[data-trpgettextoriginal] span.trp-edit-translation:hover, .trpgettext-wrap span.trp-edit-translation:hover{
|
59 |
background: #00ce44 !important;
|
60 |
+
}
|
61 |
+
|
62 |
+
translate-press{
|
63 |
+
pointer-events: all;
|
64 |
}
|
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' );
|
42 |
-
define( 'TRP_PLUGIN_VERSION', '1.0.
|
43 |
|
44 |
$this->load_dependencies();
|
45 |
$this->initialize_components();
|
@@ -74,6 +74,7 @@ class TRP_Translate_Press{
|
|
74 |
require_once TRP_PLUGIN_DIR . 'includes/class-url-converter.php';
|
75 |
require_once TRP_PLUGIN_DIR . 'includes/functions.php';
|
76 |
require_once TRP_PLUGIN_DIR . 'assets/lib/simplehtmldom/simple_html_dom.php';
|
|
|
77 |
}
|
78 |
|
79 |
/**
|
@@ -137,7 +138,7 @@ class TRP_Translate_Press{
|
|
137 |
|
138 |
|
139 |
$this->loader->add_action( 'trp_head', $this->translation_manager, 'enqueue_scripts_and_styles' );
|
140 |
-
$this->loader->add_filter( 'template_include', $this->translation_manager, 'translation_editor',
|
141 |
$this->loader->add_action( 'wp_enqueue_scripts', $this->translation_manager, 'enqueue_preview_scripts_and_styles' );
|
142 |
$this->loader->add_action( 'admin_bar_menu', $this->translation_manager, 'add_shortcut_to_translation_editor', 90, 1 );
|
143 |
$this->loader->add_filter( 'show_admin_bar', $this->translation_manager, 'hide_admin_bar_when_in_editor', 90 );
|
39 |
define( 'TRP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
40 |
define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
41 |
define( 'TRP_PLUGIN_SLUG', 'translatepress' );
|
42 |
+
define( 'TRP_PLUGIN_VERSION', '1.0.3' );
|
43 |
|
44 |
$this->load_dependencies();
|
45 |
$this->initialize_components();
|
74 |
require_once TRP_PLUGIN_DIR . 'includes/class-url-converter.php';
|
75 |
require_once TRP_PLUGIN_DIR . 'includes/functions.php';
|
76 |
require_once TRP_PLUGIN_DIR . 'assets/lib/simplehtmldom/simple_html_dom.php';
|
77 |
+
require_once TRP_PLUGIN_DIR . 'includes/shortcodes.php';
|
78 |
}
|
79 |
|
80 |
/**
|
138 |
|
139 |
|
140 |
$this->loader->add_action( 'trp_head', $this->translation_manager, 'enqueue_scripts_and_styles' );
|
141 |
+
$this->loader->add_filter( 'template_include', $this->translation_manager, 'translation_editor', 9999 );
|
142 |
$this->loader->add_action( 'wp_enqueue_scripts', $this->translation_manager, 'enqueue_preview_scripts_and_styles' );
|
143 |
$this->loader->add_action( 'admin_bar_menu', $this->translation_manager, 'add_shortcut_to_translation_editor', 90, 1 );
|
144 |
$this->loader->add_filter( 'show_admin_bar', $this->translation_manager, 'hide_admin_bar_when_in_editor', 90 );
|
includes/class-settings.php
CHANGED
@@ -67,6 +67,7 @@ class TRP_Settings{
|
|
67 |
public function register_menu_page(){
|
68 |
add_options_page( 'TranslatePress', 'TranslatePress', apply_filters( 'trp_settings_capability', 'manage_options' ), 'translate-press', array( $this, 'settings_page_content' ) );
|
69 |
add_submenu_page( 'TRPHidden', 'TranslatePress Addons', 'TRPHidden', 'manage_options', 'trp_addons_page', array($this, 'addons_page_content') );
|
|
|
70 |
}
|
71 |
|
72 |
/**
|
@@ -88,6 +89,13 @@ class TRP_Settings{
|
|
88 |
require_once TRP_PLUGIN_DIR . 'partials/addons-settings-page.php';
|
89 |
}
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
/**
|
92 |
* Register settings option.
|
93 |
*/
|
@@ -106,7 +114,7 @@ class TRP_Settings{
|
|
106 |
public function sanitize_settings( $settings ){
|
107 |
if ( ! $this->trp_query ) {
|
108 |
$trp = TRP_Translate_Press::get_trp_instance();
|
109 |
-
$this->trp_query = $trp->get_component( 'query' )
|
110 |
}
|
111 |
if ( ! $this->trp_languages ){
|
112 |
$trp = TRP_Translate_Press::get_trp_instance();
|
67 |
public function register_menu_page(){
|
68 |
add_options_page( 'TranslatePress', 'TranslatePress', apply_filters( 'trp_settings_capability', 'manage_options' ), 'translate-press', array( $this, 'settings_page_content' ) );
|
69 |
add_submenu_page( 'TRPHidden', 'TranslatePress Addons', 'TRPHidden', 'manage_options', 'trp_addons_page', array($this, 'addons_page_content') );
|
70 |
+
add_submenu_page( 'TRPHidden', 'TranslatePress Test Google API Key', 'TRPHidden', 'manage_options', 'trp_test_google_key_page', array($this, 'test_google_key_page_content') );
|
71 |
}
|
72 |
|
73 |
/**
|
89 |
require_once TRP_PLUGIN_DIR . 'partials/addons-settings-page.php';
|
90 |
}
|
91 |
|
92 |
+
/**
|
93 |
+
* Addons page content.
|
94 |
+
*/
|
95 |
+
public function test_google_key_page_content(){
|
96 |
+
require_once TRP_PLUGIN_DIR . 'partials/test-google-key-settings-page.php';
|
97 |
+
}
|
98 |
+
|
99 |
/**
|
100 |
* Register settings option.
|
101 |
*/
|
114 |
public function sanitize_settings( $settings ){
|
115 |
if ( ! $this->trp_query ) {
|
116 |
$trp = TRP_Translate_Press::get_trp_instance();
|
117 |
+
$this->trp_query = $trp->get_component( 'query' );
|
118 |
}
|
119 |
if ( ! $this->trp_languages ){
|
120 |
$trp = TRP_Translate_Press::get_trp_instance();
|
includes/class-translation-manager.php
CHANGED
@@ -152,7 +152,7 @@ class TRP_Translation_Manager{
|
|
152 |
|
153 |
$trp = TRP_Translate_Press::get_trp_instance();
|
154 |
if ( ! $this->trp_query ) {
|
155 |
-
$this->trp_query = $trp->get_component( 'query' )
|
156 |
}
|
157 |
if ( ! $this->slug_manager ) {
|
158 |
$this->slug_manager = $trp->get_component('slug_manager');
|
@@ -206,7 +206,7 @@ class TRP_Translation_Manager{
|
|
206 |
}
|
207 |
}
|
208 |
|
209 |
-
echo
|
210 |
}
|
211 |
|
212 |
}
|
@@ -231,7 +231,7 @@ class TRP_Translation_Manager{
|
|
231 |
|
232 |
$trp = TRP_Translate_Press::get_trp_instance();
|
233 |
if ( ! $this->trp_query ) {
|
234 |
-
$this->trp_query = $trp->get_component( 'query' )
|
235 |
}
|
236 |
|
237 |
/* build the current language dictionary */
|
@@ -306,7 +306,7 @@ class TRP_Translation_Manager{
|
|
306 |
}
|
307 |
}
|
308 |
|
309 |
-
die(
|
310 |
|
311 |
}
|
312 |
}
|
@@ -342,7 +342,7 @@ class TRP_Translation_Manager{
|
|
342 |
|
343 |
if ( ! $this->trp_query ) {
|
344 |
$trp = TRP_Translate_Press::get_trp_instance();
|
345 |
-
$this->trp_query = $trp->get_component( 'query' )
|
346 |
}
|
347 |
|
348 |
foreach( $update_strings as $language => $update_string_array ) {
|
@@ -378,7 +378,7 @@ class TRP_Translation_Manager{
|
|
378 |
|
379 |
if ( ! $this->trp_query ) {
|
380 |
$trp = TRP_Translate_Press::get_trp_instance();
|
381 |
-
$this->trp_query = $trp->get_component( 'query' )
|
382 |
}
|
383 |
|
384 |
foreach( $update_strings as $language => $update_string_array ) {
|
@@ -475,7 +475,7 @@ class TRP_Translation_Manager{
|
|
475 |
global $trp_translated_gettext_texts;
|
476 |
if (!$this->trp_query) {
|
477 |
$trp = TRP_Translate_Press::get_trp_instance();
|
478 |
-
$this->trp_query = $trp->get_component('query')
|
479 |
}
|
480 |
|
481 |
$strings = $this->trp_query->get_all_gettext_strings($TRP_LANGUAGE);
|
@@ -490,7 +490,10 @@ class TRP_Translation_Manager{
|
|
490 |
public function apply_gettext_filter_on_frontend(){
|
491 |
/* on ajax hooks from frontend that have the init hook ( we found WooCommerce has it ) apply it earlier */
|
492 |
if( $this::is_ajax_on_frontend() ){
|
493 |
-
add_action( '
|
|
|
|
|
|
|
494 |
}//otherwise start from the wp_head hook
|
495 |
else{
|
496 |
add_action( 'wp_head', array( $this, 'apply_gettext_filter' ), 100 );
|
@@ -589,7 +592,7 @@ class TRP_Translation_Manager{
|
|
589 |
/* initiate trp query object */
|
590 |
if (!$this->trp_query) {
|
591 |
$trp = TRP_Translate_Press::get_trp_instance();
|
592 |
-
$this->trp_query = $trp->get_component('query')
|
593 |
}
|
594 |
|
595 |
if( !isset( $trp_all_gettext_texts ) )
|
@@ -740,7 +743,7 @@ class TRP_Translation_Manager{
|
|
740 |
|
741 |
if (!$this->trp_query) {
|
742 |
$trp = TRP_Translate_Press::get_trp_instance();
|
743 |
-
$this->trp_query = $trp->get_component('query')
|
744 |
}
|
745 |
|
746 |
$this->trp_query->update_gettext_strings( $trp_gettext_strings_for_machine_translation, $TRP_LANGUAGE );
|
152 |
|
153 |
$trp = TRP_Translate_Press::get_trp_instance();
|
154 |
if ( ! $this->trp_query ) {
|
155 |
+
$this->trp_query = $trp->get_component( 'query' );
|
156 |
}
|
157 |
if ( ! $this->slug_manager ) {
|
158 |
$this->slug_manager = $trp->get_component('slug_manager');
|
206 |
}
|
207 |
}
|
208 |
|
209 |
+
echo trp_safe_json_encode( $dictionaries );
|
210 |
}
|
211 |
|
212 |
}
|
231 |
|
232 |
$trp = TRP_Translate_Press::get_trp_instance();
|
233 |
if ( ! $this->trp_query ) {
|
234 |
+
$this->trp_query = $trp->get_component( 'query' );
|
235 |
}
|
236 |
|
237 |
/* build the current language dictionary */
|
306 |
}
|
307 |
}
|
308 |
|
309 |
+
die( trp_safe_json_encode( $dictionaries ) );
|
310 |
|
311 |
}
|
312 |
}
|
342 |
|
343 |
if ( ! $this->trp_query ) {
|
344 |
$trp = TRP_Translate_Press::get_trp_instance();
|
345 |
+
$this->trp_query = $trp->get_component( 'query' );
|
346 |
}
|
347 |
|
348 |
foreach( $update_strings as $language => $update_string_array ) {
|
378 |
|
379 |
if ( ! $this->trp_query ) {
|
380 |
$trp = TRP_Translate_Press::get_trp_instance();
|
381 |
+
$this->trp_query = $trp->get_component( 'query' );
|
382 |
}
|
383 |
|
384 |
foreach( $update_strings as $language => $update_string_array ) {
|
475 |
global $trp_translated_gettext_texts;
|
476 |
if (!$this->trp_query) {
|
477 |
$trp = TRP_Translate_Press::get_trp_instance();
|
478 |
+
$this->trp_query = $trp->get_component('query');
|
479 |
}
|
480 |
|
481 |
$strings = $this->trp_query->get_all_gettext_strings($TRP_LANGUAGE);
|
490 |
public function apply_gettext_filter_on_frontend(){
|
491 |
/* on ajax hooks from frontend that have the init hook ( we found WooCommerce has it ) apply it earlier */
|
492 |
if( $this::is_ajax_on_frontend() ){
|
493 |
+
add_action( 'wp_loaded', array( $this, 'apply_gettext_filter' ) );
|
494 |
+
}
|
495 |
+
elseif( class_exists( 'WooCommerce' ) ){
|
496 |
+
add_action( 'wp_loaded', array( $this, 'apply_gettext_filter' ), 19 );
|
497 |
}//otherwise start from the wp_head hook
|
498 |
else{
|
499 |
add_action( 'wp_head', array( $this, 'apply_gettext_filter' ), 100 );
|
592 |
/* initiate trp query object */
|
593 |
if (!$this->trp_query) {
|
594 |
$trp = TRP_Translate_Press::get_trp_instance();
|
595 |
+
$this->trp_query = $trp->get_component('query');
|
596 |
}
|
597 |
|
598 |
if( !isset( $trp_all_gettext_texts ) )
|
743 |
|
744 |
if (!$this->trp_query) {
|
745 |
$trp = TRP_Translate_Press::get_trp_instance();
|
746 |
+
$this->trp_query = $trp->get_component('query');
|
747 |
}
|
748 |
|
749 |
$this->trp_query->update_gettext_strings( $trp_gettext_strings_for_machine_translation, $TRP_LANGUAGE );
|
includes/class-translation-render.php
CHANGED
@@ -223,7 +223,7 @@ class TRP_Translation_Render{
|
|
223 |
}
|
224 |
}
|
225 |
}
|
226 |
-
return
|
227 |
}
|
228 |
}
|
229 |
|
@@ -352,7 +352,7 @@ class TRP_Translation_Render{
|
|
352 |
|
353 |
if ( ! $this->trp_query ) {
|
354 |
$trp = TRP_Translate_Press::get_trp_instance();
|
355 |
-
$this->trp_query = $trp->get_component( 'query' )
|
356 |
}
|
357 |
|
358 |
$translated_strings = $this->process_strings( $translateable_strings, $language_code );
|
@@ -547,7 +547,7 @@ class TRP_Translation_Render{
|
|
547 |
|
548 |
if ( ! $this->trp_query ) {
|
549 |
$trp = TRP_Translate_Press::get_trp_instance();
|
550 |
-
$this->trp_query = $trp->get_component( 'query' )
|
551 |
}
|
552 |
|
553 |
// get existing translations
|
223 |
}
|
224 |
}
|
225 |
}
|
226 |
+
return trp_safe_json_encode($json_array);
|
227 |
}
|
228 |
}
|
229 |
|
352 |
|
353 |
if ( ! $this->trp_query ) {
|
354 |
$trp = TRP_Translate_Press::get_trp_instance();
|
355 |
+
$this->trp_query = $trp->get_component( 'query' );
|
356 |
}
|
357 |
|
358 |
$translated_strings = $this->process_strings( $translateable_strings, $language_code );
|
547 |
|
548 |
if ( ! $this->trp_query ) {
|
549 |
$trp = TRP_Translate_Press::get_trp_instance();
|
550 |
+
$this->trp_query = $trp->get_component( 'query' );
|
551 |
}
|
552 |
|
553 |
// get existing translations
|
includes/functions.php
CHANGED
@@ -9,4 +9,51 @@ function trp_the_language_switcher(){
|
|
9 |
$trp = TRP_Translate_Press::get_trp_instance();
|
10 |
$language_switcher = $trp->get_component( 'language_switcher' );
|
11 |
echo $language_switcher->language_switcher();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
}
|
9 |
$trp = TRP_Translate_Press::get_trp_instance();
|
10 |
$language_switcher = $trp->get_component( 'language_switcher' );
|
11 |
echo $language_switcher->language_switcher();
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Wrapper function for json_encode to eliminate possible UTF8 special character errors
|
16 |
+
* @param $value
|
17 |
+
* @return mixed|string|void
|
18 |
+
*/
|
19 |
+
function trp_safe_json_encode($value){
|
20 |
+
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
|
21 |
+
$encoded = json_encode($value, JSON_PRETTY_PRINT);
|
22 |
+
} else {
|
23 |
+
$encoded = json_encode($value);
|
24 |
+
}
|
25 |
+
switch (json_last_error()) {
|
26 |
+
case JSON_ERROR_NONE:
|
27 |
+
return $encoded;
|
28 |
+
case JSON_ERROR_DEPTH:
|
29 |
+
return 'Maximum stack depth exceeded'; // or trigger_error() or throw new Exception()
|
30 |
+
case JSON_ERROR_STATE_MISMATCH:
|
31 |
+
return 'Underflow or the modes mismatch'; // or trigger_error() or throw new Exception()
|
32 |
+
case JSON_ERROR_CTRL_CHAR:
|
33 |
+
return 'Unexpected control character found';
|
34 |
+
case JSON_ERROR_SYNTAX:
|
35 |
+
return 'Syntax error, malformed JSON'; // or trigger_error() or throw new Exception()
|
36 |
+
case JSON_ERROR_UTF8:
|
37 |
+
$clean = trp_utf8ize($value);
|
38 |
+
return trp_safe_json_encode($clean);
|
39 |
+
default:
|
40 |
+
return 'Unknown error'; // or trigger_error() or throw new Exception()
|
41 |
+
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Helper function for trp_safe_json_encode that helps eliminate utf8 json encode errors
|
47 |
+
* @param $mixed
|
48 |
+
* @return array|string
|
49 |
+
*/
|
50 |
+
function trp_utf8ize($mixed) {
|
51 |
+
if (is_array($mixed)) {
|
52 |
+
foreach ($mixed as $key => $value) {
|
53 |
+
$mixed[$key] = trp_utf8ize($value);
|
54 |
+
}
|
55 |
+
} else if (is_string ($mixed)) {
|
56 |
+
return utf8_encode($mixed);
|
57 |
+
}
|
58 |
+
return $mixed;
|
59 |
}
|
includes/shortcodes.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// add conditional language shortcode
|
3 |
+
add_shortcode( 'trp_language', 'trp_language_content');
|
4 |
+
|
5 |
+
/* ---------------------------------------------------------------------------
|
6 |
+
* Shortcode [trp_language language="en_EN"] [/trp_language]
|
7 |
+
* --------------------------------------------------------------------------- */
|
8 |
+
|
9 |
+
function trp_language_content( $attr, $content = null ){
|
10 |
+
extract(shortcode_atts(array(
|
11 |
+
'language' => '',
|
12 |
+
), $attr));
|
13 |
+
|
14 |
+
$current_language = get_locale();
|
15 |
+
|
16 |
+
if( $current_language == $language ){
|
17 |
+
$output = do_shortcode($content);
|
18 |
+
}else{
|
19 |
+
$output = "";
|
20 |
+
}
|
21 |
+
|
22 |
+
return $output;
|
23 |
+
}
|
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.0.
|
7 |
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
|
8 |
Author URI: https://cozmoslabs.com/
|
9 |
License: GPL2
|
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.0.3
|
7 |
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
|
8 |
Author URI: https://cozmoslabs.com/
|
9 |
License: GPL2
|
partials/main-settings-page.php
CHANGED
@@ -81,6 +81,7 @@
|
|
81 |
<th scope="row"><?php _e( 'Google Translate API Key', TRP_PLUGIN_SLUG ); ?> </th>
|
82 |
<td>
|
83 |
<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']);?>"/>
|
|
|
84 |
<p class="description">
|
85 |
<?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. ', TRP_PLUGIN_SLUG ); ?>
|
86 |
</p>
|
81 |
<th scope="row"><?php _e( 'Google Translate API Key', TRP_PLUGIN_SLUG ); ?> </th>
|
82 |
<td>
|
83 |
<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']);?>"/>
|
84 |
+
<?php if( !empty( $this->settings['g-translate-key'] ) ) echo '<a href="'.admin_url( 'admin.php?page=trp_test_google_key_page' ).'">'.__( "Test api key.", TRP_PLUGIN_SLUG );'.</a>'; ?>
|
85 |
<p class="description">
|
86 |
<?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. ', TRP_PLUGIN_SLUG ); ?>
|
87 |
</p>
|
partials/test-google-key-settings-page.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$translation_request = 'key='.$this->settings['g-translate-key'];
|
3 |
+
$translation_request .= '&source=en';
|
4 |
+
$translation_request .= '&target=es';
|
5 |
+
$translation_request .= '&q=about';
|
6 |
+
|
7 |
+
|
8 |
+
/* Due to url length restrictions we need so send a POST request faked as a GET request and send the strings in the body of the request and not in the URL */
|
9 |
+
$response = wp_remote_post( "https://www.googleapis.com/language/translate/v2", array(
|
10 |
+
'headers' => array( 'X-HTTP-Method-Override' => 'GET' ),//this fakes a GET request
|
11 |
+
'body' => $translation_request,
|
12 |
+
)
|
13 |
+
);
|
14 |
+
?>
|
15 |
+
<div id="trp-addons-page" class="wrap">
|
16 |
+
|
17 |
+
<h1> <?php _e( 'TranslatePress Settings', TRP_PLUGIN_SLUG );?></h1>
|
18 |
+
<?php do_action ( 'trp_settings_navigation_tabs' ); ?>
|
19 |
+
|
20 |
+
<div class="grid feat-header">
|
21 |
+
<div class="grid-cell">
|
22 |
+
<h2><?php _e('Google API Key from settings page:', TRP_PLUGIN_SLUG);?> <span style="font-family:monospace"><?php echo $this->settings['g-translate-key']; ?></span></h2>
|
23 |
+
|
24 |
+
<h3><?php _e('Response:', TRP_PLUGIN_SLUG);?></h3>
|
25 |
+
<pre>
|
26 |
+
<?php print_r( $response["response"] ); ?>
|
27 |
+
</pre>
|
28 |
+
<h3><?php _e('Response Body:', TRP_PLUGIN_SLUG);?></h3>
|
29 |
+
<pre>
|
30 |
+
<?php print_r( $response["body"] ); ?>
|
31 |
+
</pre>
|
32 |
+
|
33 |
+
<h3><?php _e('Entire Response From wp_remote_get():', TRP_PLUGIN_SLUG);?></h3>
|
34 |
+
<pre>
|
35 |
+
<?php print_r( $response ); ?>
|
36 |
+
</pre>
|
37 |
+
</div>
|
38 |
+
</div>
|
39 |
+
|
40 |
+
|
41 |
+
</div>
|
readme.txt
CHANGED
@@ -1,32 +1,34 @@
|
|
1 |
=== TranslatePress - Translate Multilingual sites ===
|
2 |
Contributors: cozmoslabs, razvan.mo, madalin.ungureanu, cristophor
|
3 |
Donate link: https://www.cozmoslabs.com/
|
4 |
-
Tags: translate, translation, multilingual, automatic translation, front-end translation, google translate
|
5 |
Requires at least: 3.1.0
|
6 |
Tested up to: 4.8.2
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
Easily translate your entire site and go multilingual, with full support for WooCommerce, complex themes and site builders. Integrates with Google Translate.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
**Experience a better way to translate your WordPress site and go multilingual, directly from the front-end using a friendly user interface.**
|
16 |
|
17 |
-
The interface allows you to translate the entire page at once, including output from shortcodes, forms and page builders. It also works out of the box with WooCommerce.
|
18 |
|
19 |
-
Built the WordPress way, TranslatePress - Multilingual is a GPL and self hosted plugin, meaning you'll own all your translations, forever.
|
20 |
|
21 |
-
= Multilingual Features =
|
22 |
|
23 |
-
* Translate all your website content directly from the front-end, in a friendly user interface.
|
|
|
24 |
* Live preview of your translated pages, as you edit your translations.
|
25 |
* Support for both manual and automatic translation (via Google Translate)
|
26 |
* Ability to translate dynamic strings (gettext) added by WordPress, plugins and themes.
|
27 |
* Integrates with Google Translate, allowing you to set up Automatic Translation using your own Google API key.
|
28 |
* Place language switchers anywhere using shortcode **[language-switcher]**, WP menu item or as a floating dropdown.
|
29 |
* Editorial control allowing you to publish your language only when all your translations are done
|
|
|
30 |
|
31 |
Note: this plugin uses the Google Translation API to translate the strings on your site. This feature can be enabled or disabled according to your preferences.
|
32 |
|
@@ -38,7 +40,7 @@ Users with administrator rights have access to the following translate settings:
|
|
38 |
* enable or disable url subdirectory for the default language
|
39 |
* enable automatic translation via Google Translate
|
40 |
|
41 |
-
= Powerful Add-ons =
|
42 |
|
43 |
TranslatePress - Multilingual has a range of premium [Add-ons](https://translatepress.com/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) that allow you to extend the power of the translation plugin:
|
44 |
|
@@ -81,7 +83,7 @@ All the translation are stored locally in your server's database.
|
|
81 |
|
82 |
TranslatePress - Multilingual works out of the box with WooCommerce, custom post types, complex themes and site builders, so you'll be able to translate any type of content.
|
83 |
|
84 |
-
= How is it different from other multilingual plugins? =
|
85 |
|
86 |
TranslatePress is easier to use and more intuitive altogether. No more switching between the editor, string translation interfaces or badly translated plugins. You can now translate the full page content directly from the front-end.
|
87 |
|
@@ -104,6 +106,13 @@ For more information please check out [TranslatePress documentation](https://tra
|
|
104 |
|
105 |
== Changelog ==
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
= 1.0.2 =
|
108 |
* Translation interface improvements
|
109 |
* Fixed issues with strings loaded with ajax
|
1 |
=== TranslatePress - Translate Multilingual sites ===
|
2 |
Contributors: cozmoslabs, razvan.mo, madalin.ungureanu, cristophor
|
3 |
Donate link: https://www.cozmoslabs.com/
|
4 |
+
Tags: translate, translation, multilingual, automatic translation, front-end translation, google translate, bilingual
|
5 |
Requires at least: 3.1.0
|
6 |
Tested up to: 4.8.2
|
7 |
+
Stable tag: 1.0.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
Easily translate your entire site directly from the front-end and go multilingual, with full support for WooCommerce, complex themes and site builders. Integrates with Google Translate.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
**Experience a better way to translate your WordPress site and go multilingual, directly from the front-end using a friendly user interface.**
|
16 |
|
17 |
+
The interface allows you to easily translate the entire page at once, including output from shortcodes, forms and page builders. It also works out of the box with WooCommerce.
|
18 |
|
19 |
+
Built the WordPress way, TranslatePress - Multilingual is a GPL and self hosted translation plugin, meaning you'll own all your translations, forever.
|
20 |
|
21 |
+
= Multilingual & Translation Features =
|
22 |
|
23 |
+
* Translate all your website content directly from the front-end, in a friendly user interface (translation displayed in real-time).
|
24 |
+
* Fully compatible with all themes and plugins
|
25 |
* Live preview of your translated pages, as you edit your translations.
|
26 |
* Support for both manual and automatic translation (via Google Translate)
|
27 |
* Ability to translate dynamic strings (gettext) added by WordPress, plugins and themes.
|
28 |
* Integrates with Google Translate, allowing you to set up Automatic Translation using your own Google API key.
|
29 |
* Place language switchers anywhere using shortcode **[language-switcher]**, WP menu item or as a floating dropdown.
|
30 |
* Editorial control allowing you to publish your language only when all your translations are done
|
31 |
+
* Conditional display content shortcode based on language [trp_language language="en_EN"] English content only [/trp_language]
|
32 |
|
33 |
Note: this plugin uses the Google Translation API to translate the strings on your site. This feature can be enabled or disabled according to your preferences.
|
34 |
|
40 |
* enable or disable url subdirectory for the default language
|
41 |
* enable automatic translation via Google Translate
|
42 |
|
43 |
+
= Powerful Translation Add-ons =
|
44 |
|
45 |
TranslatePress - Multilingual has a range of premium [Add-ons](https://translatepress.com/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) that allow you to extend the power of the translation plugin:
|
46 |
|
83 |
|
84 |
TranslatePress - Multilingual works out of the box with WooCommerce, custom post types, complex themes and site builders, so you'll be able to translate any type of content.
|
85 |
|
86 |
+
= How is it different from other multilingual & translation plugins? =
|
87 |
|
88 |
TranslatePress is easier to use and more intuitive altogether. No more switching between the editor, string translation interfaces or badly translated plugins. You can now translate the full page content directly from the front-end.
|
89 |
|
106 |
|
107 |
== Changelog ==
|
108 |
|
109 |
+
= 1.0.3 =
|
110 |
+
* Added a conditional language shortcode: [trp_language language="en_US"] English only content [/trp_language]
|
111 |
+
* Create link to test out Google API key.
|
112 |
+
* Improvements to Woocommerce compatibility
|
113 |
+
* Fixed json_encode error that was causing js errors
|
114 |
+
* Changed 'template_include' hook priority to improve compatibility with some themes
|
115 |
+
|
116 |
= 1.0.2 =
|
117 |
* Translation interface improvements
|
118 |
* Fixed issues with strings loaded with ajax
|