Polylang - Version 0.8.1

Version Description

(2012-03-11) =

  • Add Latvian translation contributed by @AndyDeGroo
  • It is now possible to synchronize multiple values for custom fields
  • Add new API function pll_current_language
  • Add the pll_rewrite_rules filter allowing plugins to filter rewrite rules by language
  • WP 3.4 preparation: disable the menu section in the customize theme admin panel (unusable with Polylang)
  • Bug correction: removing 'language' in permalinks does not work in WP 3.4 alpha
  • Bug correction: problems with custom post type archives when 'has_archive' is set (thanks to AndyDeGroo)
  • Bug correction: 404 error when combining %postname% permastructure with "Add language information to all URL" option
  • Bug correction: translated custom strings are duplicated if registered several times
  • Bug correction: queries with an array of post types are not correctly filtered
  • Bug correction: wp-login.php always in English
Download this release

Release Info

Developer Chouby
Plugin Icon 128x128 Polylang
Version 0.8.1
Comparing to
See all releases

Code changes from version 0.8 to 0.8.1

doc/documentation-en.odt CHANGED
Binary file
doc/documentation-en.pdf CHANGED
Binary file
include/admin-filters.php CHANGED
@@ -14,8 +14,11 @@ class Polylang_Admin_Filters extends Polylang_Base {
14
  // filter admin language for users
15
  add_filter('locale', array(&$this, 'get_locale'));
16
 
 
 
 
17
  // refresh rewrite rules if the 'page_on_front' option is modified
18
- add_action('update_option', array(&$this, 'update_option'));
19
  }
20
 
21
  // add these actions and filters here and not in the constructor to be sure that all taxonomies are registered
@@ -92,7 +95,7 @@ class Polylang_Admin_Filters extends Polylang_Base {
92
  if ($lang_id)
93
  $wp_locale->text_direction = get_metadata('term', $lang_id, '_rtl', true) ? 'rtl' : 'ltr';
94
 
95
- //modifies posts and terms links when need
96
  $this->add_post_term_link_filters();
97
  }
98
 
@@ -100,7 +103,7 @@ class Polylang_Admin_Filters extends Polylang_Base {
100
  function admin_enqueue_scripts() {
101
  $screen = get_current_screen();
102
 
103
- // FIXME keep the script in header to be sure it is loaded before post.js otherwise a non filtered tag cloud appear in tag cloud metabox
104
  if ($screen->base == 'settings_page_mlang' || $screen->base == 'post' || $screen->base == 'edit-tags')
105
  wp_enqueue_script('polylang_admin', POLYLANG_URL .'/js/admin.js', array('jquery', 'wp-ajax-response'), POLYLANG_VERSION);
106
 
@@ -182,9 +185,8 @@ class Polylang_Admin_Filters extends Polylang_Base {
182
 
183
  // adds the Languages box in the 'Edit Post' and 'Edit Page' panels (as well as in custom post types panels
184
  function add_meta_boxes() {
185
- if ($this->get_languages_list())
186
- foreach($this->post_types as $ptype)
187
- add_meta_box('ml_box', __('Languages','polylang'), array(&$this,'post_language'), $ptype, 'side','high');
188
  }
189
 
190
  // the Languages metabox in the 'Edit Post' and 'Edit Page' panels
@@ -308,7 +310,6 @@ class Polylang_Admin_Filters extends Polylang_Base {
308
  die;
309
  }
310
 
311
-
312
  // filters the pages by language in the parent dropdown list in the page attributes metabox
313
  function page_attributes_dropdown_pages_args($dropdown_args, $post) {
314
  $lang = isset($_POST['lang']) ? $this->get_language($_POST['lang']) : $this->get_post_language($post->ID); // ajax or not ?
@@ -379,10 +380,12 @@ class Polylang_Admin_Filters extends Polylang_Base {
379
  }
380
 
381
  // copy metas and allow plugins to do the same
382
- $metas = apply_filters('pll_copy_post_metas', array('_wp_page_template', '_thumbnail_id'));
383
- foreach ($metas as $meta) {
384
- if ($value = get_post_meta($_GET['from_post'], $meta, true))
385
- update_post_meta($post_id, $meta, $value);
 
 
386
  }
387
  }
388
 
@@ -445,12 +448,13 @@ class Polylang_Admin_Filters extends Polylang_Base {
445
  ($format = get_post_format($post_id)) ? set_post_format($tr_id, $format) : set_post_format($tr_id, '');
446
 
447
  // synchronize metas and allow plugins to do the same
448
- $metas = apply_filters('pll_copy_post_metas', array('_wp_page_template', '_thumbnail_id'));
449
- foreach ($metas as $meta) {
450
- if ($value = get_post_meta($post_id, $meta, true))
451
- update_post_meta($tr_id, $meta, get_post_meta($post_id, $meta, true));
452
- else
453
- delete_post_meta($tr_id, $meta);
 
454
  }
455
 
456
  // post parent
@@ -661,7 +665,7 @@ class Polylang_Admin_Filters extends Polylang_Base {
661
  'tax_query' => array(array(
662
  'taxonomy'=> $taxonomy,
663
  'field' => 'id',
664
- 'terms'=> array($term_id)+array_values($translations),
665
  ))
666
  ));
667
 
@@ -762,6 +766,11 @@ class Polylang_Admin_Filters extends Polylang_Base {
762
  '<a href="' . esc_url(admin_url('options-general.php?page=mlang&tab=menus')) . '">', '</a>') . '</p>';
763
  }
764
 
 
 
 
 
 
765
  // modifies the widgets forms to add our language dropdwown list
766
  function in_widget_form($widget) {
767
  $widget_lang = get_option('polylang_widgets');
@@ -806,10 +815,8 @@ class Polylang_Admin_Filters extends Polylang_Base {
806
  }
807
 
808
  // refresh rewrite rules if the 'page_on_front' option is modified
809
- function update_option($option) {
810
- global $wp_rewrite;
811
- if ($option == 'page_on_front')
812
- $wp_rewrite->flush_rules();
813
  }
814
  }
815
 
14
  // filter admin language for users
15
  add_filter('locale', array(&$this, 'get_locale'));
16
 
17
+ // remove the customize menu section as it is unusable with Polylang
18
+ add_action('customize_register', array(&$this, 'customize_register'), 20); // since WP 3.4
19
+
20
  // refresh rewrite rules if the 'page_on_front' option is modified
21
+ add_action('update_option_page_on_front', array(&$this, 'update_option_page_on_front'));
22
  }
23
 
24
  // add these actions and filters here and not in the constructor to be sure that all taxonomies are registered
95
  if ($lang_id)
96
  $wp_locale->text_direction = get_metadata('term', $lang_id, '_rtl', true) ? 'rtl' : 'ltr';
97
 
98
+ //modifies posts and terms links when needed
99
  $this->add_post_term_link_filters();
100
  }
101
 
103
  function admin_enqueue_scripts() {
104
  $screen = get_current_screen();
105
 
106
+ // FIXME keep the script in header to be sure it is loaded before post.js otherwise a non filtered tag cloud appears in tag cloud metabox
107
  if ($screen->base == 'settings_page_mlang' || $screen->base == 'post' || $screen->base == 'edit-tags')
108
  wp_enqueue_script('polylang_admin', POLYLANG_URL .'/js/admin.js', array('jquery', 'wp-ajax-response'), POLYLANG_VERSION);
109
 
185
 
186
  // adds the Languages box in the 'Edit Post' and 'Edit Page' panels (as well as in custom post types panels
187
  function add_meta_boxes() {
188
+ foreach($this->post_types as $ptype)
189
+ add_meta_box('ml_box', __('Languages','polylang'), array(&$this,'post_language'), $ptype, 'side', 'high');
 
190
  }
191
 
192
  // the Languages metabox in the 'Edit Post' and 'Edit Page' panels
310
  die;
311
  }
