TranslatePress – Translate Multilingual sites - Version 2.1.1

Version Description

  • Improved Custom Languages feature
  • Added possibility to easily edit existing language name or flag through Custom Language
  • Added vertical scroll on floating and shortcode language switchers when having many languages
Download this release

Release Info

Developer razvan.mo
Plugin Icon 128x128 TranslatePress – Translate Multilingual sites
Version 2.1.1
Comparing to
See all releases

Code changes from version 2.1.0 to 2.1.1

assets/css/trp-back-end-style.css CHANGED
@@ -1,7 +1,9 @@
1
  /* Free */
2
 
3
  table#trp-options td{
4
- padding-left: 28px;
 
 
5
  }
6
 
7
  span.select2-container{
@@ -189,7 +191,9 @@ input.trp-translation-published{
189
 
190
  table.trp-adst-list-option{
191
  width: 1px;
192
- margin-left: -30px
 
 
193
  }
194
  table.trp-adst-list-option td{
195
  padding: 5px;
@@ -222,6 +226,20 @@ table.trp-adst-list-option th{
222
  font-size: 15px;
223
  }
224
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  /* Add-ons page */
226
 
227
  .trp-add-ons-plugins-container{
1
  /* Free */
2
 
3
  table#trp-options td{
4
+ padding-left: 14px;
5
+ padding-right: 14px;
6
+
7
  }
8
 
9
  span.select2-container{
191
 
192
  table.trp-adst-list-option{
193
  width: 1px;
194
+ margin-left: -30px;
195
+ border-collapse: separate;
196
+ border-spacing: 0;
197
  }
198
  table.trp-adst-list-option td{
199
  padding: 5px;
226
  font-size: 15px;
227
  }
228
 
229
+ .trp_display_on_hover{
230
+ display: none;
231
+ }
232
+
233
+ .cuslangcode {
234
+ border-right-style: solid;
235
+ border-right-color: #0f0f0f;
236
+ }
237
+
238
+ .trp_lang_code{
239
+ border-right-style: solid;
240
+ border-right-color: #0f0f0f;
241
+ }
242
+
243
  /* Add-ons page */
244
 
245
  .trp-add-ons-plugins-container{
assets/css/trp-floater-language-switcher.css CHANGED
@@ -202,4 +202,9 @@ body.admin-bar #trp-floater-ls.trp-top-left{
202
 
203
  #trp-floater-ls a {
204
  text-decoration: none;
 
 
 
 
 
205
  }
202
 
203
  #trp-floater-ls a {
204
  text-decoration: none;
205
+ }
206
+
207
+ #trp-floater-ls-language-list{
208
+ max-height: 300px;
209
+ overflow-y: auto;
210
  }
assets/css/trp-language-switcher.css CHANGED
@@ -16,7 +16,6 @@
16
  */
17
  .trp-language-switcher{
18
  position: relative;
19
- width: auto;
20
  display: inline-block;
21
  padding: 0;
22
  border: 0;
@@ -92,13 +91,15 @@
92
 
93
  .trp-language-switcher:focus .trp-ls-shortcode-language,
94
  .trp-language-switcher:hover .trp-ls-shortcode-language{
 
 
 
95
  visibility:visible;
96
- height:auto;
97
  position: absolute;
98
  left: 0;
99
  top: 0;
100
  display: inline-block !important;
101
-
102
  }
103
 
104
  /*
16
  */
17
  .trp-language-switcher{
18
  position: relative;
 
19
  display: inline-block;
20
  padding: 0;
21
  border: 0;
91
 
92
  .trp-language-switcher:focus .trp-ls-shortcode-language,
93
  .trp-language-switcher:hover .trp-ls-shortcode-language{
94
+ max-height: 250px;
95
+ height: auto;
96
+ overflow-y: auto;
97
  visibility:visible;
 
98
  position: absolute;
99
  left: 0;
100
  top: 0;
101
  display: inline-block !important;
102
+ min-height: auto;
103
  }
104
 
105
  /*
class-translate-press.php CHANGED
@@ -58,7 +58,7 @@ class TRP_Translate_Press{
58
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
59
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
60
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
61
- define( 'TRP_PLUGIN_VERSION', '2.1.0' );
62
 
63
  wp_cache_add_non_persistent_groups(array('trp'));
64
 
58
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
59
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
60
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
61
+ define( 'TRP_PLUGIN_VERSION', '2.1.1' );
62
 
63
  wp_cache_add_non_persistent_groups(array('trp'));
64
 
includes/advanced-settings/custom-language.php CHANGED
@@ -16,18 +16,22 @@ add_filter('trp_register_advanced_settings', 'trp_register_custom_language', 228
16
  */
17
  function trp_register_custom_language($settings_array){
18
 
 
19
  $settings_array[] = array(
20
  'name' => 'custom_language',
21
  'columns' => array (
22
- 'cuslangname' => array ('label' => esc_html__( 'Language name', 'translatepress-multilingual' ), 'type' => 'text', 'values' => '' ),
23
- 'cuslangnative' => array ('label' => esc_html__( 'Native name', 'translatepress-multilingual' ), 'type' => 'text', 'values' => '' ),
24
- 'cuslangiso' => array ('label' => esc_html__( 'ISO code', 'translatepress-multilingual' ), 'type' => 'text', 'values' => '' ),
25
- 'cuslangflag' => array ('label' => esc_html__( 'Flag URL', 'translatepress-multilingual' ), 'type' => 'textarea', 'values' => '' ),
26
- 'cuslangisrtl' => array ('label' => esc_html__( 'Text RTL', 'translatepress-multilingual' ), 'type' => 'checkbox', 'values' => '' ),
 
 
27
  ),
28
  'type' => 'mixed',
29
  'label' => esc_html__( 'Custom language', 'translatepress-multilingual' ),
30
- 'description' => wp_kses( __( 'Adds custom languages to TranslatePress.<br>Will be available under General settings, All Languages list, where the URL slug can also be edited.<br>For custom flag, first upload the image in media library then paste the URL.<br>Changing or deleting a custom language will impact translations and site URL\'s.<br> The ISO code will be used for automatic translation if supported.', 'translatepress-multilingual' ), array( 'br' => array() )),
 
31
 
32
  );
33
 
16
  */
17
  function trp_register_custom_language($settings_array){
18
 
19
+ $text = wp_kses( __( 'To edit an existing TranslatePress language, input the language code and fill in only the columns you want to overwrite (e.g. Language name, Flag).<br>You can also add new custom languages. They will be available under General settings, All Languages list, where the URL slug can be edited.<br>For custom flag, first upload the image in media library then paste the URL.<br>Changing or deleting a custom language will impact translations and site URL\'s.<br>The Language code and the Automatic Translation Code should contain only alphabetical values, numerical values, "-" and "_".<br>The Automatic Translation codes can be found on <a href = "https://cloud.google.com/translate/docs/languages" target = "_blank">Google ISO Codes</a> and <a href = "https://www.deepl.com/docs-api/translating-text/" target = "_blank">DeepL Target Codes</a>.' , 'translatepress-multilingual' ), array( 'br' => array(), 'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ) ));
20
  $settings_array[] = array(
21
  'name' => 'custom_language',
22
  'columns' => array (
23
+
24
+ 'cuslangcode' => array ('label' => esc_html__( 'Language code', 'translatepress-multilingual' ), 'type' => 'text', 'values' => '', 'placeholder' => 'e. g. en_US', 'required' => true ),
25
+ 'cuslangname' => array ('label' => esc_html__( 'Language name', 'translatepress-multilingual' ), 'type' => 'text', 'values' => '', 'placeholder' => '', 'required' => false ),
26
+ 'cuslangnative' => array ('label' => esc_html__( 'Native name', 'translatepress-multilingual' ), 'type' => 'text', 'values' => '', 'placeholder' => '', 'required' => false ),
27
+ 'cuslangiso' => array ('label' => esc_html__( 'Automatic translation code', 'translatepress-multilingual' ), 'type' => 'text', 'values' => '', 'placeholder' => 'e. g. en', 'required' => false ),
28
+ 'cuslangflag' => array ('label' => esc_html__( 'Flag URL', 'translatepress-multilingual' ), 'type' => 'textarea', 'values' => '', 'placeholder' => '', 'required' => false ),
29
+ 'cuslangisrtl' => array ('label' => esc_html__( 'Text RTL', 'translatepress-multilingual' ), 'type' => 'checkbox', 'values' => '', 'placeholder' => '', 'required' => false ),
30
  ),
31
  'type' => 'mixed',
32
  'label' => esc_html__( 'Custom language', 'translatepress-multilingual' ),
33
+ /* phpcs:ignore */
34
+ 'description' => $text,
35
 
36
  );
37
 
includes/class-advanced-tab.php CHANGED
@@ -111,8 +111,9 @@ class TRP_Advanced_Tab {
111
  */
112
  {
113
  $settings[ $registered_setting['name'] ] = array();
 
114
  foreach ( $registered_setting['columns'] as $column => $column_name ) {
115
- $one_column = $column;
116
  $settings[ $registered_setting['name'] ][ $column ] = array();
117
  if ( isset($submitted_settings[ $registered_setting['name'] ][ $column ] ) ) {
118
  foreach ($submitted_settings[$registered_setting['name']][$column] as $key => $value) {
@@ -175,9 +176,12 @@ class TRP_Advanced_Tab {
175
  }
176
 
177
  } //end foreach of parsing all the registered settings array
178
- add_settings_error( 'trp_advanced_settings', 'settings_updated', __( 'Settings saved.', 'translatepress-multilingual' ), 'updated' );
179
 
180
- return apply_filters( 'trp_extra_sanitize_advanced_settings', $settings, $submitted_settings );
 
 
 
 
181
  }
182
 
183
  /*
@@ -554,7 +558,12 @@ class TRP_Advanced_Tab {
554
  <thead>
555
  ";
556
  foreach( $setting['columns'] as $option_name => $option_details ){
557
- $html .= '<th><strong>' . esc_html( $option_details['label'] ) . '</strong></th>';
 
 
 
 
 
558
  }
559
 
560
  //"Remove" button
@@ -569,7 +578,7 @@ class TRP_Advanced_Tab {
569
  break;
570
  }
571
 
572
- if ( isset( $adv_option[ $setting['name'] ] ) && is_array( $adv_option[ $setting['name'] ] ) ) {
573
  foreach ( $adv_option[ $setting['name'] ][ $first_column ] as $index => $value ) {
574
 
575
  $html .= "<tr class='trp-list-entry'>";
@@ -577,7 +586,8 @@ class TRP_Advanced_Tab {
577
  foreach ( $setting['columns'] as $option_name => $option_details ) {
578
  switch ( $option_details['type']) {
579
  case 'text':
580
- $html .= "<td><input class='trp_narrow_input' type='text' name='trp_advanced_settings[" . esc_attr( $setting['name'] ) . "][" . esc_attr( $option_name ) . "][]' value='" . htmlspecialchars($adv_option[ $setting['name'] ][ $option_name ][ $index ], ENT_QUOTES) . "' ></td>";
 
581
  break;
582
  case 'textarea':
583
  $html .= "<td><textarea class='trp_narrow_input' name='trp_advanced_settings[" . esc_attr( $setting['name'] ) . "][" . esc_attr( $option_name ) . "][]'>" . htmlspecialchars($adv_option[ $setting['name'] ][ $option_name ][ $index ], ENT_QUOTES) . "</textarea></td>";
@@ -611,7 +621,7 @@ class TRP_Advanced_Tab {
611
 
612
  switch ( $option_details['type']) {
613
  case 'text':
614
- $html .= "<td><input type='text' class='trp_narrow_input' id='new_entry_" . esc_attr( $setting['name'] ) . "_" . esc_attr( $option_name ) . "' data-name='trp_advanced_settings[" . esc_attr( $setting['name'] ) . "][" . esc_attr( $option_name ) . "][]' data-setting-name='" . esc_attr( $setting['name'] ) . "' data-column-name='" . esc_attr( $option_name ) . "'></input></td>";
615
  break;
616
  case 'textarea':
617
  $html .= "<td class='trp_narrow_input'><textarea id='new_entry_" . esc_attr( $setting['name'] ) . "_" . esc_attr( $option_name ) . "' data-name='trp_advanced_settings[" . esc_attr( $setting['name'] ) . "][" . esc_attr( $option_name ) . "][]' data-setting-name='" . esc_attr( $setting['name'] ) . "' data-column-name='" . esc_attr( $option_name ) . "'></textarea></td>";
111
  */
112
  {
113
  $settings[ $registered_setting['name'] ] = array();
114
+ $one_column = '';
115
  foreach ( $registered_setting['columns'] as $column => $column_name ) {
116
+ $one_column = ( empty ( $one_column ) && !(is_array($column_name) && $column_name ['type'] === 'checkbox') ) ? $column : $one_column;
117
  $settings[ $registered_setting['name'] ][ $column ] = array();
118
  if ( isset($submitted_settings[ $registered_setting['name'] ][ $column ] ) ) {
119
  foreach ($submitted_settings[$registered_setting['name']][$column] as $key => $value) {
176
  }
177
 
178
  } //end foreach of parsing all the registered settings array
 
179
 
180
+ if ( apply_filters( 'trp_saving_advanced_settings_is_successful', true, $settings, $submitted_settings ) ) {
181
+ add_settings_error( 'trp_advanced_settings', 'settings_updated', esc_html__( 'Settings saved.', 'translatepress-multilingual' ), 'updated' );
182
+ }
183
+
184
+ return apply_filters( 'trp_extra_sanitize_advanced_settings', $settings, $submitted_settings, $prev_settings );
185
  }
186
 
187
  /*
558
  <thead>
559
  ";
560
  foreach( $setting['columns'] as $option_name => $option_details ){
561
+ if(isset($setting['columns'][$option_name]['required']) && $setting['columns'][$option_name]['required'] === true){
562
+ $html .= '<th class="trp_lang_code"><strong>' . esc_html( $option_details['label'] ). '<span title="Required"> *</span> </strong></th>';
563
+ }else{
564
+ $html .= '<th><strong>' . esc_html( $option_details['label'] ) . '</strong></th>';
565
+ }
566
+
567
  }
568
 
569
  //"Remove" button
578
  break;
579
  }
580
 
581
+ if ( isset( $adv_option[ $setting['name'] ] ) && is_array( $adv_option[ $setting['name'] ] )) {
582
  foreach ( $adv_option[ $setting['name'] ][ $first_column ] as $index => $value ) {
583
 
584
  $html .= "<tr class='trp-list-entry'>";
586
  foreach ( $setting['columns'] as $option_name => $option_details ) {
587
  switch ( $option_details['type']) {
588
  case 'text':
589
+ $html .= "<td class=' ". $option_name ." '><input class='trp_narrow_input' type='text' name='trp_advanced_settings[" . esc_attr( $setting['name'] ) . "][" . esc_attr( $option_name ) . "][]' value='" . htmlspecialchars($adv_option[ $setting['name'] ][ $option_name ][ $index ], ENT_QUOTES) . "'></td>";
590
+
591
  break;
592
  case 'textarea':
593
  $html .= "<td><textarea class='trp_narrow_input' name='trp_advanced_settings[" . esc_attr( $setting['name'] ) . "][" . esc_attr( $option_name ) . "][]'>" . htmlspecialchars($adv_option[ $setting['name'] ][ $option_name ][ $index ], ENT_QUOTES) . "</textarea></td>";
621
 
622
  switch ( $option_details['type']) {
623
  case 'text':
624
+ $html .= "<td class=' " . $option_name . " '><input type='text' class='trp_narrow_input' id='new_entry_" . esc_attr( $setting['name'] ) . "_" . esc_attr( $option_name ) . "' data-name='trp_advanced_settings[" . esc_attr( $setting['name'] ) . "][" . esc_attr( $option_name ) . "][]' data-setting-name='" . esc_attr( $setting['name'] ) . "' data-column-name='" . esc_attr( $option_name ) . "' placeholder='" . esc_attr( $setting['columns'][ $option_name ]['placeholder'] ) . "' '></input></td>";
625
  break;
626
  case 'textarea':
627
  $html .= "<td class='trp_narrow_input'><textarea id='new_entry_" . esc_attr( $setting['name'] ) . "_" . esc_attr( $option_name ) . "' data-name='trp_advanced_settings[" . esc_attr( $setting['name'] ) . "][" . esc_attr( $option_name ) . "][]' data-setting-name='" . esc_attr( $setting['name'] ) . "' data-column-name='" . esc_attr( $option_name ) . "'></textarea></td>";
includes/class-upgrade.php CHANGED
@@ -72,6 +72,9 @@ class TRP_Upgrade {
72
  if ( version_compare($stored_database_version, '1.9.8', '<=')) {
73
  $this->set_force_slash_at_end_of_links();
74
  }
 
 
 
75
  }
76
 
77
  // don't update the db version unless they are different. Otherwise the query is run on every page load.
@@ -671,6 +674,20 @@ class TRP_Upgrade {
671
 
672
  }
673
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
674
 
675
  public function trp_remove_duplicate_original_strings(){
676
  if ( ! $this->trp_query ) {
72
  if ( version_compare($stored_database_version, '1.9.8', '<=')) {
73
  $this->set_force_slash_at_end_of_links();
74
  }
75
+ if ( version_compare($stored_database_version, '2.1.0', '<=')){
76
+ $this->add_iso_code_to_language_code();
77
+ }
78
  }
79
 
80
  // don't update the db version unless they are different. Otherwise the query is run on every page load.
674
 
675
  }
676
 
677
+ public function add_iso_code_to_language_code(){
678
+ $trp = TRP_Translate_Press::get_trp_instance();
679
+ $trp_settings = $trp->get_component('settings' );
680
+ $settings = $trp_settings->get_settings();
681
+
682
+ if(isset($settings['trp_advanced_settings']) && isset($settings['trp_advanced_settings']['custom_language']) ){
683
+ $advanced_settings = $settings['trp_advanced_settings'];
684
+ if(!isset($advanced_settings['custom_language']['cuslangcode'])){
685
+ $advanced_settings['custom_language']['cuslangcode'] = $advanced_settings['custom_language']['cuslangiso'];
686
+ }
687
+ update_option('trp_advanced_settings', $advanced_settings);
688
+ }
689
+ }
690
+
691
 
692
  public function trp_remove_duplicate_original_strings(){
693
  if ( ! $this->trp_query ) {
includes/custom-language.php CHANGED
@@ -19,16 +19,33 @@ function trpc_add_custom_language( $languages ) {
19
 
20
  foreach ( $option['custom_language']['cuslangname'] as $key => $value ) {
21
 
22
- $lang = $option["custom_language"]["cuslangiso"][ $key ];
23
 
24
- if ( array_key_exists( $lang, $languages ) ) {
25
- return $languages;
26
- }
 
 
27
 
28
  $custom_language_iso = $option["custom_language"]["cuslangiso"][ $key ];
29
  $custom_language_name = $option["custom_language"]["cuslangname"][ $key ];
30
  $custom_language_native = $option["custom_language"]["cuslangnative"][ $key ];
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  $languages[ $lang ] = array(
33
  'language' => $lang,
34
  'english_name' => $custom_language_name,
@@ -56,8 +73,8 @@ function trpc_language_rtl($translated, $text, $context, $domain){
56
 
57
  if ( isset( $option['custom_language'] ) ) {
58
  foreach ( $option['custom_language']['cuslangname'] as $key => $value ) {
59
- $custom_language_iso = $option["custom_language"]["cuslangiso"][$key];
60
- if($text == 'ltr' && $context == "text direction" && isset($option["custom_language"]["cuslangisrtl"][0]) && $option["custom_language"]["cuslangisrtl"][0] === 'yes' && $TRP_LANGUAGE === $custom_language_iso){
61
  $translated = 'rtl';
62
  }
63
  }
@@ -84,7 +101,7 @@ function trpc_flags_path_custom( $original_flags_path, $language_code ) {
84
 
85
  if ( isset( $option['custom_language'] ) ) {
86
  foreach ( $option['custom_language']['cuslangname'] as $key => $value ) {
87
- if ($language_code === $option["custom_language"]["cuslangiso"][$key] ) {
88
  $attachment_array = wp_get_attachment_image_src(attachment_url_to_postid($option["custom_language"]["cuslangflag"][ $key ]), 'trp-custom-language-flag');
89
  return isset($attachment_array) ? $attachment_array[0] : $option["custom_language"]["cuslangflag"][ $key ];
90
  }
@@ -110,10 +127,107 @@ function trpc_flag_name_custom ( $original_flags_path, $language_code ){
110
  $option = get_option( 'trp_advanced_settings', true );
111
  if ( isset( $option['custom_language'] ) ) {
112
  foreach ( $option['custom_language']['cuslangname'] as $key => $value ) {
113
- if ($language_code === $option["custom_language"]["cuslangiso"][$key] ) {
114
  return '';
115
  }
116
  }
117
  }
118
  return $original_flags_path;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  }
19
 
20
  foreach ( $option['custom_language']['cuslangname'] as $key => $value ) {
21
 
 
22
 
23
+ if(isset($option["custom_language"]["cuslangcode"][ $key ])) {
24
+ $lang = $option["custom_language"]["cuslangcode"][$key];
25
+ }else{
26
+ $lang = $option["custom_language"]["cuslangiso"][ $key ];
27
+ }
28
 
29
  $custom_language_iso = $option["custom_language"]["cuslangiso"][ $key ];
30
  $custom_language_name = $option["custom_language"]["cuslangname"][ $key ];
31
  $custom_language_native = $option["custom_language"]["cuslangnative"][ $key ];
32
 
33
+ if ( array_key_exists( $lang, $languages ) ) {
34
+ if(empty( $custom_language_name )){
35
+ $custom_language_name = $languages[$lang]['english_name'];
36
+ }
37
+ if(empty( $custom_language_native )){
38
+ $custom_language_native = $languages[$lang]['native_name'];
39
+ }
40
+ if(empty( $custom_language_iso )){
41
+ $custom_language_iso = reset($languages[$lang]['iso']);
42
+ }
43
+ }else{
44
+ if( empty($custom_language_iso) && isset($option["custom_language"]["cuslangcode"][ $key ])){
45
+ $custom_language_iso = $option["custom_language"]["cuslangcode"][$key];
46
+ }
47
+ }
48
+
49
  $languages[ $lang ] = array(
50
  'language' => $lang,
51
  'english_name' => $custom_language_name,
73
 
74
  if ( isset( $option['custom_language'] ) ) {
75
  foreach ( $option['custom_language']['cuslangname'] as $key => $value ) {
76
+ $custom_language_code = $option["custom_language"]["cuslangcode"][$key];
77
+ if($text == 'ltr' && $context == "text direction" && isset($option["custom_language"]["cuslangisrtl"][$key]) && $option["custom_language"]["cuslangisrtl"][$key] === 'yes' && $TRP_LANGUAGE === $custom_language_code){
78
  $translated = 'rtl';
79
  }
80
  }
101
 
102
  if ( isset( $option['custom_language'] ) ) {
103
  foreach ( $option['custom_language']['cuslangname'] as $key => $value ) {
104
+ if ($language_code === $option["custom_language"]["cuslangcode"][$key] && !empty($option["custom_language"]["cuslangflag"][$key]) ) {
105
  $attachment_array = wp_get_attachment_image_src(attachment_url_to_postid($option["custom_language"]["cuslangflag"][ $key ]), 'trp-custom-language-flag');
106
  return isset($attachment_array) ? $attachment_array[0] : $option["custom_language"]["cuslangflag"][ $key ];
107
  }
127
  $option = get_option( 'trp_advanced_settings', true );
128
  if ( isset( $option['custom_language'] ) ) {
129
  foreach ( $option['custom_language']['cuslangname'] as $key => $value ) {
130
+ if ($language_code === $option["custom_language"]["cuslangcode"][$key] && !empty($option["custom_language"]["cuslangflag"][$key])) {
131
  return '';
132
  }
133
  }
134
  }
135
  return $original_flags_path;
136
+
137
+ }
138
+
139
+ add_filter('trp_saving_advanced_settings_is_successful', 'trp_add_messages_custom_language_codes', 10, 3);
140
+
141
+ /**
142
+ * The function verifies if the language codes and ISO codes written by the user contain only the allowed characters, A-Z a-z 0-9 _ - and if the language code is unique among other custom languages and existing languages.
143
+ *
144
+ * @param bool $is_correct_code retains if the language code and the ISO code are valid or not
145
+ * @param $settings
146
+ * @param $submitted_settings
147
+ */
148
+
149
+ function trp_verify_custom_language_codes($is_correct_code, $settings){
150
+
151
+ if(isset($settings['custom_language']['cuslangcode'])) {
152
+ foreach ($settings['custom_language']['cuslangcode'] as $key => $item) {
153
+ if (!empty($settings['custom_language']['cuslangcode'][$key])) {
154
+ if (!trp_is_valid_language_code($item)) {
155
+ $is_correct_code = false;
156
+
157
+ return array(
158
+ 'message' => esc_html__('The Language code of the added custom language is invalid.','translatepress-multilingual'),
159
+ 'correct_code' => $is_correct_code
160
+ );
161
+ }
162
+ }
163
+ }
164
+ }
165
+
166
+ if(isset($settings['custom_language']['cuslangiso'])) {
167
+ foreach ($settings['custom_language']['cuslangiso'] as $key => $item) {
168
+ if(!empty($settings['custom_language']['cuslangiso'][$key])){
169
+ if (!trp_is_valid_language_code($item)) {
170
+ $is_correct_code = false;
171
+
172
+ return array(
173
+ 'message' => esc_html__('The Automatic Translation Code of the added custom language is invalid.', 'translatepress-multilingual'),
174
+ 'correct_code' => $is_correct_code
175
+ );
176
+ }
177
+ }
178
+ }
179
+ }
180
+
181
+ foreach ($settings['custom_language']['cuslangcode'] as $item) {
182
+ if (empty($item)) {
183
+ $is_correct_code = false;
184
+ return array(
185
+ 'message' => esc_html__('The Language code of the added custom language cannot be empty.', 'translatepress-multilingual'),
186
+ 'correct_code' => $is_correct_code
187
+ );
188
+ }
189
+ }
190
+
191
+ return array(
192
+ 'message' => '',
193
+ 'correct_code' => $is_correct_code
194
+ );
195
+
196
+ }
197
+
198
+ function trp_add_messages_custom_language_codes($correct_code=true, $settings, $submitted_settings){
199
+
200
+ $correct_code_custom_language = trp_verify_custom_language_codes(true, $settings);
201
+
202
+ if($correct_code_custom_language['correct_code'] === false){
203
+ /* phpcs:ignore */
204
+ add_settings_error( 'trp_advanced_settings', 'settings_error', esc_html($correct_code_custom_language['message']), 'error' );
205
+ $correct_code = false;
206
+
207
+ return $correct_code;
208
+ }
209
+ return $correct_code;
210
+ }
211
+
212
+
213
+ add_filter('trp_extra_sanitize_advanced_settings', 'trp_save_settings_language', 10, 3);
214
+
215
+ /**
216
+ * The custom language is saved only if the codes are correct.
217
+ * @param $settings
218
+ * @param $submitted_settings
219
+ * @param $prev_settings
220
+ * @return mixed
221
+ */
222
+
223
+ function trp_save_settings_language($settings, $submitted_settings, $prev_settings){
224
+
225
+ $correct_custom_languagea_code = trp_verify_custom_language_codes(true, $settings);
226
+
227
+ if($correct_custom_languagea_code['correct_code'] === false) {
228
+ $settings['custom_language'] = $prev_settings['custom_language'];
229
+ }
230
+
231
+ return $settings;
232
+
233
  }
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 using a visual front-end translation editor, with full support for WooCommerce and site builders.
6
- Version: 2.1.0
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
3
  Plugin Name: TranslatePress - Multilingual
4
  Plugin URI: https://translatepress.com/
5
  Description: Experience a better way of translating your WordPress site using a visual front-end translation editor, with full support for WooCommerce and site builders.
6
+ Version: 2.1.1
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
languages/translatepress-multilingual.catalog.php CHANGED
@@ -1,6 +1,9 @@
1
  <?php __("", "translatepress-multilingual"); ?>
 
 
2
  <?php __("Please update the TranslatePress - Multilingual plugin to version 2.0.5 at least for %s to work properly", "translatepress-multilingual"); ?>
3
  <?php __("Please install and activate the TranslatePress - Multilingual plugin", "translatepress-multilingual"); ?>
 
4
  <?php __("This TranslatePress add-on has been migrated to the main plugin and is no longer used. You can delete it.", "translatepress-multilingual"); ?>
5
  <?php __("<strong>TranslatePress</strong> requires at least PHP version 5.6.20+ to run. It is the <a href=\"%s\">minimum requirement of the latest WordPress version</a>. Please contact your server administrator to update your PHP version.", "translatepress-multilingual"); ?>
6
  <?php __("Advanced", "translatepress-multilingual"); ?>
@@ -58,7 +61,6 @@
58
  <?php __("Test it to see if everything is working. If something went wrong, you can restore the backup that you've made at the first step. Check if no more errors occur while browsing your website in a translated language. Look at the timestamps of the errors to make sure you are not seeing the old errors. Only the most recent 5 errors are displayed.", "translatepress-multilingual"); ?>
59
  <?php __("Plan C.", "translatepress-multilingual"); ?>
60
  <?php __("If your problem still isn't solved, try asking your hosting about your errors. The most common issue is missing permissions for the SQL user, such as the Create Tables permission.", "translatepress-multilingual"); ?>
61
- <?php __("Could not install. Try again from <a href=\"%s\" >Plugins Dashboard.</a>", "translatepress-multilingual"); ?>
62
  <?php __("Active", "translatepress-multilingual"); ?>
63
  <?php __("Automatic Translation", "translatepress-multilingual"); ?>
64
  <?php __("DeepL", "translatepress-multilingual"); ?>
@@ -94,7 +96,6 @@
94
  <?php __("Top Left", "translatepress-multilingual"); ?>
95
  <?php __("Dark", "translatepress-multilingual"); ?>
96
  <?php __("Light", "translatepress-multilingual"); ?>
97
- <?php __("Install & Activate", "translatepress-multilingual"); ?>
98
  <?php __("Error! Duplicate URL slug values.", "translatepress-multilingual"); ?>
99
  <?php __("Current Language", "translatepress-multilingual"); ?>
100
  <?php __("General", "translatepress-multilingual"); ?>
@@ -213,6 +214,9 @@
213
  <?php __("<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server.", "translatepress-multilingual"); ?>
214
  <?php __("Detected long query limitation on WPEngine hosting. Some large pages may appear untranslated. You can remove limitation by adding the following to your site’s wp-config.php: define( 'WPE_GOVERNOR', false ); ", "translatepress-multilingual"); ?>
215
  <?php __("Custom Language Flag", "translatepress-multilingual"); ?>
 
 
 
216
  <?php __("TranslatePress Settings", "translatepress-multilingual"); ?>
217
  <?php __("TranslatePress Add-ons", "translatepress-multilingual"); ?>
218
  <?php __("You must first purchase this version to have access to the addon %1$shere%2$s", "translatepress-multilingual"); ?>
@@ -278,6 +282,7 @@
278
  <?php __("Slug", "translatepress-multilingual"); ?>
279
  <?php __("Are you sure you want to remove this language?", "translatepress-multilingual"); ?>
280
  <?php __("Choose...", "translatepress-multilingual"); ?>
 
281
  <?php __("Select the language you wish to make your website available in.", "translatepress-multilingual"); ?>
282
  <?php __("To add <strong>more than two languages</strong> and support for SEO Title, Description, Slug and more check out <a href=\"%1$s\" target=\"_blank\" title=\"%2$s\">%2$s</a>.", "translatepress-multilingual"); ?>
283
  <?php __("TranslatePress Advanced Add-ons", "translatepress-multilingual"); ?>
@@ -325,13 +330,14 @@
325
  <?php __("Limit this menu item to the following languages", "translatepress-multilingual"); ?>
326
  <?php __("Date format", "translatepress-multilingual"); ?>
327
  <?php __("Customize the date formatting per each translated language.<br/>Leave empty for default WP setting or see more information <a href=\"https://wordpress.org/support/article/formatting-date-and-time/\" title=\"Formatting Date and Time\" target=\"_blank\">here</a>", "translatepress-multilingual"); ?>
 
 
328
  <?php __("Language name", "translatepress-multilingual"); ?>
329
  <?php __("Native name", "translatepress-multilingual"); ?>
330
- <?php __("ISO code", "translatepress-multilingual"); ?>
331
  <?php __("Flag URL", "translatepress-multilingual"); ?>
332
  <?php __("Text RTL", "translatepress-multilingual"); ?>
333
  <?php __("Custom language", "translatepress-multilingual"); ?>
334
- <?php __("Adds custom languages to TranslatePress.<br>Will be available under General settings, All Languages list, where the URL slug can also be edited.<br>For custom flag, first upload the image in media library then paste the URL.<br>Changing or deleting a custom language will impact translations and site URL's.<br> The ISO code will be used for automatic translation if supported.", "translatepress-multilingual"); ?>
335
  <?php __("Disable dynamic translation", "translatepress-multilingual"); ?>
336
  <?php __("It disables detection of strings displayed dynamically using JavaScript. <br/>Strings loaded via a server side AJAX call will still be translated.", "translatepress-multilingual"); ?>
337
  <?php __("Exclude translated links from sitemap", "translatepress-multilingual"); ?>
1
  <?php __("", "translatepress-multilingual"); ?>
2
+ <?php __("Plugin activated.", "translatepress-multilingual"); ?>
3
+ <?php __("Could not install. Try again from <a href=\"%s\" >Plugins Dashboard.</a>", "translatepress-multilingual"); ?>
4
  <?php __("Please update the TranslatePress - Multilingual plugin to version 2.0.5 at least for %s to work properly", "translatepress-multilingual"); ?>
5
  <?php __("Please install and activate the TranslatePress - Multilingual plugin", "translatepress-multilingual"); ?>
6
+ <?php __("Install & Activate", "translatepress-multilingual"); ?>
7
  <?php __("This TranslatePress add-on has been migrated to the main plugin and is no longer used. You can delete it.", "translatepress-multilingual"); ?>
8
  <?php __("<strong>TranslatePress</strong> requires at least PHP version 5.6.20+ to run. It is the <a href=\"%s\">minimum requirement of the latest WordPress version</a>. Please contact your server administrator to update your PHP version.", "translatepress-multilingual"); ?>
9
  <?php __("Advanced", "translatepress-multilingual"); ?>
61
  <?php __("Test it to see if everything is working. If something went wrong, you can restore the backup that you've made at the first step. Check if no more errors occur while browsing your website in a translated language. Look at the timestamps of the errors to make sure you are not seeing the old errors. Only the most recent 5 errors are displayed.", "translatepress-multilingual"); ?>
62
  <?php __("Plan C.", "translatepress-multilingual"); ?>
63
  <?php __("If your problem still isn't solved, try asking your hosting about your errors. The most common issue is missing permissions for the SQL user, such as the Create Tables permission.", "translatepress-multilingual"); ?>
 
64
  <?php __("Active", "translatepress-multilingual"); ?>
65
  <?php __("Automatic Translation", "translatepress-multilingual"); ?>
66
  <?php __("DeepL", "translatepress-multilingual"); ?>
96
  <?php __("Top Left", "translatepress-multilingual"); ?>
97
  <?php __("Dark", "translatepress-multilingual"); ?>
98
  <?php __("Light", "translatepress-multilingual"); ?>
 
99
  <?php __("Error! Duplicate URL slug values.", "translatepress-multilingual"); ?>
100
  <?php __("Current Language", "translatepress-multilingual"); ?>
101
  <?php __("General", "translatepress-multilingual"); ?>
214
  <?php __("<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server.", "translatepress-multilingual"); ?>
215
  <?php __("Detected long query limitation on WPEngine hosting. Some large pages may appear untranslated. You can remove limitation by adding the following to your site’s wp-config.php: define( 'WPE_GOVERNOR', false ); ", "translatepress-multilingual"); ?>
216
  <?php __("Custom Language Flag", "translatepress-multilingual"); ?>
217
+ <?php __("The Language code of the added custom language is invalid.", "translatepress-multilingual"); ?>
218
+ <?php __("The Automatic Translation Code of the added custom language is invalid.", "translatepress-multilingual"); ?>
219
+ <?php __("The Language code of the added custom language cannot be empty.", "translatepress-multilingual"); ?>
220
  <?php __("TranslatePress Settings", "translatepress-multilingual"); ?>
221
  <?php __("TranslatePress Add-ons", "translatepress-multilingual"); ?>
222
  <?php __("You must first purchase this version to have access to the addon %1$shere%2$s", "translatepress-multilingual"); ?>
282
  <?php __("Slug", "translatepress-multilingual"); ?>
283
  <?php __("Are you sure you want to remove this language?", "translatepress-multilingual"); ?>
284
  <?php __("Choose...", "translatepress-multilingual"); ?>
285
+ <?php __("Custom Languages", "translatepress-multilingual"); ?>
286
  <?php __("Select the language you wish to make your website available in.", "translatepress-multilingual"); ?>
287
  <?php __("To add <strong>more than two languages</strong> and support for SEO Title, Description, Slug and more check out <a href=\"%1$s\" target=\"_blank\" title=\"%2$s\">%2$s</a>.", "translatepress-multilingual"); ?>
288
  <?php __("TranslatePress Advanced Add-ons", "translatepress-multilingual"); ?>
330
  <?php __("Limit this menu item to the following languages", "translatepress-multilingual"); ?>
331
  <?php __("Date format", "translatepress-multilingual"); ?>
332
  <?php __("Customize the date formatting per each translated language.<br/>Leave empty for default WP setting or see more information <a href=\"https://wordpress.org/support/article/formatting-date-and-time/\" title=\"Formatting Date and Time\" target=\"_blank\">here</a>", "translatepress-multilingual"); ?>
333
+ <?php __("To edit an existing TranslatePress language, input the language code and fill in only the columns you want to overwrite (e.g. Language name, Flag).<br>You can also add new custom languages. They will be available under General settings, All Languages list, where the URL slug can be edited.<br>For custom flag, first upload the image in media library then paste the URL.<br>Changing or deleting a custom language will impact translations and site URL's.<br>The Language code and the Automatic Translation Code should contain only alphabetical values, numerical values, \"-\" and \"_\".<br>The Automatic Translation codes can be found on <a href = \"https://cloud.google.com/translate/docs/languages\" target = \"_blank\">Google ISO Codes</a> and <a href = \"https://www.deepl.com/docs-api/translating-text/\" target = \"_blank\">DeepL Target Codes</a>.", "translatepress-multilingual"); ?>
334
+ <?php __("Language code", "translatepress-multilingual"); ?>
335
  <?php __("Language name", "translatepress-multilingual"); ?>
336
  <?php __("Native name", "translatepress-multilingual"); ?>
337
+ <?php __("Automatic translation code", "translatepress-multilingual"); ?>
338
  <?php __("Flag URL", "translatepress-multilingual"); ?>
339
  <?php __("Text RTL", "translatepress-multilingual"); ?>
340
  <?php __("Custom language", "translatepress-multilingual"); ?>
 
341
  <?php __("Disable dynamic translation", "translatepress-multilingual"); ?>
342
  <?php __("It disables detection of strings displayed dynamically using JavaScript. <br/>Strings loaded via a server side AJAX call will still be translated.", "translatepress-multilingual"); ?>
343
  <?php __("Exclude translated links from sitemap", "translatepress-multilingual"); ?>
languages/translatepress-multilingual.pot CHANGED
@@ -13,15 +13,27 @@ msgstr ""
13
  "X-Poedit-SourceCharset: UTF-8\n"
14
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
 
16
- #: index-dev.php:39
 
 
 
 
 
 
 
 
17
  msgid "Please update the TranslatePress - Multilingual plugin to version 2.0.5 at least for %s to work properly"
18
  msgstr ""
19
 
20
- #: index-dev.php:33
21
  msgid "Please install and activate the TranslatePress - Multilingual plugin"
22
  msgstr ""
23
 
24
- #: index-dev.php:216
 
 
 
 
25
  msgid "This TranslatePress add-on has been migrated to the main plugin and is no longer used. You can delete it."
26
  msgstr ""
27
 
@@ -33,27 +45,27 @@ msgstr ""
33
  msgid "Advanced"
34
  msgstr ""
35
 
36
- #: includes/class-advanced-tab.php:178
37
  msgid "Settings saved."
38
  msgstr ""
39
 
40
- #: includes/class-advanced-tab.php:307, includes/class-error-manager.php:172, partials/machine-translation-settings-page.php:13, partials/machine-translation-settings-page.php:117, partials/machine-translation-settings-page.php:150, partials/main-settings-page.php:41, partials/main-settings-page.php:54, partials/main-settings-page.php:67
41
  msgid "Yes"
42
  msgstr ""
43
 
44
- #: includes/class-advanced-tab.php:504, includes/class-advanced-tab.php:515, includes/class-advanced-tab.php:603, includes/class-advanced-tab.php:634
45
  msgid "Are you sure you want to remove this item?"
46
  msgstr ""
47
 
48
- #: includes/class-advanced-tab.php:504, includes/class-advanced-tab.php:515, includes/class-advanced-tab.php:603, includes/class-advanced-tab.php:634, partials/main-settings-language-selector.php:40, add-ons-advanced/extra-languages/partials/language-selector-pro.php:43
49
  msgid "Remove"
50
  msgstr ""
51
 
52
- #: includes/class-advanced-tab.php:515, includes/class-advanced-tab.php:634, partials/main-settings-language-selector.php:55, add-ons-advanced/extra-languages/partials/language-selector-pro.php:58
53
  msgid "Add"
54
  msgstr ""
55
 
56
- #: includes/class-advanced-tab.php:587, includes/class-advanced-tab.php:621
57
  msgid "Select..."
58
  msgstr ""
59
 
@@ -173,7 +185,7 @@ msgstr ""
173
  msgid "Automatic translation has been disabled."
174
  msgstr ""
175
 
176
- #: includes/class-error-manager.php:146, includes/class-plugin-notices.php:341, includes/class-plugin-notices.php:392, includes/class-plugin-notices.php:373, includes/class-plugin-notices.php:406, includes/class-plugin-notices.php:431, includes/class-plugin-notices.php:455, includes/class-reviews.php:119, includes/class-reviews.php:122, includes/class-upgrade.php:776
177
  msgid "Dismiss this notice."
178
  msgstr ""
179
 
@@ -249,10 +261,6 @@ msgstr ""
249
  msgid "If your problem still isn't solved, try asking your hosting about your errors. The most common issue is missing permissions for the SQL user, such as the Create Tables permission."
250
  msgstr ""
251
 
252
- #: includes/class-install-plugins.php:36
253
- msgid "Could not install. Try again from <a href=\"%s\" >Plugins Dashboard.</a>"
254
- msgstr ""
255
-
256
  #: includes/class-install-plugins.php:34, includes/class-settings.php:162, add-ons-advanced/extra-languages/partials/language-selector-pro.php:10
257
  msgid "Active"
258
  msgstr ""
@@ -393,10 +401,6 @@ msgstr ""
393
  msgid "Light"
394
  msgstr ""
395
 
396
- #: includes/class-settings.php:163
397
- msgid "Install & Activate"
398
- msgstr ""
399
-
400
  #: includes/class-settings.php:435, add-ons-advanced/extra-languages/class-extra-languages.php:44
401
  msgid "Error! Duplicate URL slug values."
402
  msgstr ""
@@ -749,107 +753,107 @@ msgstr ""
749
  msgid "Dublin Core Description"
750
  msgstr ""
751
 
752
- #: includes/class-upgrade.php:118
753
  msgid "Inserting original strings for language %s..."
754
  msgstr ""
755
 
756
- #: includes/class-upgrade.php:127
757
  msgid "Cleaning original strings table for language %s..."
758
  msgstr ""
759
 
760
- #: includes/class-upgrade.php:135
761
  msgid "Updating original string ids for language %s..."
762
  msgstr ""
763
 
764
- #: includes/class-upgrade.php:143
765
  msgid "Regenerating original meta table for language %s..."
766
  msgstr ""
767
 
768
- #: includes/class-upgrade.php:151
769
  msgid "Cleaning original meta table for language %s..."
770
  msgstr ""
771
 
772
- #: includes/class-upgrade.php:185
773
  msgid "TranslatePress data update"
774
  msgstr ""
775
 
776
- #: includes/class-upgrade.php:185
777
  msgid "We need to update your translations database to the latest version."
778
  msgstr ""
779
 
780
- #: includes/class-upgrade.php:186
781
  msgid "IMPORTANT: It is strongly recommended to first backup the database!\nAre you sure you want to continue?"
782
  msgstr ""
783
 
784
- #: includes/class-upgrade.php:186
785
  msgid "Run the updater"
786
  msgstr ""
787
 
788
- #: includes/class-upgrade.php:202
789
  msgid "Update aborted! Your user account doesn't have the capability to perform database updates."
790
  msgstr ""
791
 
792
- #: includes/class-upgrade.php:207
793
  msgid "Update aborted! Invalid nonce."
794
  msgstr ""
795
 
796
- #: includes/class-upgrade.php:246
797
  msgid "Update aborted! Incorrect action."
798
  msgstr ""
799
 
800
- #: includes/class-upgrade.php:249
801
  msgid "Update aborted! Incorrect language code."
802
  msgstr ""
803
 
804
- #: includes/class-upgrade.php:235
805
  msgid "Updating database to version %s+"
806
  msgstr ""
807
 
808
- #: includes/class-upgrade.php:239, includes/class-upgrade.php:299
809
  msgid "Processing table for language %s..."
810
  msgstr ""
811
 
812
- #: includes/class-upgrade.php:222, includes/class-upgrade.php:328, includes/class-upgrade.php:481, includes/class-upgrade.php:486
813
  msgid "Back to TranslatePress Settings"
814
  msgstr ""
815
 
816
- #: includes/class-upgrade.php:226
817
  msgid "Successfully updated database!"
818
  msgstr ""
819
 
820
- #: includes/class-upgrade.php:303, includes/class-upgrade.php:296
821
  msgid " done."
822
  msgstr ""
823
 
824
- #: includes/class-upgrade.php:481
825
  msgid "Done."
826
  msgstr ""
827
 
828
- #: includes/class-upgrade.php:486
829
  msgid "Invalid nonce."
830
  msgstr ""
831
 
832
- #: includes/class-upgrade.php:510
833
  msgid "Querying table <strong>%s</strong>"
834
  msgstr ""
835
 
836
- #: includes/class-upgrade.php:552
837
  msgid "%s duplicates removed"
838
  msgstr ""
839
 
840
- #: includes/class-upgrade.php:590, includes/class-upgrade.php:695
841
  msgid "If the page does not redirect automatically"
842
  msgstr ""
843
 
844
- #: includes/class-upgrade.php:590, includes/class-upgrade.php:695
845
  msgid "click here"
846
  msgstr ""
847
 
848
- #: includes/class-upgrade.php:684
849
  msgid "Recreated original strings table."
850
  msgstr ""
851
 
852
- #: includes/class-upgrade.php:774
853
  msgid "All individual TranslatePress add-on plugins <a href=\"%1$s\" target=\"_blank\">have been discontinued</a> and are now included in the premium Personal, Business and Developer versions of TranslatePress. Please log into your <a href=\"%2$s\" target=\"_blank\">account page</a>, download the new premium version and install it. Your individual addons settings will be ported over."
854
  msgstr ""
855
 
@@ -869,6 +873,18 @@ msgstr ""
869
  msgid "Custom Language Flag"
870
  msgstr ""
871
 
 
 
 
 
 
 
 
 
 
 
 
 
872
  #: partials/addons-settings-page.php:3, partials/license-settings-page.php:46, partials/license-settings-page.php:8, partials/main-settings-page.php:5, partials/test-api-settings-page.php:11, partials/trp-remove-duplicate-rows.php:3
873
  msgid "TranslatePress Settings"
874
  msgstr ""
@@ -1128,34 +1144,38 @@ msgstr ""
1128
  msgid "Are you sure you want to remove this language?"
1129
  msgstr ""
1130
 
1131
- #: partials/main-settings-language-selector.php:48, add-ons-advanced/extra-languages/partials/language-selector-pro.php:51
1132
  msgid "Choose..."
1133
  msgstr ""
1134
 
1135
- #: partials/main-settings-language-selector.php:59
 
 
 
 
1136
  msgid "Select the language you wish to make your website available in."
1137
  msgstr ""
1138
 
1139
  #. translators: %1$s is the URL to the add-ons. %2$2 is for the TranslatePress add-on verbiage.
1140
- #: partials/main-settings-language-selector.php:71
1141
  msgid "To add <strong>more than two languages</strong> and support for SEO Title, Description, Slug and more check out <a href=\"%1$s\" target=\"_blank\" title=\"%2$s\">%2$s</a>."
1142
  msgstr ""
1143
 
1144
- #: partials/main-settings-language-selector.php:73
1145
  msgctxt "Verbiage for the TranslatePress Advanced add-ons"
1146
  msgid "TranslatePress Advanced Add-ons"
1147
  msgstr ""
1148
 
1149
- #: partials/main-settings-language-selector.php:75
1150
  msgid "Not only are you getting extra features and premium support, but you also help fund the future development of TranslatePress."
1151
  msgstr ""
1152
 
1153
- #: partials/main-settings-language-selector.php:79
1154
  msgctxt "Link to the TranslatePress add-ons"
1155
  msgid "TranslatePress Advanced Add-ons"
1156
  msgstr ""
1157
 
1158
- #: partials/main-settings-language-selector.php:66
1159
  msgid "To add <strong>more than two languages</strong> activate the <strong>Extra Languages Add-on</strong> from <a href=\"%s\" class=\"trp-translatepress-account-page\" target=\"_blank\" title=\"Add-ons page\">the Add-ons Page</a>. Once activated, you'll be able to add unlimited languages."
1160
  msgstr ""
1161
 
@@ -1323,34 +1343,38 @@ msgstr ""
1323
  msgid "Customize the date formatting per each translated language.<br/>Leave empty for default WP setting or see more information <a href=\"https://wordpress.org/support/article/formatting-date-and-time/\" title=\"Formatting Date and Time\" target=\"_blank\">here</a>"
1324
  msgstr ""
1325
 
1326
- #: includes/advanced-settings/custom-language.php:22
 
 
 
 
 
 
 
 
1327
  msgid "Language name"
1328
  msgstr ""
1329
 
1330
- #: includes/advanced-settings/custom-language.php:23
1331
  msgid "Native name"
1332
  msgstr ""
1333
 
1334
- #: includes/advanced-settings/custom-language.php:24
1335
- msgid "ISO code"
1336
  msgstr ""
1337
 
1338
- #: includes/advanced-settings/custom-language.php:25
1339
  msgid "Flag URL"
1340
  msgstr ""
1341
 
1342
- #: includes/advanced-settings/custom-language.php:26
1343
  msgid "Text RTL"
1344
  msgstr ""
1345
 
1346
- #: includes/advanced-settings/custom-language.php:29, includes/advanced-settings/separators.php:49
1347
  msgid "Custom language"
1348
  msgstr ""
1349
 
1350
- #: includes/advanced-settings/custom-language.php:30
1351
- msgid "Adds custom languages to TranslatePress.<br>Will be available under General settings, All Languages list, where the URL slug can also be edited.<br>For custom flag, first upload the image in media library then paste the URL.<br>Changing or deleting a custom language will impact translations and site URL's.<br> The ISO code will be used for automatic translation if supported."
1352
- msgstr ""
1353
-
1354
  #: includes/advanced-settings/disable-dynamic-translation.php:8
1355
  msgid "Disable dynamic translation"
1356
  msgstr ""
@@ -1729,7 +1753,7 @@ msgstr ""
1729
  msgid "String Translation Editor"
1730
  msgstr ""
1731
 
1732
- #: add-ons-advanced/extra-languages/partials/language-selector-pro.php:61
1733
  msgid "Select the languages you wish to make your website available in."
1734
  msgstr ""
1735
 
13
  "X-Poedit-SourceCharset: UTF-8\n"
14
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
 
16
+ #: index-dev.php:34
17
+ msgid "Plugin activated."
18
+ msgstr ""
19
+
20
+ #: index-dev.php:37, includes/class-install-plugins.php:36
21
+ msgid "Could not install. Try again from <a href=\"%s\" >Plugins Dashboard.</a>"
22
+ msgstr ""
23
+
24
+ #: index-dev.php:53
25
  msgid "Please update the TranslatePress - Multilingual plugin to version 2.0.5 at least for %s to work properly"
26
  msgstr ""
27
 
28
+ #: index-dev.php:44
29
  msgid "Please install and activate the TranslatePress - Multilingual plugin"
30
  msgstr ""
31
 
32
+ #: index-dev.php:46, includes/class-settings.php:163
33
+ msgid "Install & Activate"
34
+ msgstr ""
35
+
36
+ #: index-dev.php:230
37
  msgid "This TranslatePress add-on has been migrated to the main plugin and is no longer used. You can delete it."
38
  msgstr ""
39
 
45
  msgid "Advanced"
46
  msgstr ""
47
 
48
+ #: includes/class-advanced-tab.php:181
49
  msgid "Settings saved."
50
  msgstr ""
51
 
52
+ #: includes/class-advanced-tab.php:311, includes/class-error-manager.php:172, partials/machine-translation-settings-page.php:13, partials/machine-translation-settings-page.php:117, partials/machine-translation-settings-page.php:150, partials/main-settings-page.php:41, partials/main-settings-page.php:54, partials/main-settings-page.php:67
53
  msgid "Yes"
54
  msgstr ""
55
 
56
+ #: includes/class-advanced-tab.php:508, includes/class-advanced-tab.php:519, includes/class-advanced-tab.php:613, includes/class-advanced-tab.php:644
57
  msgid "Are you sure you want to remove this item?"
58
  msgstr ""
59
 
60
+ #: includes/class-advanced-tab.php:508, includes/class-advanced-tab.php:519, includes/class-advanced-tab.php:613, includes/class-advanced-tab.php:644, partials/main-settings-language-selector.php:40, add-ons-advanced/extra-languages/partials/language-selector-pro.php:43
61
  msgid "Remove"
62
  msgstr ""
63
 
64
+ #: includes/class-advanced-tab.php:519, includes/class-advanced-tab.php:644, partials/main-settings-language-selector.php:82, add-ons-advanced/extra-languages/partials/language-selector-pro.php:84
65
  msgid "Add"
66
  msgstr ""
67
 
68
+ #: includes/class-advanced-tab.php:597, includes/class-advanced-tab.php:631
69
  msgid "Select..."
70
  msgstr ""
71
 
185
  msgid "Automatic translation has been disabled."
186
  msgstr ""
187
 
188
+ #: includes/class-error-manager.php:146, includes/class-plugin-notices.php:341, includes/class-plugin-notices.php:392, includes/class-plugin-notices.php:373, includes/class-plugin-notices.php:406, includes/class-plugin-notices.php:431, includes/class-plugin-notices.php:455, includes/class-reviews.php:119, includes/class-reviews.php:122, includes/class-upgrade.php:793
189
  msgid "Dismiss this notice."
190
  msgstr ""
191
 
261
  msgid "If your problem still isn't solved, try asking your hosting about your errors. The most common issue is missing permissions for the SQL user, such as the Create Tables permission."
262
  msgstr ""
263
 
 
 
 
 
264
  #: includes/class-install-plugins.php:34, includes/class-settings.php:162, add-ons-advanced/extra-languages/partials/language-selector-pro.php:10
265
  msgid "Active"
266
  msgstr ""
401
  msgid "Light"
402
  msgstr ""
403
 
 
 
 
 
404
  #: includes/class-settings.php:435, add-ons-advanced/extra-languages/class-extra-languages.php:44
405
  msgid "Error! Duplicate URL slug values."
406
  msgstr ""
753
  msgid "Dublin Core Description"
754
  msgstr ""
755
 
756
+ #: includes/class-upgrade.php:121
757
  msgid "Inserting original strings for language %s..."
758
  msgstr ""
759
 
760
+ #: includes/class-upgrade.php:130
761
  msgid "Cleaning original strings table for language %s..."
762
  msgstr ""
763
 
764
+ #: includes/class-upgrade.php:138
765
  msgid "Updating original string ids for language %s..."
766
  msgstr ""
767
 
768
+ #: includes/class-upgrade.php:146
769
  msgid "Regenerating original meta table for language %s..."
770
  msgstr ""
771
 
772
+ #: includes/class-upgrade.php:154
773
  msgid "Cleaning original meta table for language %s..."
774
  msgstr ""
775
 
776
+ #: includes/class-upgrade.php:188
777
  msgid "TranslatePress data update"
778
  msgstr ""
779
 
780
+ #: includes/class-upgrade.php:188
781
  msgid "We need to update your translations database to the latest version."
782
  msgstr ""
783
 
784
+ #: includes/class-upgrade.php:189
785
  msgid "IMPORTANT: It is strongly recommended to first backup the database!\nAre you sure you want to continue?"
786
  msgstr ""
787
 
788
+ #: includes/class-upgrade.php:189
789
  msgid "Run the updater"
790
  msgstr ""
791
 
792
+ #: includes/class-upgrade.php:205
793
  msgid "Update aborted! Your user account doesn't have the capability to perform database updates."
794
  msgstr ""
795
 
796
+ #: includes/class-upgrade.php:210
797
  msgid "Update aborted! Invalid nonce."
798
  msgstr ""
799
 
800
+ #: includes/class-upgrade.php:249
801
  msgid "Update aborted! Incorrect action."
802
  msgstr ""
803
 
804
+ #: includes/class-upgrade.php:252
805
  msgid "Update aborted! Incorrect language code."
806
  msgstr ""
807
 
808
+ #: includes/class-upgrade.php:238
809
  msgid "Updating database to version %s+"
810
  msgstr ""
811
 
812
+ #: includes/class-upgrade.php:242, includes/class-upgrade.php:302
813
  msgid "Processing table for language %s..."
814
  msgstr ""
815
 
816
+ #: includes/class-upgrade.php:225, includes/class-upgrade.php:331, includes/class-upgrade.php:484, includes/class-upgrade.php:489
817
  msgid "Back to TranslatePress Settings"
818
  msgstr ""
819
 
820
+ #: includes/class-upgrade.php:229
821
  msgid "Successfully updated database!"
822
  msgstr ""
823
 
824
+ #: includes/class-upgrade.php:306, includes/class-upgrade.php:299
825
  msgid " done."
826
  msgstr ""
827
 
828
+ #: includes/class-upgrade.php:484
829
  msgid "Done."
830
  msgstr ""
831
 
832
+ #: includes/class-upgrade.php:489
833
  msgid "Invalid nonce."
834
  msgstr ""
835
 
836
+ #: includes/class-upgrade.php:513
837
  msgid "Querying table <strong>%s</strong>"
838
  msgstr ""
839
 
840
+ #: includes/class-upgrade.php:555
841
  msgid "%s duplicates removed"
842
  msgstr ""
843
 
844
+ #: includes/class-upgrade.php:593, includes/class-upgrade.php:712
845
  msgid "If the page does not redirect automatically"
846
  msgstr ""
847
 
848
+ #: includes/class-upgrade.php:593, includes/class-upgrade.php:712
849
  msgid "click here"
850
  msgstr ""
851
 
852
+ #: includes/class-upgrade.php:701
853
  msgid "Recreated original strings table."
854
  msgstr ""
855
 
856
+ #: includes/class-upgrade.php:791
857
  msgid "All individual TranslatePress add-on plugins <a href=\"%1$s\" target=\"_blank\">have been discontinued</a> and are now included in the premium Personal, Business and Developer versions of TranslatePress. Please log into your <a href=\"%2$s\" target=\"_blank\">account page</a>, download the new premium version and install it. Your individual addons settings will be ported over."
858
  msgstr ""
859
 
873
  msgid "Custom Language Flag"
874
  msgstr ""
875
 
876
+ #: includes/custom-language.php:158
877
+ msgid "The Language code of the added custom language is invalid."
878
+ msgstr ""
879
+
880
+ #: includes/custom-language.php:173
881
+ msgid "The Automatic Translation Code of the added custom language is invalid."
882
+ msgstr ""
883
+
884
+ #: includes/custom-language.php:185
885
+ msgid "The Language code of the added custom language cannot be empty."
886
+ msgstr ""
887
+
888
  #: partials/addons-settings-page.php:3, partials/license-settings-page.php:46, partials/license-settings-page.php:8, partials/main-settings-page.php:5, partials/test-api-settings-page.php:11, partials/trp-remove-duplicate-rows.php:3
889
  msgid "TranslatePress Settings"
890
  msgstr ""
1144
  msgid "Are you sure you want to remove this language?"
1145
  msgstr ""
1146
 
1147
+ #: partials/main-settings-language-selector.php:53, add-ons-advanced/extra-languages/partials/language-selector-pro.php:56
1148
  msgid "Choose..."
1149
  msgstr ""
1150
 
1151
+ #: partials/main-settings-language-selector.php:57, add-ons-advanced/extra-languages/partials/language-selector-pro.php:60
1152
+ msgid "Custom Languages"
1153
+ msgstr ""
1154
+
1155
+ #: partials/main-settings-language-selector.php:86
1156
  msgid "Select the language you wish to make your website available in."
1157
  msgstr ""
1158
 
1159
  #. translators: %1$s is the URL to the add-ons. %2$2 is for the TranslatePress add-on verbiage.
1160
+ #: partials/main-settings-language-selector.php:98
1161
  msgid "To add <strong>more than two languages</strong> and support for SEO Title, Description, Slug and more check out <a href=\"%1$s\" target=\"_blank\" title=\"%2$s\">%2$s</a>."
1162
  msgstr ""
1163
 
1164
+ #: partials/main-settings-language-selector.php:100
1165
  msgctxt "Verbiage for the TranslatePress Advanced add-ons"
1166
  msgid "TranslatePress Advanced Add-ons"
1167
  msgstr ""
1168
 
1169
+ #: partials/main-settings-language-selector.php:102
1170
  msgid "Not only are you getting extra features and premium support, but you also help fund the future development of TranslatePress."
1171
  msgstr ""
1172
 
1173
+ #: partials/main-settings-language-selector.php:106
1174
  msgctxt "Link to the TranslatePress add-ons"
1175
  msgid "TranslatePress Advanced Add-ons"
1176
  msgstr ""
1177
 
1178
+ #: partials/main-settings-language-selector.php:93
1179
  msgid "To add <strong>more than two languages</strong> activate the <strong>Extra Languages Add-on</strong> from <a href=\"%s\" class=\"trp-translatepress-account-page\" target=\"_blank\" title=\"Add-ons page\">the Add-ons Page</a>. Once activated, you'll be able to add unlimited languages."
1180
  msgstr ""
1181
 
1343
  msgid "Customize the date formatting per each translated language.<br/>Leave empty for default WP setting or see more information <a href=\"https://wordpress.org/support/article/formatting-date-and-time/\" title=\"Formatting Date and Time\" target=\"_blank\">here</a>"
1344
  msgstr ""
1345
 
1346
+ #: includes/advanced-settings/custom-language.php:19
1347
+ msgid "To edit an existing TranslatePress language, input the language code and fill in only the columns you want to overwrite (e.g. Language name, Flag).<br>You can also add new custom languages. They will be available under General settings, All Languages list, where the URL slug can be edited.<br>For custom flag, first upload the image in media library then paste the URL.<br>Changing or deleting a custom language will impact translations and site URL's.<br>The Language code and the Automatic Translation Code should contain only alphabetical values, numerical values, \"-\" and \"_\".<br>The Automatic Translation codes can be found on <a href = \"https://cloud.google.com/translate/docs/languages\" target = \"_blank\">Google ISO Codes</a> and <a href = \"https://www.deepl.com/docs-api/translating-text/\" target = \"_blank\">DeepL Target Codes</a>."
1348
+ msgstr ""
1349
+
1350
+ #: includes/advanced-settings/custom-language.php:24
1351
+ msgid "Language code"
1352
+ msgstr ""
1353
+
1354
+ #: includes/advanced-settings/custom-language.php:25
1355
  msgid "Language name"
1356
  msgstr ""
1357
 
1358
+ #: includes/advanced-settings/custom-language.php:26
1359
  msgid "Native name"
1360
  msgstr ""
1361
 
1362
+ #: includes/advanced-settings/custom-language.php:27
1363
+ msgid "Automatic translation code"
1364
  msgstr ""
1365
 
1366
+ #: includes/advanced-settings/custom-language.php:28
1367
  msgid "Flag URL"
1368
  msgstr ""
1369
 
1370
+ #: includes/advanced-settings/custom-language.php:29
1371
  msgid "Text RTL"
1372
  msgstr ""
1373
 
1374
+ #: includes/advanced-settings/custom-language.php:32, includes/advanced-settings/separators.php:49
1375
  msgid "Custom language"
1376
  msgstr ""
1377
 
 
 
 
 
1378
  #: includes/advanced-settings/disable-dynamic-translation.php:8
1379
  msgid "Disable dynamic translation"
1380
  msgstr ""
1753
  msgid "String Translation Editor"
1754
  msgstr ""
1755
 
1756
+ #: add-ons-advanced/extra-languages/partials/language-selector-pro.php:87
1757
  msgid "Select the languages you wish to make your website available in."
1758
  msgstr ""
1759
 
partials/language-switcher-shortcode.php CHANGED
@@ -33,7 +33,7 @@ $current_language_preference = $this->add_shortcode_preferences($shortcode_setti
33
  var trp_shortcode_language_item = trp_el.querySelector('.trp-ls-shortcode-language')
34
 
35
  // set width
36
- var trp_ls_shortcode_width = trp_shortcode_language_item.offsetWidth + 5;
37
  trp_shortcode_language_item.style.width = trp_ls_shortcode_width + 'px';
38
  trp_el.querySelector('.trp-ls-shortcode-current-language').style.width = trp_ls_shortcode_width + 'px';
39
 
33
  var trp_shortcode_language_item = trp_el.querySelector('.trp-ls-shortcode-language')
34
 
35
  // set width
36
+ var trp_ls_shortcode_width = trp_shortcode_language_item.offsetWidth + 16;
37
  trp_shortcode_language_item.style.width = trp_ls_shortcode_width + 'px';
38
  trp_el.querySelector('.trp-ls-shortcode-current-language').style.width = trp_ls_shortcode_width + 'px';
39
 
partials/main-settings-language-selector.php CHANGED
@@ -45,11 +45,38 @@
45
  </table>
46
  <div id="trp-new-language">
47
  <select id="trp-select-language" class="trp-select2 trp-translation-language" >
 
 
 
 
 
48
  <option value=""><?php esc_html_e( 'Choose...', 'translatepress-multilingual' );?></option>
49
  <?php foreach( $languages as $language_code => $language_name ){ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  <option title="<?php echo esc_attr( $language_code ); ?>" value="<?php echo esc_attr( $language_code ); ?>">
51
  <?php echo esc_html( $language_name ); ?>
52
  </option>
 
53
  <?php }?>
54
  </select>
55
  <button type="button" id="trp-add-language" class="button-secondary"><?php esc_html_e( 'Add', 'translatepress-multilingual' );?></button>
45
  </table>
46
  <div id="trp-new-language">
47
  <select id="trp-select-language" class="trp-select2 trp-translation-language" >
48
+ <?php
49
+ $trp = TRP_Translate_Press::get_trp_instance();
50
+ $trp_languages = $trp->get_component('languages');
51
+ $wp_languages = $trp_languages->get_wp_languages();
52
+ ?>
53
  <option value=""><?php esc_html_e( 'Choose...', 'translatepress-multilingual' );?></option>
54
  <?php foreach( $languages as $language_code => $language_name ){ ?>
55
+
56
+ <?php if(isset($wp_languages[$language_code]['is_custom_language']) && $wp_languages[$language_code]['is_custom_language'] === true){ ?>
57
+ <optgroup label="<?php echo esc_html__('Custom Languages', 'translatepress-multilingual'); ?>">
58
+ <?php break;?>
59
+ <?php } ?>
60
+ <?php } ?>
61
+ <?php foreach( $languages as $language_code => $language_name ){ ?>
62
+
63
+ <?php if(isset($wp_languages[$language_code]['is_custom_language']) && $wp_languages[$language_code]['is_custom_language'] === true){ ?>
64
+ <option title="<?php echo esc_attr( $language_code ); ?>" value="<?php echo esc_attr( $language_code ); ?>">
65
+ <?php echo esc_html( $language_name ); ?>
66
+ </option>
67
+
68
+ <?php } ?>
69
+
70
+ <?php }?>
71
+ </optgroup>
72
+
73
+ <?php foreach( $languages as $language_code => $language_name ){ ?>
74
+ <?php if(!isset($wp_languages[$language_code]['is_custom_language']) || (isset($wp_languages[$language_code]['is_custom_language']) && $wp_languages[$language_code]['is_custom_language'] !== true)){ ?>
75
+
76
  <option title="<?php echo esc_attr( $language_code ); ?>" value="<?php echo esc_attr( $language_code ); ?>">
77
  <?php echo esc_html( $language_name ); ?>
78
  </option>
79
+ <?php } ?>
80
  <?php }?>
81
  </select>
82
  <button type="button" id="trp-add-language" class="button-secondary"><?php esc_html_e( 'Add', 'translatepress-multilingual' );?></button>
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: translate, translation, multilingual, automatic translation, bilingual, fr
5
  Requires at least: 3.1.0
6
  Tested up to: 5.8
7
  Requires PHP: 5.6.20
8
- Stable tag: 2.1.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -140,6 +140,11 @@ For more information please check out our [documentation](https://translatepress
140
 
141
 
142
  == Changelog ==
 
 
 
 
 
143
  = 2.1.0 =
144
  * Fixed some cases of missing spaces between words in different html tags on translated pages
145
  * Fixed conflict with Scriptless Social Sharing plugin
5
  Requires at least: 3.1.0
6
  Tested up to: 5.8
7
  Requires PHP: 5.6.20
8
+ Stable tag: 2.1.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
140
 
141
 
142
  == Changelog ==
143
+ = 2.1.1 =
144
+ * Improved Custom Languages feature
145
+ * Added possibility to easily edit existing language name or flag through Custom Language
146
+ * Added vertical scroll on floating and shortcode language switchers when having many languages
147
+
148
  = 2.1.0 =
149
  * Fixed some cases of missing spaces between words in different html tags on translated pages
150
  * Fixed conflict with Scriptless Social Sharing plugin