Version Description
- We now allow HTML in normal strings translations.
- Changed the way we get the default language permalinks in Woocommerce rewrites
- Fixed issues with date_i18n function
- Fixed a warning generated when there are no rewrite rules
- Fixed dynamic strings not updating the translation dropdown list.
- Fixed issues with hidden space characters that were breaking some translations
- Make sure we don't loose the trp-edit-translation=preview from url after a WordPress redirect
Download this release
Release Info
Developer | madalin.ungureanu |
Plugin | TranslatePress – Translate Multilingual sites |
Version | 1.0.8 |
Comparing to | |
See all releases |
Code changes from version 1.0.7 to 1.0.8
- assets/js/trp-editor-script.js +6 -6
- assets/js/trp-iframe-preview-script.js +3 -0
- assets/js/trp-translate-dom-changes.js +1 -0
- class-translate-press.php +7 -3
- includes/class-settings.php +14 -14
- includes/class-translation-manager.php +63 -5
- includes/class-translation-render.php +57 -12
- includes/class-url-converter.php +28 -22
- includes/functions.php +38 -4
- index.php +2 -2
- partials/addons-settings-page.php +1 -1
- partials/language-switcher-shortcode.php +1 -1
- partials/main-settings-page.php +29 -29
- partials/test-google-key-settings-page.php +5 -5
- partials/translation-manager.php +25 -25
- readme.txt +11 -2
assets/js/trp-editor-script.js
CHANGED
@@ -18,7 +18,7 @@ function TRP_Editor(){
|
|
18 |
var translated_textareas = [];
|
19 |
this.edit_translation_button = null;
|
20 |
var categories;
|
21 |
-
|
22 |
this.jquery_string_selector = jQuery( '#trp-string-categories' );
|
23 |
this.change_tracker = null;
|
24 |
this.maybe_overflow_fix = null;
|
@@ -49,10 +49,10 @@ function TRP_Editor(){
|
|
49 |
|
50 |
_this.iframe_strings_lookup();
|
51 |
|
52 |
-
if ( trp_lister != null ) {
|
53 |
-
_this.jquery_string_selector.off( 'change', trp_lister.select_string );
|
54 |
}
|
55 |
-
trp_lister = new TRP_Lister( dictionaries[trp_on_screen_language] );
|
56 |
|
57 |
if ( _this.change_tracker != null ) {
|
58 |
_this.change_tracker.destroy();
|
@@ -133,7 +133,7 @@ function TRP_Editor(){
|
|
133 |
},
|
134 |
success: function (response) {
|
135 |
_this.populate_strings( response );
|
136 |
-
trp_lister.reload_list();
|
137 |
_this.change_tracker = new TRP_Change_Tracker( _this.original_textarea, translated_textareas );
|
138 |
},
|
139 |
error: function(errorThrown){
|
@@ -660,7 +660,7 @@ function TRP_String( language, array_index ){
|
|
660 |
}else if( jquery_object.attr( 'data-trp-button' ) ){
|
661 |
jquery_object.children('button').text(text_to_set);
|
662 |
}else {
|
663 |
-
jquery_object.
|
664 |
}
|
665 |
}
|
666 |
}
|
18 |
var translated_textareas = [];
|
19 |
this.edit_translation_button = null;
|
20 |
var categories;
|
21 |
+
this.trp_lister = null;
|
22 |
this.jquery_string_selector = jQuery( '#trp-string-categories' );
|
23 |
this.change_tracker = null;
|
24 |
this.maybe_overflow_fix = null;
|
49 |
|
50 |
_this.iframe_strings_lookup();
|
51 |
|
52 |
+
if ( _this.trp_lister != null ) {
|
53 |
+
_this.jquery_string_selector.off( 'change', _this.trp_lister.select_string );
|
54 |
}
|
55 |
+
_this.trp_lister = new TRP_Lister( dictionaries[trp_on_screen_language] );
|
56 |
|
57 |
if ( _this.change_tracker != null ) {
|
58 |
_this.change_tracker.destroy();
|
133 |
},
|
134 |
success: function (response) {
|
135 |
_this.populate_strings( response );
|
136 |
+
_this.trp_lister.reload_list();
|
137 |
_this.change_tracker = new TRP_Change_Tracker( _this.original_textarea, translated_textareas );
|
138 |
},
|
139 |
error: function(errorThrown){
|
660 |
}else if( jquery_object.attr( 'data-trp-button' ) ){
|
661 |
jquery_object.children('button').text(text_to_set);
|
662 |
}else {
|
663 |
+
jquery_object.html( text_to_set );
|
664 |
}
|
665 |
}
|
666 |
}
|
assets/js/trp-iframe-preview-script.js
CHANGED
@@ -10,6 +10,9 @@ function TRP_Iframe_Preview(){
|
|
10 |
*/
|
11 |
this.initialize = function() {
|
12 |
jQuery('a').each(function () {
|
|
|
|
|
|
|
13 |
if( typeof this.href != "undefined" && this.href != '' ) {
|
14 |
if (this.action != '' && this.href.indexOf('void(0)') === -1) {
|
15 |
if (is_link_previewable(this) && !this.getAttribute('href').startsWith('#')) {
|
10 |
*/
|
11 |
this.initialize = function() {
|
12 |
jQuery('a').each(function () {
|
13 |
+
// target parent brakes from the iframe so we're removing it entirely
|
14 |
+
jQuery(this).removeAttr('target');
|
15 |
+
|
16 |
if( typeof this.href != "undefined" && this.href != '' ) {
|
17 |
if (this.action != '' && this.href.indexOf('void(0)') === -1) {
|
18 |
if (is_link_previewable(this) && !this.getAttribute('href').startsWith('#')) {
|
assets/js/trp-translate-dom-changes.js
CHANGED
@@ -79,6 +79,7 @@ function TRP_Translator(){
|
|
79 |
}
|
80 |
if ( typeof parent.trpEditor !== 'undefined' ) {
|
81 |
parent.trpEditor.populate_strings( response );
|
|
|
82 |
}
|
83 |
}
|
84 |
}else{
|
79 |
}
|
80 |
if ( typeof parent.trpEditor !== 'undefined' ) {
|
81 |
parent.trpEditor.populate_strings( response );
|
82 |
+
parent.trpEditor.trp_lister.reload_list();
|
83 |
}
|
84 |
}
|
85 |
}else{
|
class-translate-press.php
CHANGED
@@ -38,8 +38,8 @@ class TRP_Translate_Press{
|
|
38 |
public function __construct() {
|
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();
|
@@ -128,6 +128,8 @@ class TRP_Translate_Press{
|
|
128 |
$this->loader->add_action( 'wp', $this->translation_render, 'start_output_buffer' );
|
129 |
$this->loader->add_action( 'admin_init', $this->translation_render, 'start_output_buffer' );
|
130 |
$this->loader->add_action( 'wp_enqueue_scripts', $this->translation_render, 'enqueue_dynamic_translation', 1 );
|
|
|
|
|
131 |
|
132 |
|
133 |
$this->loader->add_action( 'wp_enqueue_scripts', $this->language_switcher, 'enqueue_language_switcher_scripts' );
|
@@ -168,6 +170,8 @@ class TRP_Translate_Press{
|
|
168 |
$this->loader->add_filter( 'attribute_escape', $this->translation_manager, 'handle_esc_functions_for_gettext', 10, 2 );
|
169 |
/* we need to allow the trp-gettext tag in ksses functions */
|
170 |
$this->loader->add_filter( 'wp_kses_allowed_html', $this->translation_manager, 'handle_kses_functions_for_gettext', 10 );
|
|
|
|
|
171 |
|
172 |
/* define an update hook here */
|
173 |
$this->loader->add_action( 'plugins_loaded', $this->query, 'check_for_necessary_updates' );
|
@@ -177,7 +181,7 @@ class TRP_Translate_Press{
|
|
177 |
/* set up wp_mail hooks */
|
178 |
$this->loader->add_filter( 'wp_mail', $this->translation_render, 'wp_mail_filter', 200 );
|
179 |
|
180 |
-
/* hide php
|
181 |
$this->loader->add_action( 'wp', $this->translation_render, 'trp_debug_mode_off' );
|
182 |
|
183 |
/**
|
38 |
public function __construct() {
|
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.0.8' );
|
43 |
|
44 |
$this->load_dependencies();
|
45 |
$this->initialize_components();
|
128 |
$this->loader->add_action( 'wp', $this->translation_render, 'start_output_buffer' );
|
129 |
$this->loader->add_action( 'admin_init', $this->translation_render, 'start_output_buffer' );
|
130 |
$this->loader->add_action( 'wp_enqueue_scripts', $this->translation_render, 'enqueue_dynamic_translation', 1 );
|
131 |
+
$this->loader->add_filter( 'wp_redirect', $this->translation_render, 'force_preview_on_url_redirect', 99, 2 );
|
132 |
+
$this->loader->add_filter( 'trp_before_translate_content', $this->translation_render, 'force_preview_on_url_in_ajax' );
|
133 |
|
134 |
|
135 |
$this->loader->add_action( 'wp_enqueue_scripts', $this->language_switcher, 'enqueue_language_switcher_scripts' );
|
170 |
$this->loader->add_filter( 'attribute_escape', $this->translation_manager, 'handle_esc_functions_for_gettext', 10, 2 );
|
171 |
/* we need to allow the trp-gettext tag in ksses functions */
|
172 |
$this->loader->add_filter( 'wp_kses_allowed_html', $this->translation_manager, 'handle_kses_functions_for_gettext', 10 );
|
173 |
+
/* we need to treat the date_i18n function differently so we remove the gettext wraps */
|
174 |
+
$this->loader->add_filter( 'date_i18n', $this->translation_manager, 'handle_date_i18n_function_for_gettext', 1, 4 );
|
175 |
|
176 |
/* define an update hook here */
|
177 |
$this->loader->add_action( 'plugins_loaded', $this->query, 'check_for_necessary_updates' );
|
181 |
/* set up wp_mail hooks */
|
182 |
$this->loader->add_filter( 'wp_mail', $this->translation_render, 'wp_mail_filter', 200 );
|
183 |
|
184 |
+
/* hide php ors and notice when we are storing strings in db */
|
185 |
$this->loader->add_action( 'wp', $this->translation_render, 'trp_debug_mode_off' );
|
186 |
|
187 |
/**
|
includes/class-settings.php
CHANGED
@@ -22,11 +22,11 @@ class TRP_Settings{
|
|
22 |
*/
|
23 |
public function get_language_switcher_options(){
|
24 |
$ls_options = apply_filters( 'trp_language_switcher_output', array(
|
25 |
-
'full-names' => array( 'full_names' => true, 'short_names' => false, 'flags' => false, 'label' => __( 'Full Language Names',
|
26 |
-
'short-names' => array( 'full_names' => false, 'short_names' => true, 'flags' => false, 'label' => __( 'Short Language Names',
|
27 |
-
'flags-full-names' => array( 'full_names' => true, 'short_names' => false, 'flags' => true, 'label' => __( 'Flags with Full Language Names',
|
28 |
-
'flags-short-names' => array( 'full_names' => false, 'short_names' => true, 'flags' => true, 'label' => __( 'Flags with Short Language Names',
|
29 |
-
'only-flags' => array( 'full_names' => false, 'short_names' => false, 'flags' => true, 'label' => __( 'Only Flags',
|
30 |
) );
|
31 |
return $ls_options;
|
32 |
}
|
@@ -321,10 +321,10 @@ class TRP_Settings{
|
|
321 |
$selected_language_code = '';
|
322 |
?>
|
323 |
<tr>
|
324 |
-
<th scope="row"> <?php _e( 'Translation Language',
|
325 |
<td>
|
326 |
<select id="trp-translation-language" name="trp_settings[translation-languages][]" class="trp-select2">
|
327 |
-
<option value=""><?php _e( 'Choose...',
|
328 |
<?php foreach( $languages as $language_code => $language_name ){ ?>
|
329 |
<option value="<?php echo $language_code; ?>" <?php if ( in_array( $language_code, $this->settings['translation-languages'] ) && $language_code != $this->settings['default-language'] ) { echo 'selected'; $selected_language_code = $language_code; } ?>>
|
330 |
<?php echo $language_name; ?>
|
@@ -332,12 +332,12 @@ class TRP_Settings{
|
|
332 |
<?php }?>
|
333 |
</select>
|
334 |
<label>
|
335 |
-
<span id="trp-published-language"><b><?php _e( 'Slug',
|
336 |
<input id="trp-url-slug" class="trp-language-slug" name="trp_settings[url-slugs][<?php echo $selected_language_code ?>]" type="text" style="text-transform: lowercase;" value="<?php echo $this->url_converter->get_url_slug( $selected_language_code, false ); ?>">
|
337 |
<input id="trp-active-checkbox" type="hidden" class="trp-translation-published " name="trp_settings[publish-languages][]" value="<?php echo $selected_language_code; ?>" >
|
338 |
</label>
|
339 |
<p class="description">
|
340 |
-
<?php _e( 'Select the language you wish to make your website available in.<br>To select multiple languages, consider upgrading to <a href="https://translatepress.com/" target="_blank" title="TranslatePress Pro">TranslatePress PRO</a>.',
|
341 |
</p>
|
342 |
</td>
|
343 |
</tr>
|
@@ -392,7 +392,7 @@ class TRP_Settings{
|
|
392 |
$this->trp_languages = $trp->get_component( 'languages' );
|
393 |
}
|
394 |
$published_languages = $this->trp_languages->get_language_names( $languages, 'english_name' );
|
395 |
-
$published_languages['current_language'] = __( 'Current Language',
|
396 |
$languages[] = 'current_language';
|
397 |
$posts = get_posts( array( 'post_type' =>'language_switcher', 'posts_per_page' => -1 ) );
|
398 |
|
@@ -433,12 +433,12 @@ class TRP_Settings{
|
|
433 |
public function add_navigation_tabs(){
|
434 |
$tabs = apply_filters( 'trp_settings_tabs', array(
|
435 |
array(
|
436 |
-
'name' => __( 'General',
|
437 |
'url' => admin_url( 'options-general.php?page=translate-press' ),
|
438 |
'page' => 'translate-press'
|
439 |
),
|
440 |
array(
|
441 |
-
'name' => __( 'Translate Site',
|
442 |
'url' => add_query_arg( 'trp-edit-translation', 'true', home_url() ),
|
443 |
'page' => 'trp_translation_editor'
|
444 |
)
|
@@ -446,14 +446,14 @@ class TRP_Settings{
|
|
446 |
|
447 |
if( class_exists('TRP_LICENSE_PAGE') ) {
|
448 |
$tabs[] = array(
|
449 |
-
'name' => __( 'License',
|
450 |
'url' => admin_url( 'admin.php?page=trp_license_key' ),
|
451 |
'page' => 'trp_license_key'
|
452 |
);
|
453 |
}
|
454 |
else{
|
455 |
$tabs[] = array(
|
456 |
-
'name' => __( 'Addons',
|
457 |
'url' => admin_url( 'admin.php?page=trp_addons_page' ),
|
458 |
'page' => 'trp_addons_page'
|
459 |
);
|
22 |
*/
|
23 |
public function get_language_switcher_options(){
|
24 |
$ls_options = apply_filters( 'trp_language_switcher_output', array(
|
25 |
+
'full-names' => array( 'full_names' => true, 'short_names' => false, 'flags' => false, 'label' => __( 'Full Language Names', 'translatepress-multilingual' ) ),
|
26 |
+
'short-names' => array( 'full_names' => false, 'short_names' => true, 'flags' => false, 'label' => __( 'Short Language Names', 'translatepress-multilingual' ) ),
|
27 |
+
'flags-full-names' => array( 'full_names' => true, 'short_names' => false, 'flags' => true, 'label' => __( 'Flags with Full Language Names', 'translatepress-multilingual' ) ),
|
28 |
+
'flags-short-names' => array( 'full_names' => false, 'short_names' => true, 'flags' => true, 'label' => __( 'Flags with Short Language Names', 'translatepress-multilingual' ) ),
|
29 |
+
'only-flags' => array( 'full_names' => false, 'short_names' => false, 'flags' => true, 'label' => __( 'Only Flags', 'translatepress-multilingual' ) ),
|
30 |
) );
|
31 |
return $ls_options;
|
32 |
}
|
321 |
$selected_language_code = '';
|
322 |
?>
|
323 |
<tr>
|
324 |
+
<th scope="row"> <?php _e( 'Translation Language', 'translatepress-multilingual' ) ?> </th>
|
325 |
<td>
|
326 |
<select id="trp-translation-language" name="trp_settings[translation-languages][]" class="trp-select2">
|
327 |
+
<option value=""><?php _e( 'Choose...', 'translatepress-multilingual' );?></option>
|
328 |
<?php foreach( $languages as $language_code => $language_name ){ ?>
|
329 |
<option value="<?php echo $language_code; ?>" <?php if ( in_array( $language_code, $this->settings['translation-languages'] ) && $language_code != $this->settings['default-language'] ) { echo 'selected'; $selected_language_code = $language_code; } ?>>
|
330 |
<?php echo $language_name; ?>
|
332 |
<?php }?>
|
333 |
</select>
|
334 |
<label>
|
335 |
+
<span id="trp-published-language"><b><?php _e( 'Slug', 'translatepress-multilingual' ); ?></b></span>
|
336 |
<input id="trp-url-slug" class="trp-language-slug" name="trp_settings[url-slugs][<?php echo $selected_language_code ?>]" type="text" style="text-transform: lowercase;" value="<?php echo $this->url_converter->get_url_slug( $selected_language_code, false ); ?>">
|
337 |
<input id="trp-active-checkbox" type="hidden" class="trp-translation-published " name="trp_settings[publish-languages][]" value="<?php echo $selected_language_code; ?>" >
|
338 |
</label>
|
339 |
<p class="description">
|
340 |
+
<?php _e( 'Select the language you wish to make your website available in.<br>To select multiple languages, consider upgrading to <a href="https://translatepress.com/" target="_blank" title="TranslatePress Pro">TranslatePress PRO</a>.', 'translatepress-multilingual' ); ?>
|
341 |
</p>
|
342 |
</td>
|
343 |
</tr>
|
392 |
$this->trp_languages = $trp->get_component( 'languages' );
|
393 |
}
|
394 |
$published_languages = $this->trp_languages->get_language_names( $languages, 'english_name' );
|
395 |
+
$published_languages['current_language'] = __( 'Current Language', 'translatepress-multilingual' );
|
396 |
$languages[] = 'current_language';
|
397 |
$posts = get_posts( array( 'post_type' =>'language_switcher', 'posts_per_page' => -1 ) );
|
398 |
|
433 |
public function add_navigation_tabs(){
|
434 |
$tabs = apply_filters( 'trp_settings_tabs', array(
|
435 |
array(
|
436 |
+
'name' => __( 'General', 'translatepress-multilingual' ),
|
437 |
'url' => admin_url( 'options-general.php?page=translate-press' ),
|
438 |
'page' => 'translate-press'
|
439 |
),
|
440 |
array(
|
441 |
+
'name' => __( 'Translate Site', 'translatepress-multilingual' ),
|
442 |
'url' => add_query_arg( 'trp-edit-translation', 'true', home_url() ),
|
443 |
'page' => 'trp_translation_editor'
|
444 |
)
|
446 |
|
447 |
if( class_exists('TRP_LICENSE_PAGE') ) {
|
448 |
$tabs[] = array(
|
449 |
+
'name' => __( 'License', 'translatepress-multilingual' ),
|
450 |
'url' => admin_url( 'admin.php?page=trp_license_key' ),
|
451 |
'page' => 'trp_license_key'
|
452 |
);
|
453 |
}
|
454 |
else{
|
455 |
$tabs[] = array(
|
456 |
+
'name' => __( 'Addons', 'translatepress-multilingual' ),
|
457 |
'url' => admin_url( 'admin.php?page=trp_addons_page' ),
|
458 |
'page' => 'trp_addons_page'
|
459 |
);
|
includes/class-translation-manager.php
CHANGED
@@ -331,7 +331,7 @@ class TRP_Translation_Manager{
|
|
331 |
array_push($update_strings[ $language ], array(
|
332 |
'id' => (int)$string->id,
|
333 |
'original' => sanitize_text_field($string->original),
|
334 |
-
'translated' =>
|
335 |
'status' => (int)$string->status
|
336 |
));
|
337 |
|
@@ -404,7 +404,7 @@ class TRP_Translation_Manager{
|
|
404 |
if( is_admin () ) {
|
405 |
$url = add_query_arg( 'trp-edit-translation', 'true', home_url() );
|
406 |
|
407 |
-
$title = __( 'Translate Site',
|
408 |
$url_target = '_blank';
|
409 |
} else {
|
410 |
|
@@ -416,7 +416,7 @@ class TRP_Translation_Manager{
|
|
416 |
$url = $this->url_converter->cur_page_url();
|
417 |
$url = add_query_arg( 'trp-edit-translation', 'true', $url );
|
418 |
|
419 |
-
$title = __( 'Translate Page',
|
420 |
$url_target = '';
|
421 |
}
|
422 |
|
@@ -435,7 +435,7 @@ class TRP_Translation_Manager{
|
|
435 |
$wp_admin_bar->add_node(
|
436 |
array(
|
437 |
'id' => 'trp_settings_page',
|
438 |
-
'title' => __( 'Settings',
|
439 |
'href' => admin_url( 'options-general.php?page=translate-press' ),
|
440 |
'parent' => 'trp_edit_translation',
|
441 |
'meta' => array(
|
@@ -574,7 +574,7 @@ class TRP_Translation_Manager{
|
|
574 |
if( count( $this->settings['publish-languages'] ) < 1 )
|
575 |
return $translation;
|
576 |
|
577 |
-
if( ( isset( $_REQUEST['trp-edit-translation'] ) && $_REQUEST['trp-edit-translation'] == 'true' ) || $domain ==
|
578 |
return $translation;
|
579 |
|
580 |
/* for our own actions don't do nothing */
|
@@ -780,5 +780,63 @@ class TRP_Translation_Manager{
|
|
780 |
}
|
781 |
return $tags;
|
782 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
783 |
|
784 |
}
|
331 |
array_push($update_strings[ $language ], array(
|
332 |
'id' => (int)$string->id,
|
333 |
'original' => sanitize_text_field($string->original),
|
334 |
+
'translated' => preg_replace( '/<script\b[^>]*>(.*?)<\/script>/is', '', $string->translated ),
|
335 |
'status' => (int)$string->status
|
336 |
));
|
337 |
|
404 |
if( is_admin () ) {
|
405 |
$url = add_query_arg( 'trp-edit-translation', 'true', home_url() );
|
406 |
|
407 |
+
$title = __( 'Translate Site', 'translatepress-multilingual' );
|
408 |
$url_target = '_blank';
|
409 |
} else {
|
410 |
|
416 |
$url = $this->url_converter->cur_page_url();
|
417 |
$url = add_query_arg( 'trp-edit-translation', 'true', $url );
|
418 |
|
419 |
+
$title = __( 'Translate Page', 'translatepress-multilingual' );
|
420 |
$url_target = '';
|
421 |
}
|
422 |
|
435 |
$wp_admin_bar->add_node(
|
436 |
array(
|
437 |
'id' => 'trp_settings_page',
|
438 |
+
'title' => __( 'Settings', 'translatepress-multilingual' ),
|
439 |
'href' => admin_url( 'options-general.php?page=translate-press' ),
|
440 |
'parent' => 'trp_edit_translation',
|
441 |
'meta' => array(
|
574 |
if( count( $this->settings['publish-languages'] ) < 1 )
|
575 |
return $translation;
|
576 |
|
577 |
+
if( ( isset( $_REQUEST['trp-edit-translation'] ) && $_REQUEST['trp-edit-translation'] == 'true' ) || $domain == 'translatepress-multilingual' )
|
578 |
return $translation;
|
579 |
|
580 |
/* for our own actions don't do nothing */
|
780 |
}
|
781 |
return $tags;
|
782 |
}
|
783 |
+
|
784 |
+
/**
|
785 |
+
* make sure we remove the trp-gettext wrap from the format the date_i18n receives
|
786 |
+
* ideally if in the gettext filter we would know 100% that a string is a valid date format then we would not wrap it but it seems that it is not easy to determine that ( explore further in the future $d = DateTime::createFromFormat('Y', date('y a') method); )
|
787 |
+
*/
|
788 |
+
function handle_date_i18n_function_for_gettext( $j, $dateformatstring, $unixtimestamp, $gmt ){
|
789 |
+
|
790 |
+
/* remove trp-gettext wrap */
|
791 |
+
$dateformatstring = preg_replace( '/(<|<)trp-gettext (.*?)(>|>)/', '', $dateformatstring );
|
792 |
+
$dateformatstring = preg_replace( '/(<|<)(.?)\/trp-gettext(>|>)/', '', $dateformatstring );
|
793 |
+
|
794 |
+
|
795 |
+
global $wp_locale;
|
796 |
+
$i = $unixtimestamp;
|
797 |
+
|
798 |
+
if ( false === $i ) {
|
799 |
+
$i = current_time( 'timestamp', $gmt );
|
800 |
+
}
|
801 |
+
|
802 |
+
if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) {
|
803 |
+
$datemonth = $wp_locale->get_month( date( 'm', $i ) );
|
804 |
+
$datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth );
|
805 |
+
$dateweekday = $wp_locale->get_weekday( date( 'w', $i ) );
|
806 |
+
$dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday );
|
807 |
+
$datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) );
|
808 |
+
$datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) );
|
809 |
+
$dateformatstring = ' '.$dateformatstring;
|
810 |
+
$dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring );
|
811 |
+
$dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring );
|
812 |
+
$dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring );
|
813 |
+
$dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring );
|
814 |
+
$dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring );
|
815 |
+
$dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring );
|
816 |
+
|
817 |
+
$dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
|
818 |
+
}
|
819 |
+
$timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' );
|
820 |
+
$timezone_formats_re = implode( '|', $timezone_formats );
|
821 |
+
if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) ) {
|
822 |
+
$timezone_string = get_option( 'timezone_string' );
|
823 |
+
if ( $timezone_string ) {
|
824 |
+
$timezone_object = timezone_open( $timezone_string );
|
825 |
+
$date_object = date_create( null, $timezone_object );
|
826 |
+
foreach ( $timezone_formats as $timezone_format ) {
|
827 |
+
if ( false !== strpos( $dateformatstring, $timezone_format ) ) {
|
828 |
+
$formatted = date_format( $date_object, $timezone_format );
|
829 |
+
$dateformatstring = ' '.$dateformatstring;
|
830 |
+
$dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring );
|
831 |
+
$dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
|
832 |
+
}
|
833 |
+
}
|
834 |
+
}
|
835 |
+
}
|
836 |
+
$j = @date( $dateformatstring, $i );
|
837 |
+
|
838 |
+
return $j;
|
839 |
+
|
840 |
+
}
|
841 |
|
842 |
}
|
includes/class-translation-render.php
CHANGED
@@ -92,8 +92,7 @@ class TRP_Translation_Render{
|
|
92 |
* @return string Trimmed string.
|
93 |
*/
|
94 |
public function full_trim( $word ) {
|
95 |
-
$word =
|
96 |
-
$word = trim($word," \t\n\r\0\x0B\xA0�" );
|
97 |
if ( htmlentities( $word ) == "" || strip_tags( $word ) == "" || trim ($word, " \t\n\r\0\x0B\xA0�.,/`~!@#\$€£%^&*():;-_=+[]{}\\|?/<>1234567890'\"" ) == '' ){
|
98 |
$word = '';
|
99 |
}
|
@@ -109,7 +108,7 @@ class TRP_Translation_Render{
|
|
109 |
*/
|
110 |
protected function get_node_type_category( $current_node_type ){
|
111 |
$node_type_categories = apply_filters( 'trp_node_type_categories', array(
|
112 |
-
__( 'Meta Information',
|
113 |
));
|
114 |
|
115 |
foreach( $node_type_categories as $category_name => $node_types ){
|
@@ -118,7 +117,7 @@ class TRP_Translation_Render{
|
|
118 |
}
|
119 |
}
|
120 |
|
121 |
-
return __( 'String List',
|
122 |
|
123 |
}
|
124 |
|
@@ -135,47 +134,47 @@ class TRP_Translation_Render{
|
|
135 |
'type' => 'meta_desc',
|
136 |
'attribute' => 'name',
|
137 |
'value' => 'description',
|
138 |
-
'description' => __( 'Description',
|
139 |
),
|
140 |
array(
|
141 |
'type' => 'meta_desc',
|
142 |
'attribute' => 'property',
|
143 |
'value' => 'og:title',
|
144 |
-
'description' => __( 'OG Title',
|
145 |
),
|
146 |
array(
|
147 |
'type' => 'meta_desc',
|
148 |
'attribute' => 'property',
|
149 |
'value' => 'og:site_name',
|
150 |
-
'description' => __( 'OG Site Name',
|
151 |
),
|
152 |
array(
|
153 |
'type' => 'meta_desc',
|
154 |
'attribute' => 'property',
|
155 |
'value' => 'og:description',
|
156 |
-
'description' => __( 'OG Description',
|
157 |
),
|
158 |
array(
|
159 |
'type' => 'meta_desc',
|
160 |
'attribute' => 'name',
|
161 |
'value' => 'twitter:title',
|
162 |
-
'description' => __( 'Twitter Title',
|
163 |
),
|
164 |
array(
|
165 |
'type' => 'meta_desc',
|
166 |
'attribute' => 'name',
|
167 |
'value' => 'twitter:description',
|
168 |
-
'description' => __( 'Twitter Description',
|
169 |
),
|
170 |
array(
|
171 |
'type' => 'post_slug',
|
172 |
'attribute' => 'name',
|
173 |
'value' => 'trp-slug',
|
174 |
-
'description' => __( 'Post Slug',
|
175 |
),
|
176 |
array(
|
177 |
'type' => 'page_title',
|
178 |
-
'description' => __( 'Page Title',
|
179 |
),
|
180 |
|
181 |
));
|
@@ -225,6 +224,8 @@ class TRP_Translation_Render{
|
|
225 |
return $output;
|
226 |
}
|
227 |
|
|
|
|
|
228 |
//check if we have a json response
|
229 |
if (is_array($json_array = json_decode($output, true))) {
|
230 |
if (!empty($json_array)) {
|
@@ -732,4 +733,48 @@ class TRP_Translation_Render{
|
|
732 |
return $trp_wp_mail;
|
733 |
}
|
734 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
735 |
}
|
92 |
* @return string Trimmed string.
|
93 |
*/
|
94 |
public function full_trim( $word ) {
|
95 |
+
$word = trim($word," \t\n\r\0\x0B\xA0�".chr( 194 ) . chr( 160 ) );
|
|
|
96 |
if ( htmlentities( $word ) == "" || strip_tags( $word ) == "" || trim ($word, " \t\n\r\0\x0B\xA0�.,/`~!@#\$€£%^&*():;-_=+[]{}\\|?/<>1234567890'\"" ) == '' ){
|
97 |
$word = '';
|
98 |
}
|
108 |
*/
|
109 |
protected function get_node_type_category( $current_node_type ){
|
110 |
$node_type_categories = apply_filters( 'trp_node_type_categories', array(
|
111 |
+
__( 'Meta Information', 'translatepress-multilingual' ) => array( 'meta_desc', 'post_slug', 'page_title' ),
|
112 |
));
|
113 |
|
114 |
foreach( $node_type_categories as $category_name => $node_types ){
|
117 |
}
|
118 |
}
|
119 |
|
120 |
+
return __( 'String List', 'translatepress-multilingual' );
|
121 |
|
122 |
}
|
123 |
|
134 |
'type' => 'meta_desc',
|
135 |
'attribute' => 'name',
|
136 |
'value' => 'description',
|
137 |
+
'description' => __( 'Description', 'translatepress-multilingual' )
|
138 |
),
|
139 |
array(
|
140 |
'type' => 'meta_desc',
|
141 |
'attribute' => 'property',
|
142 |
'value' => 'og:title',
|
143 |
+
'description' => __( 'OG Title', 'translatepress-multilingual' )
|
144 |
),
|
145 |
array(
|
146 |
'type' => 'meta_desc',
|
147 |
'attribute' => 'property',
|
148 |
'value' => 'og:site_name',
|
149 |
+
'description' => __( 'OG Site Name', 'translatepress-multilingual' )
|
150 |
),
|
151 |
array(
|
152 |
'type' => 'meta_desc',
|
153 |
'attribute' => 'property',
|
154 |
'value' => 'og:description',
|
155 |
+
'description' => __( 'OG Description', 'translatepress-multilingual' )
|
156 |
),
|
157 |
array(
|
158 |
'type' => 'meta_desc',
|
159 |
'attribute' => 'name',
|
160 |
'value' => 'twitter:title',
|
161 |
+
'description' => __( 'Twitter Title', 'translatepress-multilingual' )
|
162 |
),
|
163 |
array(
|
164 |
'type' => 'meta_desc',
|
165 |
'attribute' => 'name',
|
166 |
'value' => 'twitter:description',
|
167 |
+
'description' => __( 'Twitter Description', 'translatepress-multilingual' )
|
168 |
),
|
169 |
array(
|
170 |
'type' => 'post_slug',
|
171 |
'attribute' => 'name',
|
172 |
'value' => 'trp-slug',
|
173 |
+
'description' => __( 'Post Slug', 'translatepress-multilingual' )
|
174 |
),
|
175 |
array(
|
176 |
'type' => 'page_title',
|
177 |
+
'description' => __( 'Page Title', 'translatepress-multilingual' )
|
178 |
),
|
179 |
|
180 |
));
|
224 |
return $output;
|
225 |
}
|
226 |
|
227 |
+
$output = apply_filters('trp_before_translate_content', $output);
|
228 |
+
|
229 |
//check if we have a json response
|
230 |
if (is_array($json_array = json_decode($output, true))) {
|
231 |
if (!empty($json_array)) {
|
733 |
return $trp_wp_mail;
|
734 |
}
|
735 |
|
736 |
+
/**
|
737 |
+
* Filters the location redirect to add the preview parameter to the next page
|
738 |
+
* @param $location
|
739 |
+
* @param $status
|
740 |
+
* @return string
|
741 |
+
* @since 1.0.8
|
742 |
+
*/
|
743 |
+
public function force_preview_on_url_redirect( $location, $status ){
|
744 |
+
if( isset( $_REQUEST['trp-edit-translation'] ) && $_REQUEST['trp-edit-translation'] == 'preview' ){
|
745 |
+
$location = add_query_arg( 'trp-edit-translation', 'preview', $location );
|
746 |
+
}
|
747 |
+
return $location;
|
748 |
+
}
|
749 |
+
|
750 |
+
/**
|
751 |
+
* Filters the output buffer of ajax calls that return json and adds the preview arg to urls
|
752 |
+
* @param $output
|
753 |
+
* @return string
|
754 |
+
* @since 1.0.8
|
755 |
+
*/
|
756 |
+
public function force_preview_on_url_in_ajax( $output ){
|
757 |
+
if ( TRP_Translation_Manager::is_ajax_on_frontend() && isset( $_REQUEST['trp-edit-translation'] ) && $_REQUEST['trp-edit-translation'] === 'preview' ) {
|
758 |
+
$result = json_decode($output, TRUE);
|
759 |
+
if ( json_last_error() === JSON_ERROR_NONE) {
|
760 |
+
array_walk_recursive($result, array($this, 'callback_add_preview_arg'));
|
761 |
+
$output = trp_safe_json_encode($result);
|
762 |
+
} //endif
|
763 |
+
} //endif
|
764 |
+
return $output;
|
765 |
+
}
|
766 |
+
|
767 |
+
/**
|
768 |
+
* Adds preview query arg to links that are url's. callback specifically for the array_walk_recursive function
|
769 |
+
* @param $item
|
770 |
+
* @param $key
|
771 |
+
* @return string
|
772 |
+
* @internal param $output
|
773 |
+
* @since 1.0.8
|
774 |
+
*/
|
775 |
+
function callback_add_preview_arg(&$item, $key){
|
776 |
+
if ( filter_var($item, FILTER_VALIDATE_URL) !== FALSE ) {
|
777 |
+
$item = add_query_arg( 'trp-edit-translation', 'preview', $item );
|
778 |
+
}
|
779 |
+
}
|
780 |
}
|
includes/class-url-converter.php
CHANGED
@@ -269,29 +269,24 @@ class TRP_Url_Converter {
|
|
269 |
/**
|
270 |
* Return current page url.
|
271 |
*
|
272 |
-
* @return string
|
273 |
*/
|
274 |
public function cur_page_url() {
|
275 |
-
$pageURL = 'http';
|
276 |
|
277 |
-
|
278 |
-
$pageURL .= "s";
|
279 |
|
280 |
-
$
|
|
|
281 |
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
$pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
|
288 |
-
else
|
289 |
-
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
|
290 |
-
}
|
291 |
|
292 |
-
if ( function_exists('apply_filters') ) $pageURL = apply_filters('trp_curpageurl', $
|
293 |
|
294 |
-
return $
|
295 |
}
|
296 |
|
297 |
/**
|
@@ -306,20 +301,31 @@ class TRP_Url_Converter {
|
|
306 |
global $default_language_wc_permalink_structure; //we use a global because apparently you can't do switch to locale and restore multiple times. I should keep an eye on this
|
307 |
/* get rewrite rules from original language */
|
308 |
if( empty($default_language_wc_permalink_structure) ) {
|
309 |
-
|
310 |
-
$default_language_wc_permalink_structure =
|
311 |
-
|
|
|
312 |
}
|
313 |
|
314 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
|
316 |
$new_rewrite_rules = array();
|
317 |
|
318 |
$search = array( '/^'.$default_language_wc_permalink_structure['product_rewrite_slug'].'\//', '/^'.$default_language_wc_permalink_structure['category_rewrite_slug'].'\//', '/^'.$default_language_wc_permalink_structure['tag_rewrite_slug'].'\//' );
|
319 |
$replace = array( $current_language_permalink_structure['product_rewrite_slug'].'/', $current_language_permalink_structure['category_rewrite_slug'].'/', $current_language_permalink_structure['tag_rewrite_slug'].'/' );
|
320 |
|
321 |
-
|
322 |
-
|
|
|
|
|
323 |
}
|
324 |
|
325 |
}
|
269 |
/**
|
270 |
* Return current page url.
|
271 |
*
|
272 |
+
* @return string
|
273 |
*/
|
274 |
public function cur_page_url() {
|
|
|
275 |
|
276 |
+
$req_uri = $_SERVER['REQUEST_URI'];
|
|
|
277 |
|
278 |
+
$home_path = trim( parse_url( home_url(), PHP_URL_PATH ), '/' );
|
279 |
+
$home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) );
|
280 |
|
281 |
+
// Trim path info from the end and the leading home path from the front.
|
282 |
+
$req_uri = trim($req_uri, '/');
|
283 |
+
$req_uri = preg_replace( $home_path_regex, '', $req_uri );
|
284 |
+
$req_uri = trim($req_uri, '/');
|
285 |
+
$req_uri = home_url($req_uri);
|
|
|
|
|
|
|
|
|
286 |
|
287 |
+
if ( function_exists('apply_filters') ) $pageURL = apply_filters('trp_curpageurl', $req_uri);
|
288 |
|
289 |
+
return $req_uri;
|
290 |
}
|
291 |
|
292 |
/**
|
301 |
global $default_language_wc_permalink_structure; //we use a global because apparently you can't do switch to locale and restore multiple times. I should keep an eye on this
|
302 |
/* get rewrite rules from original language */
|
303 |
if( empty($default_language_wc_permalink_structure) ) {
|
304 |
+
$default_language_wc_permalink_structure = array();
|
305 |
+
$default_language_wc_permalink_structure['product_rewrite_slug'] = trp_x( 'product', 'slug', 'woocommerce', $this->settings['default-language'] );
|
306 |
+
$default_language_wc_permalink_structure['category_rewrite_slug'] = trp_x( 'product-category', 'slug', 'woocommerce', $this->settings['default-language'] );
|
307 |
+
$default_language_wc_permalink_structure['tag_rewrite_slug'] = trp_x( 'product-tag', 'slug', 'woocommerce', $this->settings['default-language'] );
|
308 |
}
|
309 |
|
310 |
+
if( function_exists( 'wc_get_permalink_structure' ) ){
|
311 |
+
$current_language_permalink_structure = wc_get_permalink_structure();
|
312 |
+
}
|
313 |
+
else{
|
314 |
+
$current_language_permalink_structure = array();
|
315 |
+
$current_language_permalink_structure['product_rewrite_slug'] = trp_x( 'product', 'slug', 'woocommerce', $TRP_LANGUAGE );
|
316 |
+
$current_language_permalink_structure['category_rewrite_slug'] = trp_x( 'product-category', 'slug', 'woocommerce', $TRP_LANGUAGE );
|
317 |
+
$current_language_permalink_structure['tag_rewrite_slug'] = trp_x( 'product-tag', 'slug', 'woocommerce', $TRP_LANGUAGE );
|
318 |
+
}
|
319 |
|
320 |
$new_rewrite_rules = array();
|
321 |
|
322 |
$search = array( '/^'.$default_language_wc_permalink_structure['product_rewrite_slug'].'\//', '/^'.$default_language_wc_permalink_structure['category_rewrite_slug'].'\//', '/^'.$default_language_wc_permalink_structure['tag_rewrite_slug'].'\//' );
|
323 |
$replace = array( $current_language_permalink_structure['product_rewrite_slug'].'/', $current_language_permalink_structure['category_rewrite_slug'].'/', $current_language_permalink_structure['tag_rewrite_slug'].'/' );
|
324 |
|
325 |
+
if( !empty( $rewrite_rules ) && is_array($rewrite_rules) ) {
|
326 |
+
foreach ($rewrite_rules as $rewrite_key => $rewrite_values) {
|
327 |
+
$new_rewrite_rules[preg_replace($search, $replace, $rewrite_key)] = preg_replace($search, $replace, $rewrite_values);
|
328 |
+
}
|
329 |
}
|
330 |
|
331 |
}
|
includes/functions.php
CHANGED
@@ -60,18 +60,52 @@ function trp_utf8ize($mixed) {
|
|
60 |
|
61 |
/**
|
62 |
* function that gets the translation for a string with context directly from a .mo file
|
63 |
-
* @TODO this was developped firstly for woocommerce so it needs further development.
|
64 |
*/
|
65 |
function trp_x( $text, $context, $domain, $language ){
|
66 |
-
$mo_file = new MO();
|
67 |
|
68 |
-
|
69 |
-
|
70 |
|
|
|
|
|
|
|
|
|
71 |
|
72 |
if (!empty($mo_file->entries[$context . '' . $text]))
|
73 |
$text = $mo_file->entries[$context . '' . $text]->translations[0];
|
74 |
}
|
75 |
|
76 |
return $text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
}
|
60 |
|
61 |
/**
|
62 |
* function that gets the translation for a string with context directly from a .mo file
|
63 |
+
* @TODO this was developped firstly for woocommerce so it maybe needs further development.
|
64 |
*/
|
65 |
function trp_x( $text, $context, $domain, $language ){
|
|
|
66 |
|
67 |
+
/* try to find the correct path for the textdomain */
|
68 |
+
$path = trp_find_translation_location_for_domain( $domain, $language );
|
69 |
|
70 |
+
$mo_file = new MO();
|
71 |
+
|
72 |
+
if( !empty( $path ) ) {
|
73 |
+
if (!$mo_file->import_from_file( $path )) return $text;
|
74 |
|
75 |
if (!empty($mo_file->entries[$context . '' . $text]))
|
76 |
$text = $mo_file->entries[$context . '' . $text]->translations[0];
|
77 |
}
|
78 |
|
79 |
return $text;
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Function that tries to find the path for a translation file defined by textdomain and language
|
85 |
+
* @param $domain the textdomain of the string that you want the translation for
|
86 |
+
* @param $language the language in which you want the translation
|
87 |
+
* @return string the path of the mo file if it is found else an empty string
|
88 |
+
*/
|
89 |
+
function trp_find_translation_location_for_domain( $domain, $language ){
|
90 |
+
|
91 |
+
$path = '';
|
92 |
+
|
93 |
+
if( file_exists( WP_LANG_DIR . '/plugins/'. $domain .'-' . $language . '.mo') ) {
|
94 |
+
$path = WP_LANG_DIR . '/plugins/'. $domain .'-' . $language . '.mo';
|
95 |
+
}
|
96 |
+
elseif ( file_exists( WP_LANG_DIR . '/themes/'. $domain .'-' . $language . '.mo') ){
|
97 |
+
$path = WP_LANG_DIR . '/themes/'. $domain .'-' . $language . '.mo';
|
98 |
+
}
|
99 |
+
else {
|
100 |
+
$possible_translation_folders = array( '', 'languages/', 'language/', 'translations/', 'translation/', 'lang/' );
|
101 |
+
foreach( $possible_translation_folders as $possible_translation_folder ){
|
102 |
+
if (file_exists(get_template_directory() . '/' . $possible_translation_folder . $domain . '-' . $language . '.mo')) {
|
103 |
+
$path = get_template_directory() . '/' . $possible_translation_folder . $domain . '-' . $language . '.mo';
|
104 |
+
} elseif ( file_exists(WP_PLUGIN_DIR . '/' . $domain . '/' . $possible_translation_folder . $domain . '-' . $language . '.mo') ) {
|
105 |
+
$path = WP_PLUGIN_DIR . '/' . $domain . '/' . $possible_translation_folder . $domain . '-' . $language . '.mo';
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
return $path;
|
111 |
}
|
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
|
@@ -33,4 +33,4 @@ function trp_run_translatepress_hooks(){
|
|
33 |
$trp->run();
|
34 |
}
|
35 |
/* make sure we execute our plugin before other plugins so the changes we make apply across the board */
|
36 |
-
add_action( 'plugins_loaded', 'trp_run_translatepress_hooks', 1 );
|
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.8
|
7 |
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
|
8 |
Author URI: https://cozmoslabs.com/
|
9 |
License: GPL2
|
33 |
$trp->run();
|
34 |
}
|
35 |
/* make sure we execute our plugin before other plugins so the changes we make apply across the board */
|
36 |
+
add_action( 'plugins_loaded', 'trp_run_translatepress_hooks', 1 );
|
partials/addons-settings-page.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<div id="trp-addons-page" class="wrap">
|
2 |
|
3 |
-
<h1> <?php _e( 'TranslatePress Settings',
|
4 |
<?php do_action ( 'trp_settings_navigation_tabs' ); ?>
|
5 |
|
6 |
<div class="grid feat-header">
|
1 |
<div id="trp-addons-page" class="wrap">
|
2 |
|
3 |
+
<h1> <?php _e( 'TranslatePress Settings', 'translatepress-multilingual' );?></h1>
|
4 |
<?php do_action ( 'trp_settings_navigation_tabs' ); ?>
|
5 |
|
6 |
<div class="grid feat-header">
|
partials/language-switcher-shortcode.php
CHANGED
@@ -24,6 +24,6 @@ if( $shortcode_settings['flags'] && ! $shortcode_settings['full_names'] && ! $sh
|
|
24 |
</option>
|
25 |
<?php } ?>
|
26 |
</select>
|
27 |
-
<noscript><input type="submit" value="<?php _e( 'Change',
|
28 |
</form>
|
29 |
</div>
|
24 |
</option>
|
25 |
<?php } ?>
|
26 |
</select>
|
27 |
+
<noscript><input type="submit" value="<?php _e( 'Change', 'translatepress-multilingual' );?>"></noscript>
|
28 |
</form>
|
29 |
</div>
|
partials/main-settings-page.php
CHANGED
@@ -2,12 +2,12 @@
|
|
2 |
<div id="trp-main-settings" class="wrap">
|
3 |
<form method="post" action="options.php">
|
4 |
<?php settings_fields( 'trp_settings' ); ?>
|
5 |
-
<h1> <?php _e( 'TranslatePress Settings',
|
6 |
<?php do_action ( 'trp_settings_navigation_tabs' ); ?>
|
7 |
|
8 |
<table id="trp-options" class="form-table">
|
9 |
<tr>
|
10 |
-
<th scope="row"><?php _e( 'Default Language',
|
11 |
<td>
|
12 |
<select id="trp-default-language" name="trp_settings[default-language]" class="trp-select2">
|
13 |
<?php
|
@@ -18,7 +18,7 @@
|
|
18 |
<?php }?>
|
19 |
</select>
|
20 |
<p class="description">
|
21 |
-
<?php _e( 'Select the original language your website was written in. ',
|
22 |
</p>
|
23 |
</td>
|
24 |
</tr>
|
@@ -26,97 +26,97 @@
|
|
26 |
<?php do_action( 'trp_language_selector', $languages ); ?>
|
27 |
|
28 |
<tr>
|
29 |
-
<th scope="row"><?php _e( 'Native language name',
|
30 |
<td>
|
31 |
<select id="trp-g-translate" name="trp_settings[native_or_english_name]" class="trp-select">
|
32 |
-
<option value="english_name" <?php selected( $this->settings['native_or_english_name'], 'english_name' ); ?>><?php _e( 'No',
|
33 |
-
<option value="native_name" <?php selected( $this->settings['native_or_english_name'], 'native_name' ); ?>><?php _e( 'Yes',
|
34 |
</select>
|
35 |
<p class="description">
|
36 |
-
<?php _e( 'Select Yes if you want languages to display in their native names. Otherwise, they will be displayed in English.',
|
37 |
</p>
|
38 |
</td>
|
39 |
</tr>
|
40 |
|
41 |
<tr>
|
42 |
-
<th scope="row"><?php _e( 'Use subdirectory for default language',
|
43 |
<td>
|
44 |
<select id="trp-g-translate" name="trp_settings[add-subdirectory-to-default-language]" class="trp-select">
|
45 |
-
<option value="no" <?php selected( $this->settings['add-subdirectory-to-default-language'], 'no' ); ?>><?php _e( 'No',
|
46 |
-
<option value="yes" <?php selected( $this->settings['add-subdirectory-to-default-language'], 'yes' ); ?>><?php _e( 'Yes',
|
47 |
</select>
|
48 |
<p class="description">
|
49 |
-
<?php _e( 'Select Yes if you want to add the subdirectory in the url for the default language.',
|
50 |
</p>
|
51 |
</td>
|
52 |
</tr>
|
53 |
|
54 |
<tr>
|
55 |
-
<th scope="row"><?php _e( 'Force language in custom links',
|
56 |
<td>
|
57 |
<select id="trp-g-translate" name="trp_settings[force-language-to-custom-links]" class="trp-select">
|
58 |
-
<option value="no" <?php selected( $this->settings['force-language-to-custom-links'], 'no' ); ?>><?php _e( 'No',
|
59 |
-
<option value="yes" <?php selected( $this->settings['force-language-to-custom-links'], 'yes' ); ?>><?php _e( 'Yes',
|
60 |
</select>
|
61 |
<p class="description">
|
62 |
-
<?php _e( 'Select Yes if you want to force custom links without language encoding to add the subdirectory in the url for the default language.',
|
63 |
</p>
|
64 |
</td>
|
65 |
</tr>
|
66 |
|
67 |
<tr>
|
68 |
-
<th scope="row"><?php _e( 'Google Translate',
|
69 |
<td>
|
70 |
<select id="trp-g-translate" name="trp_settings[g-translate]" class="trp-select">
|
71 |
-
<option value="no" <?php selected( $this->settings['g-translate'], 'no' ); ?>><?php _e( 'No',
|
72 |
-
<option value="yes" <?php selected( $this->settings['g-translate'], 'yes' ); ?>><?php _e( 'Yes',
|
73 |
</select>
|
74 |
<p class="description">
|
75 |
-
<?php _e( '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>. ',
|
76 |
</p>
|
77 |
</td>
|
78 |
</tr>
|
79 |
|
80 |
<tr>
|
81 |
-
<th scope="row"><?php _e( 'Google Translate API Key',
|
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.",
|
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. ',
|
87 |
</p>
|
88 |
</td>
|
89 |
|
90 |
</tr>
|
91 |
|
92 |
<tr>
|
93 |
-
<th scope="row"><?php _e( 'Language Switcher',
|
94 |
<td>
|
95 |
<div class="trp-ls-type">
|
96 |
-
<input type="checkbox" disabled checked id="trp-ls-shortcode" ><b><?php _e( 'Shortcode ',
|
97 |
<div>
|
98 |
<?php $this->output_language_switcher_select( 'shortcode-options', $this->settings['shortcode-options'] ); ?>
|
99 |
</div>
|
100 |
<p class="description">
|
101 |
-
<?php _e( 'Use shortcode on any page or widget.',
|
102 |
</p>
|
103 |
</div>
|
104 |
<div class="trp-ls-type">
|
105 |
-
<label><input type="checkbox" id="trp-ls-menu" disabled checked ><b><?php _e( 'Menu item',
|
106 |
<div>
|
107 |
<?php $this->output_language_switcher_select( 'menu-options', $this->settings['menu-options'] ); ?>
|
108 |
</div>
|
109 |
<p class="description">
|
110 |
-
<?php _e( 'Go to Appearance -> Menus to add Language Switcher Languages in any menu.',
|
111 |
</p>
|
112 |
</div>
|
113 |
<div class="trp-ls-type">
|
114 |
-
<label><input type="checkbox" id="trp-ls-floater" name="trp_settings[trp-ls-floater]" value="yes" <?php if ( isset($this->settings['trp-ls-floater']) && ( $this->settings['trp-ls-floater'] == 'yes' ) ){ echo 'checked'; } ?>><b><?php _e( 'Floating language selection',
|
115 |
<div>
|
116 |
<?php $this->output_language_switcher_select( 'floater-options', $this->settings['floater-options'] ); ?>
|
117 |
</div>
|
118 |
<p class="description">
|
119 |
-
<?php _e( 'Have a floating dropdown following the user on every page.',
|
120 |
</p>
|
121 |
</div>
|
122 |
</td>
|
2 |
<div id="trp-main-settings" class="wrap">
|
3 |
<form method="post" action="options.php">
|
4 |
<?php settings_fields( 'trp_settings' ); ?>
|
5 |
+
<h1> <?php _e( 'TranslatePress Settings', 'translatepress-multilingual' );?></h1>
|
6 |
<?php do_action ( 'trp_settings_navigation_tabs' ); ?>
|
7 |
|
8 |
<table id="trp-options" class="form-table">
|
9 |
<tr>
|
10 |
+
<th scope="row"><?php _e( 'Default Language', 'translatepress-multilingual' ); ?> </th>
|
11 |
<td>
|
12 |
<select id="trp-default-language" name="trp_settings[default-language]" class="trp-select2">
|
13 |
<?php
|
18 |
<?php }?>
|
19 |
</select>
|
20 |
<p class="description">
|
21 |
+
<?php _e( 'Select the original language your website was written in. ', 'translatepress-multilingual' ); ?>
|
22 |
</p>
|
23 |
</td>
|
24 |
</tr>
|
26 |
<?php do_action( 'trp_language_selector', $languages ); ?>
|
27 |
|
28 |
<tr>
|
29 |
+
<th scope="row"><?php _e( 'Native language name', 'translatepress-multilingual' ); ?> </th>
|
30 |
<td>
|
31 |
<select id="trp-g-translate" name="trp_settings[native_or_english_name]" class="trp-select">
|
32 |
+
<option value="english_name" <?php selected( $this->settings['native_or_english_name'], 'english_name' ); ?>><?php _e( 'No', 'translatepress-multilingual') ?></option>
|
33 |
+
<option value="native_name" <?php selected( $this->settings['native_or_english_name'], 'native_name' ); ?>><?php _e( 'Yes', 'translatepress-multilingual') ?></option>
|
34 |
</select>
|
35 |
<p class="description">
|
36 |
+
<?php _e( 'Select Yes if you want languages to display in their native names. Otherwise, they will be displayed in English.', 'translatepress-multilingual' ); ?>
|
37 |
</p>
|
38 |
</td>
|
39 |
</tr>
|
40 |
|
41 |
<tr>
|
42 |
+
<th scope="row"><?php _e( 'Use subdirectory for default language', 'translatepress-multilingual' ); ?> </th>
|
43 |
<td>
|
44 |
<select id="trp-g-translate" name="trp_settings[add-subdirectory-to-default-language]" class="trp-select">
|
45 |
+
<option value="no" <?php selected( $this->settings['add-subdirectory-to-default-language'], 'no' ); ?>><?php _e( 'No', 'translatepress-multilingual') ?></option>
|
46 |
+
<option value="yes" <?php selected( $this->settings['add-subdirectory-to-default-language'], 'yes' ); ?>><?php _e( 'Yes', 'translatepress-multilingual') ?></option>
|
47 |
</select>
|
48 |
<p class="description">
|
49 |
+
<?php _e( 'Select Yes if you want to add the subdirectory in the url for the default language.', 'translatepress-multilingual' ); ?>
|
50 |
</p>
|
51 |
</td>
|
52 |
</tr>
|
53 |
|
54 |
<tr>
|
55 |
+
<th scope="row"><?php _e( 'Force language in custom links', 'translatepress-multilingual' ); ?> </th>
|
56 |
<td>
|
57 |
<select id="trp-g-translate" name="trp_settings[force-language-to-custom-links]" class="trp-select">
|
58 |
+
<option value="no" <?php selected( $this->settings['force-language-to-custom-links'], 'no' ); ?>><?php _e( 'No', 'translatepress-multilingual') ?></option>
|
59 |
+
<option value="yes" <?php selected( $this->settings['force-language-to-custom-links'], 'yes' ); ?>><?php _e( 'Yes', 'translatepress-multilingual') ?></option>
|
60 |
</select>
|
61 |
<p class="description">
|
62 |
+
<?php _e( 'Select Yes if you want to force custom links without language encoding to add the subdirectory in the url for the default language.', 'translatepress-multilingual' ); ?>
|
63 |
</p>
|
64 |
</td>
|
65 |
</tr>
|
66 |
|
67 |
<tr>
|
68 |
+
<th scope="row"><?php _e( 'Google Translate', 'translatepress-multilingual' ); ?> </th>
|
69 |
<td>
|
70 |
<select id="trp-g-translate" name="trp_settings[g-translate]" class="trp-select">
|
71 |
+
<option value="no" <?php selected( $this->settings['g-translate'], 'no' ); ?>><?php _e( 'No', 'translatepress-multilingual') ?></option>
|
72 |
+
<option value="yes" <?php selected( $this->settings['g-translate'], 'yes' ); ?>><?php _e( 'Yes', 'translatepress-multilingual') ?></option>
|
73 |
</select>
|
74 |
<p class="description">
|
75 |
+
<?php _e( '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' ); ?>
|
76 |
</p>
|
77 |
</td>
|
78 |
</tr>
|
79 |
|
80 |
<tr>
|
81 |
+
<th scope="row"><?php _e( 'Google Translate API Key', 'translatepress-multilingual' ); ?> </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.", 'translatepress-multilingual' );'.</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. ', 'translatepress-multilingual' ); ?>
|
87 |
</p>
|
88 |
</td>
|
89 |
|
90 |
</tr>
|
91 |
|
92 |
<tr>
|
93 |
+
<th scope="row"><?php _e( 'Language Switcher', 'translatepress-multilingual' ); ?> </th>
|
94 |
<td>
|
95 |
<div class="trp-ls-type">
|
96 |
+
<input type="checkbox" disabled checked id="trp-ls-shortcode" ><b><?php _e( 'Shortcode ', 'translatepress-multilingual' ); ?>[language-switcher] </b>
|
97 |
<div>
|
98 |
<?php $this->output_language_switcher_select( 'shortcode-options', $this->settings['shortcode-options'] ); ?>
|
99 |
</div>
|
100 |
<p class="description">
|
101 |
+
<?php _e( 'Use shortcode on any page or widget.', 'translatepress-multilingual' ); ?>
|
102 |
</p>
|
103 |
</div>
|
104 |
<div class="trp-ls-type">
|
105 |
+
<label><input type="checkbox" id="trp-ls-menu" disabled checked ><b><?php _e( 'Menu item', 'translatepress-multilingual' ); ?></b></label>
|
106 |
<div>
|
107 |
<?php $this->output_language_switcher_select( 'menu-options', $this->settings['menu-options'] ); ?>
|
108 |
</div>
|
109 |
<p class="description">
|
110 |
+
<?php _e( 'Go to Appearance -> Menus to add Language Switcher Languages in any menu.', 'translatepress-multilingual' ); ?>
|
111 |
</p>
|
112 |
</div>
|
113 |
<div class="trp-ls-type">
|
114 |
+
<label><input type="checkbox" id="trp-ls-floater" name="trp_settings[trp-ls-floater]" value="yes" <?php if ( isset($this->settings['trp-ls-floater']) && ( $this->settings['trp-ls-floater'] == 'yes' ) ){ echo 'checked'; } ?>><b><?php _e( 'Floating language selection', 'translatepress-multilingual' ); ?></b></label>
|
115 |
<div>
|
116 |
<?php $this->output_language_switcher_select( 'floater-options', $this->settings['floater-options'] ); ?>
|
117 |
</div>
|
118 |
<p class="description">
|
119 |
+
<?php _e( 'Have a floating dropdown following the user on every page.', 'translatepress-multilingual' ); ?>
|
120 |
</p>
|
121 |
</div>
|
122 |
</td>
|
partials/test-google-key-settings-page.php
CHANGED
@@ -14,23 +14,23 @@ $response = wp_remote_post( "https://www.googleapis.com/language/translate/v2",
|
|
14 |
?>
|
15 |
<div id="trp-addons-page" class="wrap">
|
16 |
|
17 |
-
<h1> <?php _e( 'TranslatePress Settings',
|
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:',
|
23 |
|
24 |
-
<h3><?php _e('Response:',
|
25 |
<pre>
|
26 |
<?php print_r( $response["response"] ); ?>
|
27 |
</pre>
|
28 |
-
<h3><?php _e('Response Body:',
|
29 |
<pre>
|
30 |
<?php print_r( $response["body"] ); ?>
|
31 |
</pre>
|
32 |
|
33 |
-
<h3><?php _e('Entire Response From wp_remote_get():',
|
34 |
<pre>
|
35 |
<?php print_r( $response ); ?>
|
36 |
</pre>
|
14 |
?>
|
15 |
<div id="trp-addons-page" class="wrap">
|
16 |
|
17 |
+
<h1> <?php _e( 'TranslatePress Settings', 'translatepress-multilingual' );?></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:', 'translatepress-multilingual');?> <span style="font-family:monospace"><?php echo $this->settings['g-translate-key']; ?></span></h2>
|
23 |
|
24 |
+
<h3><?php _e('Response:', 'translatepress-multilingual');?></h3>
|
25 |
<pre>
|
26 |
<?php print_r( $response["response"] ); ?>
|
27 |
</pre>
|
28 |
+
<h3><?php _e('Response Body:', 'translatepress-multilingual');?></h3>
|
29 |
<pre>
|
30 |
<?php print_r( $response["body"] ); ?>
|
31 |
</pre>
|
32 |
|
33 |
+
<h3><?php _e('Entire Response From wp_remote_get():', 'translatepress-multilingual');?></h3>
|
34 |
<pre>
|
35 |
<?php print_r( $response ); ?>
|
36 |
</pre>
|
partials/translation-manager.php
CHANGED
@@ -43,11 +43,11 @@
|
|
43 |
<div id="trp-close-save">
|
44 |
<a id="trp-controls-close" href="#"></a>
|
45 |
<div id="trp-save-container">
|
46 |
-
<span id="trp-translation-saved" style="display: none"><?php _e( 'Saved!',
|
47 |
<span class="trp-ajax-loader" style="display: none" id="trp-string-saved-ajax-loader">
|
48 |
<div class="trp-spinner"></div>
|
49 |
</span>
|
50 |
-
<button id="trp-save" type="submit" class="button-primary trp-save-string"><?php _e( 'Save translation',
|
51 |
</div>
|
52 |
</div>
|
53 |
<div class="trp-controls-section">
|
@@ -61,16 +61,16 @@
|
|
61 |
<input type="hidden" name="trp-edit-translation" value="true">
|
62 |
</form>
|
63 |
<div id="trp-string-list">
|
64 |
-
<select id="trp-string-categories" data-trp-placeholder="<?php _e( 'Select string to translate...',
|
65 |
<option value="" class="default-option"></option>
|
66 |
<?php //add here an optiongroup so we know to add all the gettext strings below this and all the other strings above this ?>
|
67 |
-
<optgroup id="trp-gettext-strings-optgroup" label="<?php _e( 'Gettext strings',
|
68 |
</select>
|
69 |
</div>
|
70 |
|
71 |
<div id="trp-next-previous">
|
72 |
-
<button type="button" id="trp-previous" class="trp-next-previous-buttons"><span>«</span> <?php _e( 'Previous',
|
73 |
-
<button type="button" id="trp-next" class="trp-next-previous-buttons"><?php _e( 'Next',
|
74 |
</div>
|
75 |
|
76 |
</div>
|
@@ -79,32 +79,32 @@
|
|
79 |
</div>
|
80 |
<div class="trp-controls-section">
|
81 |
<div id="trp-translation-section" class="trp-controls-section-content">
|
82 |
-
<div id="trp-unsaved-changes-warning-message" style="display:none"><?php _e( 'You have unsaved changes!',
|
83 |
|
84 |
|
85 |
<?php //original strings for gettext textarea ?>
|
86 |
<div id="trp-gettext-original" class="trp-language-text trp-gettext-original-language" style="display:none">
|
87 |
-
<div class="trp-language-name"><?php _e( 'Original String',
|
88 |
<textarea id="trp-gettext-original-textarea" readonly="readonly"></textarea>
|
89 |
</div>
|
90 |
|
91 |
<div id="trp-language-<?php echo $trp_settings['default-language'];?>" class="trp-language-text trp-default-language">
|
92 |
<?php $default_language_name = $available_languages[ $trp_settings['default-language'] ];?>
|
93 |
-
<div class="trp-language-name" data-trp-gettext-language-name="<?php echo sprintf( __( 'To %s',
|
94 |
-
<?php echo sprintf( __( 'From %s',
|
95 |
</div>
|
96 |
<textarea id="trp-original" data-trp-language-code="<?php echo esc_attr( $trp_settings['default-language'] ); ?>" readonly="readonly"></textarea>
|
97 |
-
<div class="trp-discard-changes trp-discard-on-default-language" style="display:none;"><?php _e( 'Discard changes',
|
98 |
</div>
|
99 |
<?php
|
100 |
foreach( $translation_languages as $language ){?>
|
101 |
<div id="trp-language-<?php echo $language;?>" class="trp-language-text <?php echo ( $TRP_LANGUAGE == $trp_settings['default-language'] || $language == $TRP_LANGUAGE ) ? 'trp-current-language' : 'trp-other-language' ?>">
|
102 |
-
<div class="trp-language-name"><?php echo sprintf( __( 'To %s',
|
103 |
<textarea id="trp-translated-<?php echo $language; ?>" data-trp-translate-id="" data-trp-language-code="<?php echo esc_attr( $language ); ?>"></textarea>
|
104 |
-
<div class="trp-discard-changes"><?php _e( 'Discard changes',
|
105 |
</div>
|
106 |
<?php if ( $language == $TRP_LANGUAGE && count( $translation_languages ) > 1 ){
|
107 |
-
$other_languages = __( 'Other languages',
|
108 |
?>
|
109 |
<div id="trp-show-all-languages" class="trp-toggle-languages"><span>⯈ <?php echo $other_languages ?></span></div>
|
110 |
<div id="trp-hide-all-languages" class="trp-toggle-languages trp-toggle-languages-active"><span>⯆ <?php echo $other_languages ?></span></div>
|
@@ -117,9 +117,9 @@
|
|
117 |
<?php if( count( $trp_settings['translation-languages'] ) == 1 ) { ?>
|
118 |
<div class="trp-controls-section">
|
119 |
<div id="trp-translation-section" class="trp-controls-section-content">
|
120 |
-
<p><?php printf( __( 'You can add a new language from <a href="%s">Settings->TranslatePress</a>',
|
121 |
-
<p><?php _e( 'However, you can still use TranslatePress to <strong style="background: #f5fb9d;">modify gettext strings</strong> available in your page.',
|
122 |
-
<p><?php _e( 'Strings that are user created can\'t be modified, only those from themes and plugins.',
|
123 |
</div>
|
124 |
</div>
|
125 |
<?php } ?>
|
@@ -130,16 +130,16 @@
|
|
130 |
?>
|
131 |
<div class="trp-controls-section wp-core-ui">
|
132 |
<div id="trp-upsell-section" class="trp-controls-section-content">
|
133 |
-
<h3><?php _e('Your Website <br/> Multiple Languages',
|
134 |
<ul>
|
135 |
-
<li><?php _e('Support for 221 Languages',
|
136 |
-
<li><?php _e('Translate SEO Title, Description, Slug',
|
137 |
-
<li><?php _e('Translate Facebook Tags',
|
138 |
-
<li><?php _e('Create Translator Accounts',
|
139 |
-
<li><?php _e('Publish when the translation is done',
|
140 |
</ul>
|
141 |
-
<p><span style="background: #f5fb9d;"><?php _e('Supported By Real People',
|
142 |
-
<p><a class="button-primary" target="_blank" href="https://translatepress.com/pricing/?utm_source=wpbackend&utm_medium=clientsite&utm_content=tpeditor&utm_campaign=tpfree"><?php _e('Learn More',
|
143 |
</div>
|
144 |
</div>
|
145 |
<?php endif; ?>
|
43 |
<div id="trp-close-save">
|
44 |
<a id="trp-controls-close" href="#"></a>
|
45 |
<div id="trp-save-container">
|
46 |
+
<span id="trp-translation-saved" style="display: none"><?php _e( 'Saved!', 'translatepress-multilingual' ); ?></span>
|
47 |
<span class="trp-ajax-loader" style="display: none" id="trp-string-saved-ajax-loader">
|
48 |
<div class="trp-spinner"></div>
|
49 |
</span>
|
50 |
+
<button id="trp-save" type="submit" class="button-primary trp-save-string"><?php _e( 'Save translation', 'translatepress-multilingual' ); ?></button>
|
51 |
</div>
|
52 |
</div>
|
53 |
<div class="trp-controls-section">
|
61 |
<input type="hidden" name="trp-edit-translation" value="true">
|
62 |
</form>
|
63 |
<div id="trp-string-list">
|
64 |
+
<select id="trp-string-categories" data-trp-placeholder="<?php _e( 'Select string to translate...', 'translatepress-multilingual' ); ?>">
|
65 |
<option value="" class="default-option"></option>
|
66 |
<?php //add here an optiongroup so we know to add all the gettext strings below this and all the other strings above this ?>
|
67 |
+
<optgroup id="trp-gettext-strings-optgroup" label="<?php _e( 'Gettext strings', 'translatepress-multilingual' ); ?>"></optgroup>
|
68 |
</select>
|
69 |
</div>
|
70 |
|
71 |
<div id="trp-next-previous">
|
72 |
+
<button type="button" id="trp-previous" class="trp-next-previous-buttons"><span>«</span> <?php _e( 'Previous', 'translatepress-multilingual' ); ?></button>
|
73 |
+
<button type="button" id="trp-next" class="trp-next-previous-buttons"><?php _e( 'Next', 'translatepress-multilingual' ); ?> <span>»</span></button>
|
74 |
</div>
|
75 |
|
76 |
</div>
|
79 |
</div>
|
80 |
<div class="trp-controls-section">
|
81 |
<div id="trp-translation-section" class="trp-controls-section-content">
|
82 |
+
<div id="trp-unsaved-changes-warning-message" style="display:none"><?php _e( 'You have unsaved changes!', 'translatepress-multilingual' );?></div>
|
83 |
|
84 |
|
85 |
<?php //original strings for gettext textarea ?>
|
86 |
<div id="trp-gettext-original" class="trp-language-text trp-gettext-original-language" style="display:none">
|
87 |
+
<div class="trp-language-name"><?php _e( 'Original String', 'translatepress-multilingual' );?></div>
|
88 |
<textarea id="trp-gettext-original-textarea" readonly="readonly"></textarea>
|
89 |
</div>
|
90 |
|
91 |
<div id="trp-language-<?php echo $trp_settings['default-language'];?>" class="trp-language-text trp-default-language">
|
92 |
<?php $default_language_name = $available_languages[ $trp_settings['default-language'] ];?>
|
93 |
+
<div class="trp-language-name" data-trp-gettext-language-name="<?php echo sprintf( __( 'To %s', 'translatepress-multilingual' ), $default_language_name ); ?>" data-trp-default-language-name="<?php echo sprintf( __( 'From %s', 'translatepress-multilingual' ), $default_language_name ); ?>">
|
94 |
+
<?php echo sprintf( __( 'From %s', 'translatepress-multilingual' ), $default_language_name ); ?>
|
95 |
</div>
|
96 |
<textarea id="trp-original" data-trp-language-code="<?php echo esc_attr( $trp_settings['default-language'] ); ?>" readonly="readonly"></textarea>
|
97 |
+
<div class="trp-discard-changes trp-discard-on-default-language" style="display:none;"><?php _e( 'Discard changes', 'translatepress-multilingual' );?></div>
|
98 |
</div>
|
99 |
<?php
|
100 |
foreach( $translation_languages as $language ){?>
|
101 |
<div id="trp-language-<?php echo $language;?>" class="trp-language-text <?php echo ( $TRP_LANGUAGE == $trp_settings['default-language'] || $language == $TRP_LANGUAGE ) ? 'trp-current-language' : 'trp-other-language' ?>">
|
102 |
+
<div class="trp-language-name"><?php echo sprintf( __( 'To %s', 'translatepress-multilingual' ), $available_languages[ $language ] ); ?></div>
|
103 |
<textarea id="trp-translated-<?php echo $language; ?>" data-trp-translate-id="" data-trp-language-code="<?php echo esc_attr( $language ); ?>"></textarea>
|
104 |
+
<div class="trp-discard-changes"><?php _e( 'Discard changes', 'translatepress-multilingual' );?></div>
|
105 |
</div>
|
106 |
<?php if ( $language == $TRP_LANGUAGE && count( $translation_languages ) > 1 ){
|
107 |
+
$other_languages = __( 'Other languages', 'translatepress-multilingual' );
|
108 |
?>
|
109 |
<div id="trp-show-all-languages" class="trp-toggle-languages"><span>⯈ <?php echo $other_languages ?></span></div>
|
110 |
<div id="trp-hide-all-languages" class="trp-toggle-languages trp-toggle-languages-active"><span>⯆ <?php echo $other_languages ?></span></div>
|
117 |
<?php if( count( $trp_settings['translation-languages'] ) == 1 ) { ?>
|
118 |
<div class="trp-controls-section">
|
119 |
<div id="trp-translation-section" class="trp-controls-section-content">
|
120 |
+
<p><?php printf( __( 'You can add a new language from <a href="%s">Settings->TranslatePress</a>', 'translatepress-multilingual' ), admin_url( 'options-general.php?page=translate-press' ) );?></p>
|
121 |
+
<p><?php _e( 'However, you can still use TranslatePress to <strong style="background: #f5fb9d;">modify gettext strings</strong> available in your page.', 'translatepress-multilingual' );?></p>
|
122 |
+
<p><?php _e( 'Strings that are user created can\'t be modified, only those from themes and plugins.', 'translatepress-multilingual' );?></p>
|
123 |
</div>
|
124 |
</div>
|
125 |
<?php } ?>
|
130 |
?>
|
131 |
<div class="trp-controls-section wp-core-ui">
|
132 |
<div id="trp-upsell-section" class="trp-controls-section-content">
|
133 |
+
<h3><?php _e('Your Website <br/> Multiple Languages', 'translatepress-multilingual' ); ?></h3>
|
134 |
<ul>
|
135 |
+
<li><?php _e('Support for 221 Languages', 'translatepress-multilingual' ); ?></li>
|
136 |
+
<li><?php _e('Translate SEO Title, Description, Slug', 'translatepress-multilingual' ); ?></li>
|
137 |
+
<li><?php _e('Translate Facebook Tags', 'translatepress-multilingual' ); ?></li>
|
138 |
+
<li><?php _e('Create Translator Accounts', 'translatepress-multilingual' ); ?></li>
|
139 |
+
<li><?php _e('Publish when the translation is done', 'translatepress-multilingual' ); ?></li>
|
140 |
</ul>
|
141 |
+
<p><span style="background: #f5fb9d;"><?php _e('Supported By Real People', 'translatepress-multilingual' ); ?></span></p>
|
142 |
+
<p><a class="button-primary" target="_blank" href="https://translatepress.com/pricing/?utm_source=wpbackend&utm_medium=clientsite&utm_content=tpeditor&utm_campaign=tpfree"><?php _e('Learn More', 'translatepress-multilingual' ); ?></a></p>
|
143 |
</div>
|
144 |
</div>
|
145 |
<?php endif; ?>
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ 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.
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -107,6 +107,15 @@ For more information please check out [TranslatePress documentation](https://tra
|
|
107 |
|
108 |
== Changelog ==
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
= 1.0.7 =
|
111 |
* Fixed a small bug in js regarding the translation editor sidebar with
|
112 |
* Fixed Language Switcher for Woocommerce product categories and product tags going to 404 pages
|
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.9.0
|
7 |
+
Stable tag: 1.0.8
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
107 |
|
108 |
== Changelog ==
|
109 |
|
110 |
+
= 1.0.8 =
|
111 |
+
* We now allow HTML in normal strings translations.
|
112 |
+
* Changed the way we get the default language permalinks in Woocommerce rewrites
|
113 |
+
* Fixed issues with date_i18n function
|
114 |
+
* Fixed a warning generated when there are no rewrite rules
|
115 |
+
* Fixed dynamic strings not updating the translation dropdown list.
|
116 |
+
* Fixed issues with hidden space characters that were breaking some translations
|
117 |
+
* Make sure we don't loose the trp-edit-translation=preview from url after a WordPress redirect
|
118 |
+
|
119 |
= 1.0.7 =
|
120 |
* Fixed a small bug in js regarding the translation editor sidebar with
|
121 |
* Fixed Language Switcher for Woocommerce product categories and product tags going to 404 pages
|