312
 
 
313
  // filters the pages by language in the parent dropdown list in the page attributes metabox
314
  function page_attributes_dropdown_pages_args($dropdown_args, $post) {
315
  $lang = isset($_POST['lang']) ? $this->get_language($_POST['lang']) : $this->get_post_language($post->ID); // ajax or not ?
380
  }
381
 
382
  // copy metas and allow plugins to do the same
383
+ $keys = array_unique(apply_filters('pll_copy_post_metas', array('_wp_page_template', '_thumbnail_id')));
384
+ $metas = get_post_custom($_GET['from_post']);
385
+ foreach ($keys as $key) {
386
+ if (isset($metas[$key]))
387
+ foreach ($metas[$key] as $value)
388
+ add_post_meta($post_id, $key, $value);
389
  }
390
  }
391
 
448
  ($format = get_post_format($post_id)) ? set_post_format($tr_id, $format) : set_post_format($tr_id, '');
449
 
450
  // synchronize metas and allow plugins to do the same
451
+ $keys = array_unique(apply_filters('pll_copy_post_metas', array('_wp_page_template', '_thumbnail_id')));
452
+ $metas = get_post_custom($post_id);
453
+ foreach ($keys as $key) {
454
+ delete_post_meta($tr_id, $key); // the synchronization process of multiple values custom fields is easier if we delete all metas first
455
+ if (isset($metas[$key]))
456
+ foreach ($metas[$key] as $value)
457
+ add_post_meta($tr_id, $key, $value);
458
  }
459
 
460
  // post parent
665
  'tax_query' => array(array(
666
  'taxonomy'=> $taxonomy,
667
  'field' => 'id',
668
+ 'terms'=> array_merge(array($term_id), array_values($translations)),
669
  ))
670
  ));
671
 
766
  '<a href="' . esc_url(admin_url('options-general.php?page=mlang&tab=menus')) . '">', '</a>') . '</p>';
767
  }
768
 
769
+ // FIXME remove the customize menu section as it is currently unusable with Polylang
770
+ function customize_register() {
771
+ $GLOBALS['customize']->remove_section('nav'); // since WP 3.4
772
+ }
773
+
774
  // modifies the widgets forms to add our language dropdwown list
775
  function in_widget_form($widget) {
776
  $widget_lang = get_option('polylang_widgets');
815
  }
816
 
817
  // refresh rewrite rules if the 'page_on_front' option is modified
818
+ function update_option_page_on_front() {
819
+ $GLOBALS['wp_rewrite']->flush_rules();
 
 
820
  }
821
  }
822
 
include/admin.php CHANGED
@@ -266,8 +266,8 @@ class Polylang_Admin extends Polylang_Base {
266
 
267
  update_option('polylang', $options);
268
 
269
- // refresh refresh permalink structure and rewrite rules in case rewrite or hide_default options have been modified
270
- $wp_rewrite->extra_permastructs['language'][0] = $options['rewrite'] ? '%language%' : '/language/%language%';
271
  $wp_rewrite->flush_rules();
272
 
273
  // fills existing posts & terms with default language
266
 
267
  update_option('polylang', $options);
268
 
269
+ // refresh rewrite rules in case rewrite or hide_default options have been modified
270
+ // it seems useless to refresh permastruct here
271
  $wp_rewrite->flush_rules();
272
 
273
  // fills existing posts & terms with default language
include/api.php CHANGED
@@ -6,18 +6,24 @@ function pll_the_languages($args = '') {
6
  return isset($polylang) ? $polylang->the_languages($args) : '';
7
  }
8
 
 
 
 
 
 
 
9
  // among the post and its translations, returns the id of the post which is in the language represented by $slug
10
- function pll_get_post($post_id, $slug = '') {
11
  global $polylang;
12
- $slug = $slug ? $slug : reset(explode('_', get_locale()));
13
- return isset($polylang) ? $polylang->get_post($post_id, $slug) : null;
14
  }
15
 
16
  // among the term and its translations, returns the id of the term which is in the language represented by $slug
17
- function pll_get_term($term_id, $slug = '') {
18
  global $polylang;
19
- $slug = $slug ? $slug : reset(explode('_', get_locale()));
20
- return isset($polylang) ? $polylang->get_term($term_id, $slug) : null;
21
  }
22
 
23
  // acts as is_front_page but knows about translated front page
6
  return isset($polylang) ? $polylang->the_languages($args) : '';
7
  }
8
 
9
+ // returns the current language
10
+ function pll_current_language($args = 'slug') {
11
+ global $polylang;
12
+ return isset($polylang) ? $polylang->current_language($args) : false;
13
+ }
14
+
15
  // among the post and its translations, returns the id of the post which is in the language represented by $slug
16
+ function pll_get_post($post_id, $slug = false) {
17
  global $polylang;
18
+ $slug = $slug ? $slug : pll_current_language();
19
+ return isset($polylang) && $slug ? $polylang->get_post($post_id, $slug) : null;
20
  }
21
 
22
  // among the term and its translations, returns the id of the term which is in the language represented by $slug
23
+ function pll_get_term($term_id, $slug = false) {
24
  global $polylang;
25
+ $slug = $slug ? $slug : pll_current_language();
26
+ return isset($polylang) && $slug ? $polylang->get_term($term_id, $slug) : null;
27
  }
28
 
29
  // acts as is_front_page but knows about translated front page
include/base.php CHANGED
@@ -4,7 +4,7 @@
4
  abstract class Polylang_Base {
5
  protected $options;
6
  protected $home;
7
- protected $strings; // strings to translate
8
  protected $post_types; // post types to filter by language
9
  protected $taxonomies; // taxonomies to filter by language
10
 
@@ -13,11 +13,11 @@ abstract class Polylang_Base {
13
  $this->options = get_option('polylang');
14
  $this->home = get_option('home');
15
 
16
- add_action('init', array(&$this, 'init_base'), 999); // must come late to be sure all post types and taxonomies are registered
17
  }
18
 
19
  // init post types and taxonomies to filter by language
20
- function init_base() {
21
  $this->post_types = apply_filters('pll_get_post_types', get_post_types(array('show_ui' => true)));
22
  $this->taxonomies = apply_filters('pll_get_taxonomies', get_taxonomies(array('show_ui'=>true)));
23
  }
@@ -233,9 +233,11 @@ abstract class Polylang_Base {
233
  return get_posts($q);
234
  }
235
 
236
- // register strings for translation
237
  function register_string($name, $string) {
238
- $this->strings[] = array('name'=> $name, 'string' => $string);
 
 
239
  }
240
 
241
  // export a mo object in options
4
  abstract class Polylang_Base {
5
  protected $options;
6
  protected $home;
7
+ protected $strings = array(); // strings to translate
8
  protected $post_types; // post types to filter by language
9
  protected $taxonomies; // taxonomies to filter by language
10
 
13
  $this->options = get_option('polylang');
14
  $this->home = get_option('home');
15
 
16
+ add_action('wp_loaded', array(&$this, 'add_post_types_taxonomies')); // must come late to be sure that all post types and taxonomies are registered
17
  }
18
 
19
  // init post types and taxonomies to filter by language
20
+ function add_post_types_taxonomies() {
21
  $this->post_types = apply_filters('pll_get_post_types', get_post_types(array('show_ui' => true)));
22
  $this->taxonomies = apply_filters('pll_get_taxonomies', get_taxonomies(array('show_ui'=>true)));
23
  }
233
  return get_posts($q);
234
  }
235
 
236
+ // register strings for translation making sure it is not duplicate
237
  function register_string($name, $string) {
238
+ $to_register = array('name'=> $name, 'string' => $string);
239
+ if (!in_array($to_register, $this->strings))
240
+ $this->strings[] = $to_register;
241
  }
242
 
243
  // export a mo object in options
include/core.php CHANGED
@@ -22,6 +22,7 @@ class Polylang_Core extends Polylang_base {
22
  add_action('init', array(&$this, 'init'));
23
  add_filter('override_load_textdomain', array(&$this, 'mofile'), 10, 3);
24
  add_action('wp', array(&$this, 'load_textdomains'));
 
25
 
26
  // filters posts according to the language
27
  add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));;
@@ -154,7 +155,7 @@ class Polylang_Core extends Polylang_base {
154
  return $this->curlang;
155
 
156
  // no language set for 404 and attachment
157
- if (is_404() || is_attachment())
158
  return $this->get_preferred_language();
159
 
160
  if ($var = get_query_var('lang'))
@@ -232,7 +233,7 @@ class Polylang_Core extends Polylang_base {
232
 
233
  // detect our exclude pages query and returns to avoid conflicts
234
  // this test should be sufficient
235
- if (isset($qvars['tax_query'][0]) && isset($qvars['tax_query'][0]['taxonomy']) && isset($qvars['tax_query'][0]['operator']))
236
  return;
237
 
238
  // homepage is requested, let's set the language
@@ -309,7 +310,8 @@ class Polylang_Core extends Polylang_base {
309
 
310
  // allow filtering recent posts by the current language
311
  // take care not to break queries for non visible post types such as nav_menu_items, attachments...
312
- if ($query->is_home && $this->curlang && (!isset($qvars['post_type']) || in_array($qvars['post_type'], $this->post_types)))
 
313
  $query->set('lang', $this->curlang->slug);
314
 
315
  // remove pages query when the language is set unless we do a search
@@ -513,9 +515,10 @@ class Polylang_Core extends Polylang_base {
513
  if (is_post_type_archive()){
514
  // custom post types can have a different slug than the post type name
515
  // thanks to AndyDeGroo for pointing that out
516
- // http://wordpress.org/support/topic/plugin-polylang-problems-with-custom-post-type-archive-titles?replies=6#post-2640861
517
- $cpt_rewrite = get_post_type_object($qvars['post_type'])->rewrite;
518
- $cpt_slug = isset($cpt_rewrite['slug']) ? $cpt_rewrite['slug'] : $qvars['post_type'];
 
519
  $url = esc_url($base.$cpt_slug.'/');
520
  }
521
  }
@@ -692,5 +695,13 @@ class Polylang_Core extends Polylang_base {
692
  else
693
  return $output;
694
  }
 
 
 
 
 
 
 
 
695
  }
696
  ?>
22
  add_action('init', array(&$this, 'init'));
23
  add_filter('override_load_textdomain', array(&$this, 'mofile'), 10, 3);
24
  add_action('wp', array(&$this, 'load_textdomains'));
25
+ add_action('login_init', array(&$this, 'load_textdomains'));
26
 
27
  // filters posts according to the language
28
  add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));;
155
  return $this->curlang;
156
 
157
  // no language set for 404 and attachment
158
+ if (is_404() || is_attachment() || current_filter() == 'login_init')
159
  return $this->get_preferred_language();
160
 
161
  if ($var = get_query_var('lang'))
233
 
234
  // detect our exclude pages query and returns to avoid conflicts
235
  // this test should be sufficient
236
+ if (isset($qvars['tax_query'][0]['taxonomy']) && $qvars['tax_query'][0]['taxonomy'] == 'language' && isset($qvars['tax_query'][0]['operator']))
237
  return;
238
 
239
  // homepage is requested, let's set the language
310
 
311
  // allow filtering recent posts by the current language
312
  // take care not to break queries for non visible post types such as nav_menu_items, attachments...
313
+ if ($query->is_home && $this->curlang && (!isset($qvars['post_type']) || in_array($qvars['post_type'], $this->post_types) ||
314
+ (is_array($qvars['post_type']) && array_intersect($qvars['post_type'], $this->post_types)) ))
315
  $query->set('lang', $this->curlang->slug);
316
 
317
  // remove pages query when the language is set unless we do a search
515
  if (is_post_type_archive()){
516
  // custom post types can have a different slug than the post type name
517
  // thanks to AndyDeGroo for pointing that out
518
+ // http://wordpress.org/support/topic/plugin-polylang-problems-with-custom-post-type-archive-titles
519
+ $cpt = get_post_type_object($qvars['post_type']);
520
+ // we don't need to check if there is $cpt->rewrite['slug'] because WP always sets it
521
+ $cpt_slug = is_string($cpt->has_archive) ? $cpt->has_archive : $cpt->rewrite['slug'];
522
  $url = esc_url($base.$cpt_slug.'/');
523
  }
524
  }
695
  else
696
  return $output;
697
  }
698
+
699
+ // just returns the current language for API
700
+ function current_language($args) {
701
+ return !isset($this->curlang) ? false :
702
+ $args == 'name' ? $this->curlang->name :
703
+ $args == 'locale' ? $this->curlang->description :
704
+ $this->curlang->slug;
705
+ }
706
  }
707
  ?>
languages/polylang-lv.mo ADDED
Binary file
languages/polylang-lv.po ADDED
@@ -0,0 +1,510 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: polylang 0.8\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2012-01-23 15:00+0100\n"
6
+ "PO-Revision-Date: 2012-03-03 19:48+0200\n"
7
+ "Last-Translator: Andis <andis.grossteins@gmail.com>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);\n"
13
+ "X-Poedit-Language: Latvian\n"
14
+ "X-Poedit-Country: LATVIA\n"
15
+ "X-Poedit-SourceCharset: utf-8\n"
16
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
17
+ "X-Poedit-Basepath: ../\n"
18
+ "X-Textdomain-Support: yes\n"
19
+ "X-Poedit-SearchPath-0: .\n"
20
+
21
+ # polylang
22
+ #: polylang.php:103
23
+ #, php-format
24
+ msgid "You are using WordPress %s. Polylang requires at least WordPress %s."
25
+ msgstr "Jūs lietojat WordPress %s. Polylang nepieciešama vismaz WordPress %s versija."
26
+
27
+ #@ polylang
28
+ #: polylang.php:199
29
+ msgid "Error: Restore of local flags failed!"
30
+ msgstr "Kļūda: Lokālo karogu atjaunošana neizdevās!"
31
+
32
+ #@ polylang
33
+ #: polylang.php:200
34
+ #, php-format
35
+ msgid "Please move your local flags from %s to %s"
36
+ msgstr "Lūdzu pārvietojies jūsu lokālos karogu failus no %s uz %s"
37
+
38
+ #@ polylang
39
+ #: include/widget.php:6
40
+ msgid "Language Switcher"
41
+ msgstr "Valodu Izvēlne"
42
+
43
+ #@ polylang
44
+ #: include/widget.php:6
45
+ msgid "Displays a language switcher"
46
+ msgstr "Parāda valodu izvēlni"
47
+
48
+ #@ polylang
49
+ #: include/widget.php:71
50
+ msgid "Title:"
51
+ msgstr "Virsraksts:"
52
+
53
+ #@ default
54
+ #@ polylang
55
+ #: include/admin.php:26
56
+ #: include/admin.php:310
57
+ msgid "Settings"
58
+ msgstr "Uzstādījumi"
59
+
60
+ #@ polylang
61
+ #: include/admin-filters.php:187
62
+ #: include/admin.php:33
63
+ #: include/admin.php:302
64
+ #: include/list-table.php:13
65
+ msgid "Languages"
66
+ msgstr "Valodas"
67
+
68
+ #@ polylang
69
+ #: include/admin.php:307
70
+ msgid "Menus"
71
+ msgstr "Izvēlne"
72
+
73
+ #@ polylang
74
+ #: include/admin.php:309
75
+ #: include/list-table.php:104
76
+ msgid "Strings translation"
77
+ msgstr "Tekstu tulkošana"
78
+
79
+ #@ polylang
80
+ #: include/admin.php:328
81
+ msgid "Enter a valid WorPress locale"
82
+ msgstr "Ievadiet derīgu WordPress valodas kodu"
83
+
84
+ #@ polylang
85
+ #: include/admin.php:329
86
+ msgid "The language code must be 2 characters long"
87
+ msgstr "Valodas kodā jābūt 2 simboliem"
88
+
89
+ #@ polylang
90
+ #: include/admin.php:330
91
+ msgid "The language code must be unique"
92
+ msgstr "Valodas kodam jābūt unikālam"
93
+
94
+ #@ polylang
95
+ #: include/admin.php:331
96
+ msgid "The language must have a name"
97
+ msgstr "Valodai ir nepieciešams nosaukums"
98
+
99
+ #@ polylang
100
+ #: include/admin.php:332
101
+ msgid "The language was created, but the WordPress language file was not downloaded. Please install it manually."
102
+ msgstr "Valoda tika izveidota, bet WordPress tulkojumu fails netika lejuplādēts. Lūdzu uzstādiet to manuāli."
103
+
104
+ #@ polylang
105
+ #: include/admin.php:488
106
+ msgid "Upgrading language files&#8230;"
107
+ msgstr "Atjaunina valodu failus&#8230;"
108
+
109
+ #@ polylang
110
+ #: include/admin.php:499
111
+ msgid "Displays language names"
112
+ msgstr "Rāda valodu nosaukumus"
113
+
114
+ #@ polylang
115
+ #: include/admin.php:500
116
+ msgid "Displays flags"
117
+ msgstr "Rāda karogus"
118
+
119
+ #@ polylang
120
+ #: include/admin.php:501
121
+ msgid "Forces link to front page"
122
+ msgstr "Valodas saite ved uz sākumlapu"
123
+
124
+ #@ polylang
125
+ #: include/admin.php:502
126
+ msgid "Hides the current language"
127
+ msgstr "Paslēpt aktīvo valodu"
128
+
129
+ #@ polylang
130
+ #: include/admin.php:504
131
+ msgid "Displays a language switcher at the end of the menu"
132
+ msgstr "Rāda valodu izvēlni šīs izvēlnes beigās"
133
+
134
+ #@ polylang
135
+ #: include/admin.php:505
136
+ msgid "Displays as dropdown"
137
+ msgstr "Rāda kā nolaižamo izvēlni"
138
+
139
+ #@ default
140
+ #: include/admin.php:514
141
+ msgid "Site Title"
142
+ msgstr "Vietnes virsraksts"
143
+
144
+ #@ default
145
+ #: include/admin.php:515
146
+ msgid "Tagline"
147
+ msgstr "Apakšvirsrakts"
148
+
149
+ #@ polylang
150
+ #: include/admin.php:533
151
+ msgid "Widget title"
152
+ msgstr "Logdaļas virsraksts"
153
+
154
+ #@ polylang
155
+ #: include/list-table.php:127
156
+ #: include/term-translations.php:6
157
+ #: include/term-translations.php:11
158
+ msgid "Translations"
159
+ msgstr "Tulkojumi"
160
+
161
+ #@ polylang
162
+ #: include/admin-filters.php:546
163
+ #: include/admin-filters.php:563
164
+ #: include/list-table.php:12
165
+ #: include/post-translations.php:4
166
+ #: include/term-translations.php:15
167
+ msgid "Language"
168
+ msgstr "Valoda"
169
+
170
+ #@ polylang
171
+ #: include/term-translations.php:16
172
+ msgid "Translation"
173
+ msgstr "Tulkojums"
174
+
175
+ #@ polylang
176
+ #: include/list-table.php:26
177
+ #: include/post-translations.php:6
178
+ #: include/post-translations.php:29
179
+ #: include/term-translations.php:18
180
+ #: include/term-translations.php:65
181
+ msgid "Edit"
182
+ msgstr "Rediģēt"
183
+
184
+ #@ polylang
185
+ #: include/term-translations.php:48
186
+ msgid "No untranslated term"
187
+ msgstr "Netulkotu terminu nav"
188
+
189
+ #@ polylang
190
+ #: include/post-translations.php:34
191
+ #: include/term-translations.php:54
192
+ msgid "Add new"
193
+ msgstr "Pievienot jaunu"
194
+
195
+ #@ polylang
196
+ #: include/admin-filters.php:151
197
+ #: include/admin-filters.php:609
198
+ msgid "Add new translation"
199
+ msgstr "Pievienot jaunu tulkojumu"
200
+
201
+ #@ polylang
202
+ #: include/admin-filters.php:174
203
+ msgid "Show all languages"
204
+ msgstr "Rādīt visas valodas"
205
+
206
+ #@ polylang
207
+ #: include/admin-filters.php:204
208
+ msgid "Page's language:"
209
+ msgstr "Lapas valoda"
210
+
211
+ #@ polylang
212
+ #: include/admin-filters.php:204
213
+ msgid "Post's language:"
214
+ msgstr "Raksta valoda"
215
+
216
+ #@ default
217
+ #: include/admin-filters.php:263
218
+ msgid "(no parent)"
219
+ msgstr "(bez vecāka)"
220
+
221
+ #@ polylang
222
+ #: include/admin-filters.php:548
223
+ #: include/admin-filters.php:566
224
+ msgid "Sets the language"
225
+ msgstr "Nosaka valodu"
226
+
227
+ #@ default
228
+ #: include/admin-filters.php:739
229
+ msgid "None"
230
+ msgstr "Nav"
231
+
232
+ #@ polylang
233
+ #: include/admin-filters.php:756
234
+ msgid "Theme locations and languages"
235
+ msgstr "Nosaka valodu"
236
+
237
+ #@ polylang
238
+ #: include/admin-filters.php:761
239
+ #, php-format
240
+ msgid "Please go to the %slanguages page%s to set theme locations and languages"
241
+ msgstr "Lūdzu dodieties uz %svalodu sadaļu%s, lai uzstādītu kažociņa izvēlņu valodas"
242
+
243
+ #@ polylang
244
+ #: include/admin-filters.php:772
245
+ msgid "The widget is displayed for:"
246
+ msgstr "Logdaļa tiek rādīta:"
247
+
248
+ #@ polylang
249
+ #: include/admin-filters.php:803
250
+ msgid "Admin language"
251
+ msgstr "Vadības valoda"
252
+
253
+ #@ polylang
254
+ #: include/list-table.php:27
255
+ msgid "Delete"
256
+ msgstr "Dzēst"
257
+
258
+ #@ polylang
259
+ #: include/languages-form.php:70
260
+ #: include/list-table.php:45
261
+ msgid "Full name"
262
+ msgstr "Pilns nosaukums"
263
+
264
+ #@ polylang
265
+ #: include/languages-form.php:76
266
+ #: include/list-table.php:46
267
+ msgid "Locale"
268
+ msgstr "Lokāle"
269
+
270
+ #@ polylang
271
+ #: include/list-table.php:47
272
+ msgid "Code"
273
+ msgstr "Kods"
274
+
275
+ #@ polylang
276
+ #: include/languages-form.php:98
277
+ #: include/list-table.php:48
278
+ msgid "Order"
279
+ msgstr "Secība"
280
+
281
+ #@ polylang
282
+ #: include/list-table.php:49
283
+ msgid "Flag"
284
+ msgstr "Karogs"
285
+
286
+ #@ polylang
287
+ #: include/list-table.php:50
288
+ msgid "Posts"
289
+ msgstr "Raksti"
290
+
291
+ #@ polylang
292
+ #: include/list-table.php:105
293
+ msgid "Strings translations"
294
+ msgstr "Tekstu tulkojumi"
295
+
296
+ #@ polylang
297
+ #: include/list-table.php:125
298
+ msgid "Name"
299
+ msgstr "Nosaukums"
300
+
301
+ #@ polylang
302
+ #: include/list-table.php:126
303
+ msgid "String"
304
+ msgstr "Teksts"
305
+
306
+ #@ default
307
+ #: include/calendar.php:132
308
+ #: include/calendar.php:140
309
+ #, php-format
310
+ msgid "View posts for %1$s %2$s"
311
+ msgstr "Skatīt rakstus %1$s %2$s"
312
+
313
+ #@ polylang
314
+ #: include/languages-form.php:36
315
+ msgid "Edit language"
316
+ msgstr "Rediģēt valodu"
317
+
318
+ #@ polylang
319
+ #: include/languages-form.php:36
320
+ #: include/languages-form.php:103
321
+ msgid "Add new language"
322
+ msgstr "Pievienot jaunu valodu"
323
+
324
+ #@ polylang
325
+ #: include/languages-form.php:58
326
+ msgid "Choose a language"
327
+ msgstr "Izvēlēties valodu"
328
+
329
+ #@ polylang
330
+ #: include/languages-form.php:66
331
+ msgid "You can choose a language in the list or directly edit it below."
332
+ msgstr "Jūs varat izvēlēties valodu no saraksta, vai ari rediģēt to zemāk."
333
+
334
+ #@ polylang
335
+ #: include/languages-form.php:72
336
+ msgid "The name is how it is displayed on your site (for example: English)."
337
+ msgstr "Nosaukums, kādu to attēlos lapā (piemēram: Latviešu)"
338
+
339
+ #@ polylang
340
+ #: include/languages-form.php:79
341
+ msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
342
+ msgstr "WordPress valodas lokāle šai valodai (piemēram: en_US). Jums nāksies uzstādīt .mo failu šai valodai."
343
+
344
+ #@ polylang
345
+ #: include/languages-form.php:83
346
+ msgid "Language code"
347
+ msgstr "Valodas kods (piem.: lv)"
348
+
349
+ #@ polylang
350
+ #: include/languages-form.php:85
351
+ msgid "2-letters ISO 639-1 language code (for example: en)"
352
+ msgstr "2 burtu ISO 639-1 valodas kods (piemēram: en)"
353
+
354
+ #@ polylang
355
+ #: include/languages-form.php:89
356
+ msgid "Text direction"
357
+ msgstr "Lasīšanas virziens"
358
+
359
+ #@ polylang
360
+ #: include/languages-form.php:91
361
+ msgid "left to right"
362
+ msgstr "no kreisās uz labo"
363
+
364
+ #@ polylang
365
+ #: include/languages-form.php:93
366
+ msgid "right to left"
367
+ msgstr "no labās uz kreiso"
368
+
369
+ #@ polylang
370
+ #: include/languages-form.php:94
371
+ msgid "Choose the text direction for the language"
372
+ msgstr "Izvēlieties lasīšanas virzienu šai valodai"
373
+
374
+ #@ polylang
375
+ #: include/languages-form.php:100
376
+ msgid "Position of the language in the language switcher"
377
+ msgstr "Valodas atrašanās vieta valodu izvēlnē"
378
+
379
+ #@ default
380
+ #: include/languages-form.php:103
381
+ msgid "Update"
382
+ msgstr "Atjaunot"
383
+
384
+ #@ polylang
385
+ #: include/languages-form.php:149
386
+ msgid "Language switcher"
387
+ msgstr "Valodu izvēlne"
388
+
389
+ #@ polylang
390
+ #: include/languages-form.php:188
391
+ msgid "Default language"
392
+ msgstr "Noklusētā valoda"
393
+
394
+ #@ polylang
395
+ #: include/languages-form.php:200
396
+ msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
397
+ msgstr "Ir atrasti raksti, lapas, tēmas, vai birkas bez uzstādītas valodas. Vai vēlaties uzstādīt tām visām noklusēto valodu?"
398
+
399
+ #@ polylang
400
+ #: include/languages-form.php:208
401
+ msgid "Detect browser language"
402
+ msgstr "Noteikt pārlūka valodu"
403
+
404
+ #@ polylang
405
+ #: include/languages-form.php:214
406
+ msgid "When the front page is visited, set the language according to the browser preference"
407
+ msgstr "Kad tiek apmeklēta sākumlapa, uzstāda valodu atkarībā no pārlūkprogrammas uzstādījumiem"
408
+
409
+ #@ polylang
410
+ #: include/languages-form.php:221
411
+ msgid "URL modifications"
412
+ msgstr "Saišu modifikācijas"
413
+
414
+ #@ polylang
415
+ #: include/languages-form.php:227
416
+ msgid "Keep /language/ in pretty permalinks. Example:"
417
+ msgstr "Atstāt /language/ nemainīgajās saitēs. Piemērs:"
418
+
419
+ #@ polylang
420
+ #: include/languages-form.php:235
421
+ msgid "Remove /language/ in pretty permalinks. Example:"
422
+ msgstr "Nerādīt /language/ nemainīgajās saitēs. Piemērs:"
423
+
424
+ #@ polylang
425
+ #: include/languages-form.php:243
426
+ msgid "Hide URL language information for default language"
427
+ msgstr "Paslēpt noklusētās valodas informāciju hipersaitēs"
428
+
429
+ #@ polylang
430
+ #: include/languages-form.php:250
431
+ msgid "Add language information to all URL including posts, pages, categories and post tags (not recommended)"
432
+ msgstr "Pievienot valodu informāciju visie URL ceļiem ieskaitot rakstus, lapas, tēmas un rakstu birkas (nav ieteicams)"
433
+
434
+ #@ polylang
435
+ #: include/base.php:38
436
+ msgid "All languages"
437
+ msgstr "Visas valodas"
438
+
439
+ #@ polylang
440
+ #: include/post-translations.php:1
441
+ msgid "ID of pages in other languages:"
442
+ msgstr "lapas ID citās valodās:"
443
+
444
+ #@ polylang
445
+ #: include/post-translations.php:1
446
+ msgid "ID of posts in other languages:"
447
+ msgstr "raksta ID citās valodās:"
448
+
449
+ #@ polylang
450
+ #: include/post-translations.php:5
451
+ msgid "Page ID"
452
+ msgstr "Lapas ID"
453
+
454
+ #@ polylang
455
+ #: include/post-translations.php:5
456
+ msgid "Post ID"
457
+ msgstr "Raksta ID"
458
+
459
+ #@ default
460
+ #. translators: Calendar caption: 1: month name, 2: 4-digit year
461
+ #: include/calendar.php:106
462
+ #, php-format
463
+ msgctxt "calendar caption"
464
+ msgid "%1$s %2$s"
465
+ msgstr "%2$s %1$s"
466
+
467
+ #@ polylang
468
+ #: include/about.php:3
469
+ #, php-format
470
+ msgid "Polylang is provided with an extensive %sdocumentation%s (in English only). It includes information on how to set up your multilingual site and use it on a daily basis, a FAQ, as well as a documentation for programmers to adapt their plugins and themes."
471
+ msgstr "Polylang tiek piedāvāts ar plašu %sdokumentāciju%s (tikai angliski). Tā satur informāciju par to kā uzstādīt vietni vairākās valodās un kā to lietot ikdienā, BUJ, kā arī dokumentāciju programmētājiem par spraudņu un kažociņu pielāgošanu."
472
+
473
+ #@ polylang
474
+ #: include/about.php:8
475
+ #, php-format
476
+ msgid "You will also find useful information in the %ssupport forum%s. However don't forget to make a search before posting a new topic."
477
+ msgstr "Noderīgu informāciju varat atrast arī %satbalsata forumā%s. Ieteicams veikt meklēšanu pirms atvērt jaunu foruma tematu."
478
+
479
+ #@ polylang
480
+ #: include/about.php:14
481
+ #, php-format
482
+ msgid "Polylang is free of charge and is released under the same license as WordPress, the %sGPL%s."
483
+ msgstr "Polylang ir bezmaksas un tiek piedāvāts ar to pašu licenci kā WordPress, %sGPL%s."
484
+
485
+ #@ polylang
486
+ #: include/about.php:18
487
+ #, php-format
488
+ msgid "If you wonder how you can help the project, just %sread this%s."
489
+ msgstr "Ja jūs prātojat kā varētu palīdzēt šim projektam, %sizlasiet šo%s."
490
+
491
+ #@ polylang
492
+ #: include/about.php:22
493
+ msgid "Finally if you like this plugin or if it helps your business, donations to the author are greatly appreciated."
494
+ msgstr "Visbeidzot, ja jums patīk šis spraudnis vai ari tas palīdz jūsu biznesā, ziedojumi autoram tiks augsti vērtēti."
495
+
496
+ #@ polylang
497
+ #: include/admin.php:38
498
+ msgid "About Polylang"
499
+ msgstr "Par Polylang"
500
+
501
+ #@ polylang
502
+ #: include/languages-form.php:257
503
+ #, php-format
504
+ msgid "Redirect the language page (example: %s) to the homepage in the right language"
505
+ msgstr "Pārvirzīt valodu lapu (piemērs: %s) uz sākumlapu pareizajā valodā"
506
+
507
+ #@ polylang
508
+ #: polylang.php:117
509
+ msgid "For some reasons, Polylang could not create a table in your database."
510
+ msgstr "Kaut kādu iemeslu dēļ Polylang nevārēja izveidot vajadzīgo tabulu datubāzē."
polylang.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://wordpress.org/extend/plugins/polylang/
5
- Version: 0.8
6
  Author: F. Demarle
7
  Description: Adds multilingual capability to Wordpress
8
  */
@@ -24,7 +24,7 @@ Description: Adds multilingual capability to Wordpress
24
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
 
27
- define('POLYLANG_VERSION', '0.8');
28
  define('PLL_MIN_WP_VERSION', '3.1');
29
 
30
  define('POLYLANG_DIR', dirname(__FILE__)); // our directory
@@ -74,11 +74,9 @@ class Polylang extends Polylang_Base {
74
  add_action('admin_init', array(&$this, 'admin_init'));
75
 
76
  // plugin and widget initialization
77
- add_action('init', array(&$this, 'init'), 1000); // called just after the init in Polylang_Base
78
  add_action('widgets_init', array(&$this, 'widgets_init'));
79
-
80
- // rewrite rules
81
- add_filter('rewrite_rules_array', array(&$this, 'rewrite_rules_array' ));
82
 
83
  // separate admin and frontend
84
  if (is_admin()) {
@@ -140,7 +138,7 @@ class Polylang extends Polylang_Base {
140
  return false;
141
 
142
  // codex tells to use the init action to call register_taxonomy but I need it now for my rewrite rules
143
- register_taxonomy('language', $this->post_types, array('label' => false, 'query_var'=>'lang'));
144
 
145
  // defines default values for options in case this is the first installation
146
  $options = get_option('polylang');
@@ -155,8 +153,9 @@ class Polylang extends Polylang_Base {
155
  update_option('polylang', $options);
156
 
157
  // add our rewrite rules
158
- global $wp_rewrite;
159
- $wp_rewrite->flush_rules();
 
160
  return true;
161
  }
162
 
@@ -178,8 +177,7 @@ class Polylang extends Polylang_Base {
178
 
179
  // plugin deactivation
180
  function _deactivate() {
181
- global $wp_rewrite;
182
- $wp_rewrite->flush_rules();
183
  }
184
 
185
  // restores the local_flags directory after upgrade from version 0.5.1 or older
@@ -262,9 +260,6 @@ class Polylang extends Polylang_Base {
262
  if (version_compare($options['version'], '0.7', '<'))
263
  $options['force_lang'] = 0; // option introduced in 0.7
264
 
265
- if (version_compare($options['version'], '0.8', '<'))
266
- $GLOBALS['wp_rewrite']->flush_rules(); // rewrite rules have been modified in 0.7.1 & 0.7.2 & 0.8
267
-
268
  // string translation storage model changed and option added in 0.8
269
  if (version_compare($options['version'], '0.8dev1', '<')) {
270
  if (function_exists('base64_decode')) {
@@ -278,6 +273,9 @@ class Polylang extends Polylang_Base {
278
  $options['redirect_lang'] = 0; // option introduced in 0.8
279
  }
280
 
 
 
 
281
  $options['version'] = POLYLANG_VERSION;
282
  update_option('polylang', $options);
283
  }
@@ -287,22 +285,18 @@ class Polylang extends Polylang_Base {
287
  function init() {
288
  global $wpdb;
289
  $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb
 
290
 
291
  // registers the language taxonomy
292
  // codex: use the init action to call this function
293
- register_taxonomy('language', $this->post_types, array(
 
294
  'label' => false,
295
  'public' => false, // avoid displaying the 'like post tags text box' in the quick edit
296
  'query_var'=>'lang',
 
297
  'update_count_callback' => '_update_post_term_count'));
298
 
299
- // optionaly removes 'language' in permalinks so that we get http://www.myblog/en/ instead of http://www.myblog/language/en/
300
- // the simple line of code is inspired by the WP No Category Base plugin: http://wordpresssupplies.com/wordpress-plugins/no-category-base/
301
- global $wp_rewrite;
302
- $options = get_option('polylang');
303
- if ($options['rewrite'] && $wp_rewrite->extra_permastructs)
304
- $wp_rewrite->extra_permastructs['language'][0] = '%language%';
305
-
306
  load_plugin_textdomain('polylang', false, basename(POLYLANG_DIR).'/languages'); // plugin i18n
307
  }
308
 
@@ -315,48 +309,57 @@ class Polylang extends Polylang_Base {
315
  register_widget('Polylang_Widget_Calendar');
316
  }
317
 
318
- // rewrites rules if pretty permalinks are used
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  // always make sure the default language is at the end in case the language information is hidden for default language
320
  // thanks to brbrbr http://wordpress.org/support/topic/plugin-polylang-rewrite-rules-not-correct
321
- function rewrite_rules_array($rules) {
 
 
 
 
 
322
  $options = get_option('polylang');
 
323
  $newrules = array();
324
- $languages = array();
325
 
326
- // don't modify the rules if there is no languages created
327
- if (!($listlanguages = $this->get_languages_list()))
328
- return $rules;
329
-
330
- foreach ($listlanguages as $language)
331
  if (!$options['hide_default'] || $options['default_lang'] != $language->slug)
332
  $languages[] = $language->slug;
333
 
334
- if ($languages) {
335
- $slug = '('.implode('|', $languages).')/';
336
- $slug = $options['rewrite'] ? $slug : 'language/'.$slug;
337
- }
338
 
339
  foreach ($rules as $key => $rule) {
340
- // rules which *always* need the language code
341
- $to_rewrite = in_array($key, array('feed/(feed|rdf|rss|rss2|atom)/?$', '(feed|rdf|rss|rss2|atom)/?$', 'page/?([0-9]{1,})/?$')) ||
342
- strpos($rule, 'withcomments=1') || strpos($rule, 'post_format=') || strpos($rule, 'author_name=') || strpos($rule, 'post_type=') ||
343
- strpos($rule, 'year=') && !(strpos($rule, 'p=') || strpos($rule, 'name=') || strpos($rule, 'page=') || strpos($rule, 'cpage='));
344
-
345
- // suppress the rules created by WordPress for our taxonomy
346
- if (strpos($rule, 'lang='))
347
- unset($rules[$key]);
348
-
349
  // special case for pages which do not accept adding the lang parameter
350
- elseif ($options['force_lang'] && strpos($rule, 'pagename')) {
351
  if (isset($slug))
352
  $newrules[$slug.$key] = str_replace(array('[4]', '[3]', '[2]', '[1]'), array('[5]', '[4]', '[3]', '[2]'), $rule); // hopefully it is sufficient !
353
 
354
- if (!$options['hide_default'])
355
- unset($rules[$key]); // now useless
 
 
356
  }
357
 
358
  // rewrite rules filtered by language
359
- elseif ($to_rewrite || ($options['force_lang'] && !strpos($rule, 'robots'))) {
360
  if (isset($slug))
361
  $newrules[$slug.$key] = str_replace(array('[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '[1]', '?'),
362
  array('[9]', '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '?lang=$matches[1]&'), $rule); // hopefully it is sufficient !
@@ -365,10 +368,14 @@ class Polylang extends Polylang_Base {
365
  $newrules[$key] = str_replace('?', '?lang='.$options['default_lang'].'&', $rule);
366
 
367
  unset($rules[$key]); // now useless
368
- }
369
  }
370
- // important to put home rewrite rule before unmodified rules
371
- return $newrules + array($slug.'?$' => 'index.php?lang=$matches[1]') + $rules;
 
 
 
 
372
  }
373
 
374
  } // class Polylang
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://wordpress.org/extend/plugins/polylang/
5
+ Version: 0.8.1
6
  Author: F. Demarle
7
  Description: Adds multilingual capability to Wordpress
8
  */
24
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
 
27
+ define('POLYLANG_VERSION', '0.8.1');
28
  define('PLL_MIN_WP_VERSION', '3.1');
29
 
30
  define('POLYLANG_DIR', dirname(__FILE__)); // our directory
74
  add_action('admin_init', array(&$this, 'admin_init'));
75
 
76
  // plugin and widget initialization
77
+ add_action('init', array(&$this, 'init'));
78
  add_action('widgets_init', array(&$this, 'widgets_init'));
79
+ add_action('wp_loaded', array(&$this, 'prepare_rewrite_rules'), 20); // after Polylang_base::add_post_types_taxonomies
 
 
80
 
81
  // separate admin and frontend
82
  if (is_admin()) {
138
  return false;
139
 
140
  // codex tells to use the init action to call register_taxonomy but I need it now for my rewrite rules
141
+ register_taxonomy('language', null , array('label' => false, 'query_var'=>'lang'));
142
 
143
  // defines default values for options in case this is the first installation
144
  $options = get_option('polylang');
153
  update_option('polylang', $options);
154
 
155
  // add our rewrite rules
156
+ $this->add_post_types_taxonomies();
157
+ $this->prepare_rewrite_rules();
158
+ $GLOBALS['wp_rewrite']->flush_rules();
159
  return true;
160
  }
161
 
177
 
178
  // plugin deactivation
179
  function _deactivate() {
180
+ $GLOBALS['wp_rewrite']->flush_rules();
 
181
  }
182
 
183
  // restores the local_flags directory after upgrade from version 0.5.1 or older
260
  if (version_compare($options['version'], '0.7', '<'))
261
  $options['force_lang'] = 0; // option introduced in 0.7
262
 
 
 
 
263
  // string translation storage model changed and option added in 0.8
264
  if (version_compare($options['version'], '0.8dev1', '<')) {
265
  if (function_exists('base64_decode')) {
273
  $options['redirect_lang'] = 0; // option introduced in 0.8
274
  }
275
 
276
+ if (version_compare($options['version'], '0.8.1', '<'))
277
+ $GLOBALS['wp_rewrite']->flush_rules(); // rewrite rules have been modified in 0.7.1 & 0.7.2 & 0.8 & 0.8.1
278
+
279
  $options['version'] = POLYLANG_VERSION;
280
  update_option('polylang', $options);
281
  }
285
  function init() {
286
  global $wpdb;
287
  $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb
288
+ $options = get_option('polylang');
289
 
290
  // registers the language taxonomy
291
  // codex: use the init action to call this function
292
+ // object types will be set later once all custom post types are registered
293
+ register_taxonomy('language', null, array(
294
  'label' => false,
295
  'public' => false, // avoid displaying the 'like post tags text box' in the quick edit
296
  'query_var'=>'lang',
297
+ 'rewrite' => array('slug' => $options['rewrite'] ? '' : 'language'), // http://www.myblog/en/ or http://www.myblog/language/en/ ?
298
  'update_count_callback' => '_update_post_term_count'));
299
 
 
 
 
 
 
 
 
300
  load_plugin_textdomain('polylang', false, basename(POLYLANG_DIR).'/languages'); // plugin i18n
301
  }
302
 
309
  register_widget('Polylang_Widget_Calendar');
310
  }
311
 
312
+ // complete our taxonomy and add rewrite rules filters once custom post types and taxonomies are registered (normally in init)
313
+ function prepare_rewrite_rules() {
314
+ foreach ($this->post_types as $post_type)
315
+ register_taxonomy_for_object_type('language', $post_type);
316
+
317
+ // don't modify the rules if there is no languages created yet
318
+ if (!$this->get_languages_list())
319
+ return;
320
+
321
+ $types = array_merge(array('post', 'date', 'root', 'comments', 'search', 'author', 'page'), array_keys($GLOBALS['wp_rewrite']->extra_permastructs));
322
+ $types = apply_filters('pll_rewrite_rules', $types); // allow plugins to add rewrite rules to the language filter
323
+ foreach ($types as $type)
324
+ add_filter($type . '_rewrite_rules', array(&$this, 'rewrite_rules'));
325
+
326
+ add_filter('rewrite_rules_array', array(&$this, 'rewrite_rules')); // needed for post type archives
327
+ }
328
+
329
+ // the rewrite rules !
330
  // always make sure the default language is at the end in case the language information is hidden for default language
331
  // thanks to brbrbr http://wordpress.org/support/topic/plugin-polylang-rewrite-rules-not-correct
332
+ function rewrite_rules($rules) {
333
+
334
+ // suppress the rules created by WordPress for our taxonomy
335
+ if (($current_filter = current_filter()) == 'language_rewrite_rules')
336
+ return array();
337
+
338
  $options = get_option('polylang');
339
+ $to_rewrite = array('date_rewrite_rules', 'root_rewrite_rules', 'comments_rewrite_rules', 'author_rewrite_rule', 'post_format_rewrite_rules');
340
  $newrules = array();
 
341
 
342
+ foreach ($this->get_languages_list() as $language)
 
 
 
 
343
  if (!$options['hide_default'] || $options['default_lang'] != $language->slug)
344
  $languages[] = $language->slug;
345
 
346
+ if (isset($languages))
347
+ $slug = $options['rewrite'] ? '('.implode('|', $languages).')/' : 'language/('.implode('|', $languages).')/';
 
 
348
 
349
  foreach ($rules as $key => $rule) {
 
 
 
 
 
 
 
 
 
350
  // special case for pages which do not accept adding the lang parameter
351
+ if ($current_filter == 'page_rewrite_rules' && $options['force_lang']) {
352
  if (isset($slug))
353
  $newrules[$slug.$key] = str_replace(array('[4]', '[3]', '[2]', '[1]'), array('[5]', '[4]', '[3]', '[2]'), $rule); // hopefully it is sufficient !
354
 
355
+ if ($options['hide_default'])
356
+ $newrules[$key] = $rules[$key];
357
+
358
+ unset($rules[$key]); // now useless
359
  }
360
 
361
  // rewrite rules filtered by language
362
+ elseif (in_array($current_filter, $to_rewrite) || strpos($rule, 'post_type=') || ($current_filter != 'rewrite_rules_array' && $options['force_lang'])) {
363
  if (isset($slug))
364
  $newrules[$slug.$key] = str_replace(array('[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '[1]', '?'),
365
  array('[9]', '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '?lang=$matches[1]&'), $rule); // hopefully it is sufficient !
368
  $newrules[$key] = str_replace('?', '?lang='.$options['default_lang'].'&', $rule);
369
 
370
  unset($rules[$key]); // now useless
371
+ }
372
  }
373
+
374
+ // the home rewrite rule
375
+ if ($current_filter == 'root_rewrite_rules' && isset($slug))
376
+ $newrules[$slug.'?$'] = 'index.php?lang=$matches[1]';
377
+
378
+ return $newrules + $rules;
379
  }
380
 
381
  } // class Polylang
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, i18n, international, l10n, localization
5
  Requires at least: 3.1
6
  Tested up to: 3.3.1
7
- Stable tag: 0.8
8
 
9
  Polylang adds multilingual content management support to WordPress.
10
 
@@ -38,8 +38,9 @@ The plugin admin interface is currently available in:
38
  * Dutch contributed by [AlbertGn](http://wordpress.org/support/profile/albertgn)
39
  * Hebrew contributed by [ArielK](http://www.arielk.net)
40
  * Polish contributed by [Peter Paciorkiewicz](http://www.paciorkiewicz.pl)
 
41
 
42
- Special thanks to [AndyDeGroo](http://wordpress.org/support/profile/andydegroo) and [RavanH](http://4visions.nl/) for their help in debugging and improving Polylang !
43
 
44
  Other [contributions](http://wordpress.org/extend/plugins/polylang/other_notes/) are welcome !
45
 
@@ -101,11 +102,11 @@ You can subscribe to the tag ['polylang-dev'](http://wordpress.org/tags/polylang
101
 
102
  = Translate the admin interface =
103
 
104
- Polylang is already available in 8 languages. It's very easy to add a new one ! Download [poedit](http://www.poedit.net/download.php) (available for Windows, Mac OS X and Linux). Rename the file polylang.pot found in the polylang/languages directory into something like polylang-your_locale.po. Open the file with poedit and start translating (keeping strange codes such as %s, %1$s as is). Once done, just save and you will get two files polylang-your_locale.po and polylang-your_locale.mo that you can send to the author. The translation will be included with the next release.
105
 
106
  = Communicate =
107
 
108
- If you like Polylang, you can spread the world... Rating the plugin is very easy, you can write some words about the plugin, make a link to the plugin page...
109
 
110
  = What else ? =
111
 
@@ -113,6 +114,20 @@ Every suggestions are welcome.
113
 
114
  == Changelog ==
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  = 0.8 (2012-02-29) =
117
 
118
  * Sticky posts are now filtered by language
@@ -145,6 +160,7 @@ Every suggestions are welcome.
145
  * Add Polish translation contributed by [Peter Paciorkiewicz](http://www.paciorkiewicz.pl)
146
  * Add 5 new languages to predefined list
147
  * completely reworked rewrite rules
 
148
  * Bug correction: custom nav menus do not work in Artisteer generated themes
149
  * Bug correction: having a single language causes multiple warnings while saving post/page.
150
  * Bug correction: custom nav menu broken on archives pages
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, i18n, international, l10n, localization
5
  Requires at least: 3.1
6
  Tested up to: 3.3.1
7
+ Stable tag: 0.8.1
8
 
9
  Polylang adds multilingual content management support to WordPress.
10
 
38
  * Dutch contributed by [AlbertGn](http://wordpress.org/support/profile/albertgn)
39
  * Hebrew contributed by [ArielK](http://www.arielk.net)
40
  * Polish contributed by [Peter Paciorkiewicz](http://www.paciorkiewicz.pl)
41
+ * Latvian contributed by [@AndyDeGroo](http://twitter.com/AndyDeGroo)
42
 
43
+ Special thanks to [@AndyDeGroo](http://twitter.com/AndyDeGroo) and [RavanH](http://4visions.nl/) for their help in debugging and improving Polylang !
44
 
45
  Other [contributions](http://wordpress.org/extend/plugins/polylang/other_notes/) are welcome !
46
 
102
 
103
  = Translate the admin interface =
104
 
105
+ Polylang is already available in 9 languages. It's very easy to add a new one ! Download [poedit](http://www.poedit.net/download.php) (available for Windows, Mac OS X and Linux). Rename the file polylang.pot found in the polylang/languages directory into something like polylang-your_locale.po. Open the file with poedit and start translating (keeping strange codes such as %s, %1$s as is). Once done, just save and you will get two files polylang-your_locale.po and polylang-your_locale.mo that you can send to the author. The translation will be included with the next release.
106
 
107
  = Communicate =
108
 
109
+ If you like Polylang, you can spread the word... Rating the plugin is very easy, you can write some words about the plugin, make a link to the plugin page...
110
 
111
  = What else ? =
112
 
114
 
115
  == Changelog ==
116
 
117
+ = 0.8.1 (2012-03-11) =
118
+
119
+ * Add Latvian translation contributed by [@AndyDeGroo](http://twitter.com/AndyDeGroo)
120
+ * It is now possible to synchronize multiple values for custom fields
121
+ * Add new API function pll_current_language
122
+ * Add the pll_rewrite_rules filter allowing plugins to filter rewrite rules by language
123
+ * WP 3.4 preparation: disable the menu section in the customize theme admin panel (unusable with Polylang)
124
+ * Bug correction: removing 'language' in permalinks does not work in WP 3.4 alpha
125
+ * Bug correction: problems with custom post type archives when 'has_archive' is set (thanks to AndyDeGroo)
126
+ * Bug correction: 404 error when combining %postname% permastructure with "Add language information to all URL" option
127
+ * Bug correction: translated custom strings are duplicated if registered several times
128
+ * Bug correction: queries with an array of post types are not correctly filtered
129
+ * Bug correction: wp-login.php always in English
130
+
131
  = 0.8 (2012-02-29) =
132
 
133
  * Sticky posts are now filtered by language
160
  * Add Polish translation contributed by [Peter Paciorkiewicz](http://www.paciorkiewicz.pl)
161
  * Add 5 new languages to predefined list
162
  * completely reworked rewrite rules
163
+ * WP 3.4 preparation: add new WordPress languages files to download when creating a new language
164
  * Bug correction: custom nav menus do not work in Artisteer generated themes
165
  * Bug correction: having a single language causes multiple warnings while saving post/page.
166
  * Bug correction: custom nav menu broken on archives pages
screenshot-1.png CHANGED
Binary file