Polylang - Version 0.4

Version Description

  • Add a documentation (in English only)
  • Add the possibility to hide the url language information for the default language
  • Add the possibility to set the admin language in the user profile
  • Add the possibilty to fill existing posts, pages, categories & tags with the default language
  • Add support for custom post types and custom taxonomies
  • Add the possibility to display flags in the language switcher
  • Add CSS classes to customize rendering of the language switcher
  • Add the possibility to display the language switcher as a dropdown list
  • Add support for calendar widget
  • Improve performance: less sql queries
  • Improve data validation when creating or updating languages
  • Bug correction: 'wp_list_pages' page order is ignored when plugin is enabled
  • Bug correction: when using 'edit' or 'add new' (translation) for posts, the categories appear in the wrong language
  • Bug correction: pages are not included in language post count
  • Bug correction: the language switcher does not display languages if there are only pages
  • Bug correction: the widget filterdoes not allow to come back to 'all languages' once a language has been set
  • Other minor bug corrections

release: November 10th, 2011

Download this release

Release Info

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

Code changes from version 0.3.2 to 0.4

css/admin.css ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #term-translations table {
2
+ width: 100%;
3
+ }
4
+
5
+ #term-translations th {
6
+ padding: 0px;
7
+ font-weight: bold;
8
+ text-align: left;
9
+ }
10
+
11
+ #term-translations td {
12
+ padding: 0px;
13
+ }
14
+
15
+ #term-translations select {
16
+ width: 15em;
17
+ }
18
+
19
+ #post-translations table {
20
+ width: 100%;
21
+ text-align: left;
22
+ font-size: 11px;
23
+ margin: 0 6px;
24
+ }
25
+
26
+ #post-translations td {
27
+ font-size: 11px;
28
+ }
doc/documentation-en.odt ADDED
Binary file
doc/documentation-en.pdf ADDED
Binary file
flags/de_DE.png ADDED
Binary file
flags/en_US.png ADDED
Binary file
flags/fr_FR.png ADDED
Binary file
add-term-form.php → include/add-term-form.php RENAMED
@@ -12,5 +12,5 @@
12
  <div id="term-translations" class="form-field"><?php
13
  // adds translation field if we already know the language
14
  if (isset($_GET['from_tag']) && isset($_GET['from_lang']) && isset($_GET['new_lang']))
15
- include(POLYLANG_DIR.'/term-translations.php');?>
16
  </div>
12
  <div id="term-translations" class="form-field"><?php
13
  // adds translation field if we already know the language
14
  if (isset($_GET['from_tag']) && isset($_GET['from_lang']) && isset($_GET['new_lang']))
15
+ include(INC_DIR.'/term-translations.php');?>
16
  </div>
admin.php → include/admin.php RENAMED
@@ -1,29 +1,29 @@
1
  <?php
2
 
3
- require_once(POLYLANG_DIR.'/list-table.php');
4
- define('POLYLANG_URL', WP_PLUGIN_URL .'/polylang');
5
 
6
  class Polylang_Admin extends Polylang_Base {
7
  function __construct() {
8
  add_action('admin_init', array(&$this, 'admin_init'));
9
 
10
  // adds a 'settings' link in the plugins table
11
- $plugin_file = basename( dirname( __FILE__ ) ).'/polylang.php';
12
  add_filter('plugin_action_links_'.$plugin_file, array(&$this, 'plugin_action_links'));
13
 
14
- // adds the link to the languages panel in the wordpress admin menu
15
  add_action('admin_menu', array(&$this, 'add_menus'));
16
 
17
- // setup js scripts
18
  add_action('admin_print_scripts', array($this,'admin_js'));
 
19
 
20
- // add the language column (as well as a filter by language) in 'All Posts' an 'All Pages' panels
21
  add_filter('manage_posts_columns', array(&$this, 'add_post_column'), 10, 2);
22
  add_filter('manage_pages_columns', array(&$this, 'add_post_column'));
23
  add_action('manage_posts_custom_column', array(&$this, 'post_column'), 10, 2);
24
  add_action('manage_pages_custom_column', array(&$this, 'post_column'), 10, 2);
25
  add_filter('parse_query',array(&$this,'parse_query'));
26
- add_action('restrict_manage_posts', array(&$this, 'restrict_manage_posts'));
27
 
28
  // adds the Languages box in the 'Edit Post' and 'Edit Page' panels
29
  add_action('add_meta_boxes', array(&$this, 'add_meta_boxes'));
@@ -31,35 +31,13 @@ class Polylang_Admin extends Polylang_Base {
31
  // ajax response for post metabox
32
  add_action('wp_ajax_post_lang_choice', array($this,'post_lang_choice'));
33
 
34
- // adds actions related to languages when saving aor deleting posts and pages
35
  add_action('save_post', array(&$this, 'save_post'));
36
  add_action('before_delete_post', array(&$this, 'delete_post'));
37
 
38
- // adds the language field in the 'Categories' and 'Post Tags' panels
39
- add_action('category_add_form_fields', array(&$this, 'add_term_form'));
40
- add_action('post_tag_add_form_fields', array(&$this, 'add_term_form'));
41
-
42
- // adds the language field and translations tables in the 'Edit Category' and 'Edit Tag' panels
43
- add_action('category_edit_form_fields', array(&$this, 'edit_term_form'));
44
- add_action('post_tag_edit_form_fields', array(&$this, 'edit_term_form'));
45
-
46
  // ajax response for edit term form
47
  add_action('wp_ajax_term_lang_choice', array($this,'term_lang_choice'));
48
 
49
- // adds the language column in the 'Categories' and 'Post Tags' tables
50
- add_filter('manage_edit-category_columns', array(&$this, 'add_term_column'));
51
- add_filter('manage_edit-post_tag_columns', array(&$this, 'add_term_column'));
52
- add_action('manage_category_custom_column', array(&$this, 'term_column'), 10, 3);
53
- add_action('manage_post_tag_custom_column', array(&$this, 'term_column'), 10, 3);
54
-
55
- // adds actions related to languages when saving or deleting categories and post tags
56
- add_action('created_category', array(&$this, 'save_term'));
57
- add_action('created_post_tag', array(&$this, 'save_term'));
58
- add_action('edited_category', array(&$this, 'save_term'));
59
- add_action('edited_post_tag', array(&$this, 'save_term'));
60
- add_action('delete_category', array(&$this, 'delete_term'));
61
- add_action('delete_post_tag', array(&$this, 'delete_term'));
62
-
63
  // modifies the theme location nav menu metabox
64
  add_filter('admin_head-nav-menus.php', array(&$this, 'nav_menu_theme_locations'));
65
 
@@ -67,17 +45,43 @@ class Polylang_Admin extends Polylang_Base {
67
  add_action('in_widget_form', array(&$this, 'in_widget_form'));
68
  add_filter('widget_update_callback', array(&$this, 'widget_update_callback'), 10, 4);
69
 
 
 
 
 
 
70
  // refresh rewrite rules if the 'page_on_front' option is modified
71
  add_action('update_option', array(&$this, 'update_option'));
72
  }
73
 
74
- // manage versions
75
- // not very useful now but we don't know the future
76
  function admin_init() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  $options = get_option('polylang');
78
  if ($options['version'] < POLYLANG_VERSION) {
 
 
 
 
79
  $options['version'] = POLYLANG_VERSION;
80
- update_option('polylang', $options);
81
  }
82
  }
83
 
@@ -89,13 +93,18 @@ class Polylang_Admin extends Polylang_Base {
89
  }
90
 
91
  // adds the link to the languages panel in the wordpress admin menu
92
- function add_menus() {
93
- add_submenu_page('options-general.php', __('Languages','polylang'), __('Languages','polylang'), 'manage_options', 'mlang', array($this, 'languages_page'));
94
  }
95
 
96
  // setup js scripts
97
  function admin_js() {
98
- wp_enqueue_script('polylang_admin', POLYLANG_URL.'/admin.js');
 
 
 
 
 
99
  }
100
 
101
  // the languages panel
@@ -111,17 +120,14 @@ class Polylang_Admin extends Polylang_Base {
111
  $menus = wp_get_nav_menus();
112
  $menu_lang = get_option('polylang_nav_menus');
113
 
114
- $action = '';
115
- if (isset($_REQUEST['action']))
116
- $action = $_REQUEST['action'];
117
 
118
  switch ($action) {
119
  case 'add':
120
  check_admin_referer( 'add-lang', '_wpnonce_add-lang' );
 
121
 
122
- // FIXME improve data validation
123
- // FIXME add an error message if conditions are not fulfilled
124
- if ($_POST['name'] && $_POST['description'] && $_POST['slug']) {
125
  wp_insert_term($_POST['name'],'language',array('slug'=>$_POST['slug'], 'description'=>$_POST['description']));
126
  $wp_rewrite->flush_rules(); // refresh rewrite rules
127
 
@@ -130,7 +136,8 @@ class Polylang_Admin extends Polylang_Base {
130
  update_option('polylang', $options);
131
  }
132
  }
133
- wp_redirect('admin.php?page=mlang'); // to refresh the page (possible thanks to the $_GET['noheader']=true)
 
134
  exit;
135
  break;
136
 
@@ -146,11 +153,11 @@ class Polylang_Admin extends Polylang_Base {
146
  $args = array('numberposts'=>-1, 'taxonomy' => 'language', 'term' => $lang_slug, 'post_type'=>'any', 'post_status'=>'any');
147
  $posts = get_posts($args);
148
  foreach ($posts as $post) {
149
- foreach ($languages as $language) {
150
  delete_post_meta($post->ID, '_lang-'.$language->slug);
151
  }
152
  }
153
-
154
  // delete references to this language in all posts
155
  $args = array('numberposts'=>-1, 'meta_key'=>'_lang-'.$lang_slug, 'post_type'=>'any', 'post_status'=>'any');
156
  $posts = get_posts($args);
@@ -159,10 +166,10 @@ class Polylang_Admin extends Polylang_Base {
159
  }
160
 
161
  // delete references to this language in categories & post tags
162
- $terms = get_terms(array('category', 'post_tag'), 'get=all');
163
  foreach ($terms as $term) {
164
  if ($this->get_term_language($term->term_id) == $lang) {
165
- foreach ($languages as $language) {
166
  delete_metadata('term', $term->term_id, '_lang-'.$language->slug); // deletes translations of this term
167
  }
168
  delete_metadata('term', $term->term_id, '_language', $lang_id); // delete language of this term
@@ -175,13 +182,13 @@ class Polylang_Admin extends Polylang_Base {
175
  $wp_rewrite->flush_rules(); // refresh rewrite rules
176
 
177
  // oops ! we deleted the default language...
178
- if ($options['default_lang'] == $lang_slug) {
179
- if (!empty($languages))
180
- $options['default_lang'] = $languages[0]->slug; // arbitrary choice...
181
  else
182
  unset($options['default_lang']);
183
  update_option('polylang', $options);
184
- }
185
  }
186
  wp_redirect('admin.php?page=mlang'); // to refresh the page (possible thanks to the $_GET['noheader']=true)
187
  exit;
@@ -189,17 +196,17 @@ class Polylang_Admin extends Polylang_Base {
189
 
190
  case 'edit':
191
  if (isset($_GET['lang']) && $_GET['lang'])
192
- $edit_lang = $this->get_language((int) $_GET['lang']);
193
  break;
194
 
195
  case 'update':
196
  check_admin_referer( 'add-lang', '_wpnonce_add-lang' );
 
 
 
197
 
198
- // FIXME add an error message if conditions are not fulfilled
199
- if ($_POST['lang'] && $_POST['name'] && $_POST['description'] && $_POST['slug']) {
200
  // Update links to this language in posts and terms in case the slug has been modified
201
- $lang_id = (int) $_POST['lang'];
202
- $lang = $this->get_language($lang_id);
203
  $old_slug = $lang->slug;
204
 
205
  if ($old_slug != $_POST['slug']) {
@@ -213,21 +220,21 @@ class Polylang_Admin extends Polylang_Base {
213
  }
214
 
215
  // update the language slug in categories & post tags meta
216
- $terms = get_terms(array('category', 'post_tag'), 'get=all');
217
  foreach ($terms as $term) {
218
- $term_id = get_metadata('term', $term->term_id, '_lang-'.$old_slug, true);
219
- if ($term_id) {
220
  delete_metadata('term', $term->term_id, '_lang-'.$old_slug);
221
  update_metadata('term', $term->term_id, '_lang-'.$_POST['slug'], $term_id);
222
  }
223
- }
224
  }
225
 
226
- // and finally update the language itself
227
  wp_update_term($lang_id, 'language', array('name'=>$_POST['name'], 'slug'=>$_POST['slug'], 'description'=>$_POST['description']));
228
  $wp_rewrite->flush_rules(); // refresh rewrite rules
229
  }
230
- wp_redirect('admin.php?page=mlang'); // to refresh the page (possible thanks to the $_GET['noheader']=true)
 
231
  exit;
232
  break;
233
 
@@ -241,35 +248,99 @@ class Polylang_Admin extends Polylang_Base {
241
  case 'options':
242
  check_admin_referer( 'options-lang', '_wpnonce_options-lang' );
243
 
244
- $options['rewrite'] = $_POST['rewrite'];
245
- isset($_POST['browser']) ? $options['browser'] = 1 : $options['browser'] = 0;
246
  $options['default_lang'] = $_POST['default_lang'];
 
 
 
247
  update_option('polylang', $options);
248
 
249
- // refresh refresh permalink structure and rewrite rules in case rewrite option has been modified
250
- $wp_rewrite->extra_permastructs['language'][0] = $options['rewrite'] ? '%language%' : '/language/%language%';
251
- $wp_rewrite->flush_rules();
252
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
 
254
  default:
255
  }
256
 
257
  // prepare the list table of languages
258
  $data = array();
259
- foreach ($listlanguages as $lang)
260
  $data[] = (array) $lang;
261
 
262
  $list_table->prepare_items($data);
263
 
264
- // displays the page
265
- include(POLYLANG_DIR.'/languages-form.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  }
267
 
268
  // adds the language column (before the date column) in the posts and pages list table
269
  function add_post_column($columns, $post_type ='') {
270
- if (in_array($post_type, array('', 'post', 'page'))) {
271
- $keys = array( 'date', 'comments' );
272
- foreach ($keys as $k) {
273
  if (array_key_exists($k, $columns))
274
  $end[$k] = array_pop($columns);
275
  }
@@ -284,8 +355,7 @@ class Polylang_Admin extends Polylang_Base {
284
 
285
  // fills the language column in the posts table
286
  function post_column($column, $post_id) {
287
- $lang = $this->get_post_language($post_id);
288
- if ($lang && $column == 'language')
289
  echo esc_attr($lang->name);
290
  }
291
 
@@ -294,36 +364,35 @@ class Polylang_Admin extends Polylang_Base {
294
  function parse_query($query) {
295
  global $pagenow;
296
  $qvars = &$query->query_vars;
297
- if ($pagenow=='edit.php' && isset($qvars['lang']) && $qvars['lang'] && is_numeric($qvars['lang'])) {
298
- $lang = $this->get_language($qvars['lang']);
299
- if ($lang)
300
- $qvars['lang'] = $lang->slug;
301
- }
302
  }
303
 
304
  // adds a filter for languages in the Posts and Pages panels
305
  function restrict_manage_posts() {
306
  global $wp_query;
307
- $screen = get_current_screen();
308
  $languages = $this->get_languages_list();
309
 
310
  if (!empty($languages) && $screen->base == 'edit') {
311
  $qvars = $wp_query->query;
312
  wp_dropdown_categories(array(
313
  'show_option_all' => __('Show all languages', 'polylang'),
314
- 'name' => 'lang',
315
  'selected' => isset($qvars['lang']) ? $qvars['lang'] : 0,
316
- 'taxonomy' => 'language'));
 
 
317
  }
318
  }
319
 
320
- // adds the Languages box in the 'Edit Post' and 'Edit Page' panels
321
  function add_meta_boxes() {
322
- add_meta_box('ml_box', __('Languages','polylang'), array(&$this,'post_language'), 'post', 'side','high');
323
- add_meta_box('ml_box', __('Languages','polylang'), array(&$this,'post_language'), 'page', 'side','high');
324
  }
325
 
326
- // the Languages metabox in the 'Edit Post' and 'Edit Page' panels
327
  function post_language() {
328
  global $post_ID;
329
  $post_type = get_post_type($post_ID);
@@ -333,8 +402,8 @@ class Polylang_Admin extends Polylang_Base {
333
  $lang = $this->get_language($_GET['new_lang']);
334
 
335
  $listlanguages = $this->get_languages_list();
336
-
337
- include(POLYLANG_DIR.'/post-metabox.php');
338
  }
339
 
340
  // ajax response for post metabox
@@ -346,7 +415,7 @@ class Polylang_Admin extends Polylang_Base {
346
  $post_type = get_post_type($post_ID);
347
 
348
  if ($lang && !is_wp_error($lang))
349
- include(POLYLANG_DIR.'/post-translations.php');
350
 
351
  die();
352
  }
@@ -354,22 +423,20 @@ class Polylang_Admin extends Polylang_Base {
354
  // called when a post (or page) is saved, published or updated
355
  // the underscore in '_lang' hides the post meta in the Custom Fields metabox in the Edit Post screen
356
  function save_post($post_id) {
357
-
358
- $id = wp_is_post_revision($post_id);
359
- if ($id)
360
  $post_id = $id;
361
 
362
  if (isset($_POST['post_lang_choice']))
363
  wp_set_post_terms($post_id, $_POST['post_lang_choice'], 'language' );
364
 
365
- $lang = $this->get_post_language($post_id);
366
  $listlanguages = $this->get_languages_list();
367
 
368
  foreach ($listlanguages as $language) {
369
 
370
  if (isset($_POST[$language->slug]) && $_POST[$language->slug]) {
371
  // FIXME I don't check that the translated post is in the right language !
372
- update_post_meta($post_id, '_lang-'.$language->slug, $_POST[$language->slug]); // saves the links to translated posts
373
  if ($lang)
374
  update_post_meta($this->get_translated_post($post_id, $language), '_lang-'.$lang->slug, $post_id); // tells the translated to link to this post
375
  }
@@ -377,6 +444,7 @@ class Polylang_Admin extends Polylang_Base {
377
  // deletes the translation in case there was previously one
378
  if ($lang)
379
  delete_post_meta($this->get_translated_post($post_id, $language), '_lang-'.$lang->slug); // in the translated post
 
380
  delete_post_meta($post_id, '_lang-'.$language->slug); // in this post
381
  }
382
  }
@@ -384,8 +452,7 @@ class Polylang_Admin extends Polylang_Base {
384
  // propagates translations between them
385
  foreach ($listlanguages as $language) {
386
  foreach ($listlanguages as $lg) {
387
- $id = $this->get_translated_post($post_id, $lg);
388
- if ($lg != $lang && $lg != $language && $id)
389
  update_post_meta($this->get_translated_post($post_id, $language), '_lang-'.$lg->slug, $id);
390
  }
391
  }
@@ -393,17 +460,14 @@ class Polylang_Admin extends Polylang_Base {
393
 
394
  // called when a post (or page) is deleted
395
  function delete_post($post_id) {
396
- $id = wp_is_post_revision($post_id);
397
- if ($id)
398
  $post_id = $id;
399
 
400
- $lang = $this->get_post_language($post_id);
401
- if($lang) {
402
- $listlanguages = $this->get_languages_list();
403
- foreach ($listlanguages as $language) {
404
  delete_post_meta($this->get_translated_post($post_id, $language), '_lang-'.$lang->slug); // delete links to this post
405
  // WP deletes post metas linked to this post so it is useless to do it before
406
- }
407
  }
408
  }
409
 
@@ -412,12 +476,12 @@ class Polylang_Admin extends Polylang_Base {
412
  $taxonomy = $_GET['taxonomy'];
413
  $lang = null;
414
  if (isset($_GET['new_lang']))
415
- $lang = $this->get_language($_GET['new_lang']);
416
 
417
  $listlanguages = $this->get_languages_list();
418
 
419
  // displays the language field
420
- include(POLYLANG_DIR.'/add-term-form.php');
421
  }
422
 
423
  // adds the language field and translations tables in the 'Edit Category' and 'Edit Tag' panels
@@ -427,22 +491,7 @@ class Polylang_Admin extends Polylang_Base {
427
  $taxonomy = $tag->taxonomy;
428
  $listlanguages = $this->get_languages_list();
429
 
430
- include(POLYLANG_DIR.'/edit-term-form.php');
431
- }
432
-
433
- // ajax response for edit term form
434
- function term_lang_choice()
435
- {
436
- if ($_POST['lang']) {
437
- $lang = $this->get_language($_POST['lang']);
438
- $term_id = isset($_POST['term_id']) ? $_POST['term_id'] : null;
439
- $taxonomy = $_POST['taxonomy'];
440
-
441
- $listlanguages = $this->get_languages_list();
442
-
443
- include(POLYLANG_DIR.'/term-translations.php');
444
- }
445
- die();
446
  }
447
 
448
  // adds the language column (before the posts column) in the 'Categories' or Post Tags table
@@ -460,11 +509,11 @@ class Polylang_Admin extends Polylang_Base {
460
 
461
  // fills the language column in the 'Categories' or Post Tags table
462
  function term_column($empty, $column, $term_id) {
463
- $lang = $this->get_term_language($term_id);
464
- if ($lang && $column == 'language')
465
  echo esc_attr($lang->name);
466
  }
467
 
 
468
  // called when a category or post tag is created or edited
469
  function save_term($term_id) {
470
 
@@ -498,8 +547,7 @@ class Polylang_Admin extends Polylang_Base {
498
  if (isset($lang)) {
499
  foreach ($listlanguages as $language) {
500
  foreach ($listlanguages as $lg) {
501
- $id = $this->get_translated_term($term_id, $lg);
502
- if ($lg != $lang && $lg != $language && $id)
503
  update_metadata('term',$this->get_translated_term($term_id, $language), '_lang-'.$lg->slug, $id);
504
  }
505
  }
@@ -509,41 +557,51 @@ class Polylang_Admin extends Polylang_Base {
509
 
510
  // called when a category or post tag is deleted
511
  function delete_term($term_id) {
512
- $lang = $this->get_term_language($term_id);
513
- if($lang) {
514
- delete_metadata('term', $term_id, '_language' );
515
  $listlanguages = $this->get_languages_list();
516
  foreach ($listlanguages as $language) {
517
  delete_metadata('term', $this->get_translated_term($term_id, $language), '_lang-'.$lang->slug); // delete links to this term
518
- }
519
  foreach ($listlanguages as $language) {
520
  delete_metadata('term', $term_id, '_lang-'.$language->slug);
521
- }
522
  }
523
  }
524
 
525
  // returns all terms in the $taxonomy in the $term_language which have no translation in the $translation_language
526
  function get_terms_not_translated($taxonomy, $term_language, $translation_language) {
527
  $new_terms = array();
528
- $terms = get_terms($taxonomy, 'hide_empty=0');
529
- foreach ($terms as $term) {
530
  $lang = $this->get_term_language($term->term_id);
531
- if ($lang && $lang->name == $term_language->name) {
532
- $translated_term = $this->get_translated_term($term->term_id, $translation_language);
533
- if (!$translated_term)
534
- $new_terms[] = $term;
535
- }
536
  }
537
  return $new_terms;
538
  }
539
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
  // modifies the theme location nav menu metabox
541
  function nav_menu_theme_locations() {
542
- // only if the theme supports nav menus
543
- if ( ! current_theme_supports( 'menus' ) )
544
  return;
545
 
546
- // thanks to : http://wordpress.stackexchange.com/questions/2770/how-to-add-a-custom-metabox-to-the-menu-management-admin-screen
547
  $metabox = &$GLOBALS['wp_meta_boxes']['nav-menus']['side']['default']['nav-menu-theme-locations'];
548
  $metabox['callback'] = array(&$this,'nav_menu_language');
549
  $metabox['title'] = __('Theme locations and languages', 'polylang');
@@ -558,22 +616,21 @@ class Polylang_Admin extends Polylang_Base {
558
  // modifies the widgets forms to add our language dropdwown list
559
  function in_widget_form($widget) {
560
  $id = esc_attr($widget->id.'_lang_choice');
561
- $listlanguages = $this->get_languages_list();
562
  $widget_lang = get_option('polylang_widgets');
563
 
564
  printf(
565
- '<p><label for="%s">%s<select name="%s" id="%s" class="tags-input"><option value="0">%s</option>',
566
  $id,
567
  __('The widget is displayed for:', 'polylang'),
568
  $id,
569
  $id,
570
  __('All languages', 'polylang')
571
  );
572
- foreach ($listlanguages as $language) {
573
  printf(
574
  "<option value='%s'%s>%s</option>\n",
575
  esc_attr($language->slug),
576
- $language->slug == $widget_lang[$widget->id] ? ' selected="selected"' : '',
577
  esc_attr($language->name)
578
  );
579
  }
@@ -582,20 +639,32 @@ class Polylang_Admin extends Polylang_Base {
582
 
583
  // called when widget options are saved
584
  function widget_update_callback($instance, $new_instance, $old_instance, $widget) {
585
- $id = $widget->id.'_lang_choice';
586
- if (isset($_POST[$id]) && $_POST[$id]) {
587
- $widget_lang = get_option('polylang_widgets');
588
- $widget_lang[$widget->id] = $_POST[$id];
589
- update_option('polylang_widgets', $widget_lang);
590
- }
591
  return $instance;
592
  }
593
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
594
  // refresh rewrite rules if the 'page_on_front' option is modified
595
  function update_option($option) {
596
  global $wp_rewrite;
597
  if ($option == 'page_on_front')
598
- $wp_rewrite->flush_rules();
599
  }
600
  } // class Polylang_Admin
601
 
1
  <?php
2
 
3
+ require_once(INC_DIR.'/list-table.php');
 
4
 
5
  class Polylang_Admin extends Polylang_Base {
6
  function __construct() {
7
  add_action('admin_init', array(&$this, 'admin_init'));
8
 
9
  // adds a 'settings' link in the plugins table
10
+ $plugin_file = basename(POLYLANG_DIR).'/polylang.php';
11
  add_filter('plugin_action_links_'.$plugin_file, array(&$this, 'plugin_action_links'));
12
 
13
+ // adds the link to the languages panel in the wordpress admin menu
14
  add_action('admin_menu', array(&$this, 'add_menus'));
15
 
16
+ // setup js scripts andd css styles
17
  add_action('admin_print_scripts', array($this,'admin_js'));
18
+ add_action('admin_print_styles', array($this,'admin_css'));
19
 
20
+ // add the language column (as well as a filter by language) in 'All Posts' an 'All Pages' panels
21
  add_filter('manage_posts_columns', array(&$this, 'add_post_column'), 10, 2);
22
  add_filter('manage_pages_columns', array(&$this, 'add_post_column'));
23
  add_action('manage_posts_custom_column', array(&$this, 'post_column'), 10, 2);
24
  add_action('manage_pages_custom_column', array(&$this, 'post_column'), 10, 2);
25
  add_filter('parse_query',array(&$this,'parse_query'));
26
+ add_action('restrict_manage_posts', array(&$this, 'restrict_manage_posts'));
27
 
28
  // adds the Languages box in the 'Edit Post' and 'Edit Page' panels
29
  add_action('add_meta_boxes', array(&$this, 'add_meta_boxes'));
31
  // ajax response for post metabox
32
  add_action('wp_ajax_post_lang_choice', array($this,'post_lang_choice'));
33
 
34
+ // adds actions related to languages when saving or deleting posts and pages
35
  add_action('save_post', array(&$this, 'save_post'));
36
  add_action('before_delete_post', array(&$this, 'delete_post'));
37
 
 
 
 
 
 
 
 
 
38
  // ajax response for edit term form
39
  add_action('wp_ajax_term_lang_choice', array($this,'term_lang_choice'));
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  // modifies the theme location nav menu metabox
42
  add_filter('admin_head-nav-menus.php', array(&$this, 'nav_menu_theme_locations'));
43
 
45
  add_action('in_widget_form', array(&$this, 'in_widget_form'));
46
  add_filter('widget_update_callback', array(&$this, 'widget_update_callback'), 10, 4);
47
 
48
+ // language management for users
49
+ add_filter('locale', array(&$this, 'get_locale'));
50
+ add_action('personal_options_update', array(&$this, 'personal_options_update'));
51
+ add_action('personal_options', array(&$this, 'personal_options'));
52
+
53
  // refresh rewrite rules if the 'page_on_front' option is modified
54
  add_action('update_option', array(&$this, 'update_option'));
55
  }
56
 
 
 
57
  function admin_init() {
58
+ // add these actions and filters here and not in the constructor to be sure all taxonomies are registered
59
+ foreach (get_taxonomies(array('show_ui'=>true)) as $tax) {
60
+ // adds the language field in the 'Categories' and 'Post Tags' panels
61
+ add_action($tax.'_add_form_fields', array(&$this, 'add_term_form'));
62
+
63
+ // adds the language field and translations tables in the 'Edit Category' and 'Edit Tag' panels
64
+ add_action($tax.'_edit_form_fields', array(&$this, 'edit_term_form'));
65
+
66
+ // adds the language column in the 'Categories' and 'Post Tags' tables
67
+ add_filter('manage_edit-'.$tax.'_columns', array(&$this, 'add_term_column'));
68
+ add_action('manage_'.$tax.'_custom_column', array(&$this, 'term_column'), 10, 3);
69
+
70
+ // adds actions related to languages when saving or deleting categories and post tags
71
+ add_action('created_'.$tax, array(&$this, 'save_term'));
72
+ add_action('edited_'.$tax, array(&$this, 'save_term'));
73
+ add_action('delete_'.$tax, array(&$this, 'delete_term'));
74
+ }
75
+
76
+ // manage versions
77
  $options = get_option('polylang');
78
  if ($options['version'] < POLYLANG_VERSION) {
79
+
80
+ if($options['version'] < '0.4')
81
+ $options['hide_default'] = 0; // option introduced in 0.4
82
+
83
  $options['version'] = POLYLANG_VERSION;
84
+ update_option('polylang', $options);
85
  }
86
  }
87
 
93
  }
94
 
95
  // adds the link to the languages panel in the wordpress admin menu
96
+ function add_menus() {
97
+ add_submenu_page('options-general.php', __('Languages', 'polylang'), __('Languages', 'polylang'), 'manage_options', 'mlang', array($this, 'languages_page'));
98
  }
99
 
100
  // setup js scripts
101
  function admin_js() {
102
+ wp_enqueue_script('polylang_admin', WP_PLUGIN_URL .'/polylang/js/admin.js');
103
+ }
104
+
105
+ // setup css styles
106
+ function admin_css() {
107
+ wp_enqueue_style('polylang_admin', WP_PLUGIN_URL .'/polylang/css/admin.css');
108
  }
109
 
110
  // the languages panel
120
  $menus = wp_get_nav_menus();
121
  $menu_lang = get_option('polylang_nav_menus');
122
 
123
+ $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
 
 
124
 
125
  switch ($action) {
126
  case 'add':
127
  check_admin_referer( 'add-lang', '_wpnonce_add-lang' );
128
+ $error = $this->validate_lang();
129
 
130
+ if ($error == 0) {
 
 
131
  wp_insert_term($_POST['name'],'language',array('slug'=>$_POST['slug'], 'description'=>$_POST['description']));
132
  $wp_rewrite->flush_rules(); // refresh rewrite rules
133
 
136
  update_option('polylang', $options);
137
  }
138
  }
139
+
140
+ wp_redirect('admin.php?page=mlang'. ($error ? '&error='.$error : '') ); // to refresh the page (possible thanks to the $_GET['noheader']=true)
141
  exit;
142
  break;
143
 
153
  $args = array('numberposts'=>-1, 'taxonomy' => 'language', 'term' => $lang_slug, 'post_type'=>'any', 'post_status'=>'any');
154
  $posts = get_posts($args);
155
  foreach ($posts as $post) {
156
+ foreach ($listlanguages as $language) {
157
  delete_post_meta($post->ID, '_lang-'.$language->slug);
158
  }
159
  }
160
+
161
  // delete references to this language in all posts
162
  $args = array('numberposts'=>-1, 'meta_key'=>'_lang-'.$lang_slug, 'post_type'=>'any', 'post_status'=>'any');
163
  $posts = get_posts($args);
166
  }
167
 
168
  // delete references to this language in categories & post tags
169
+ $terms = get_terms(get_taxonomies(array('show_ui'=>true)), 'get=all');
170
  foreach ($terms as $term) {
171
  if ($this->get_term_language($term->term_id) == $lang) {
172
+ foreach ($listlanguages as $language) {
173
  delete_metadata('term', $term->term_id, '_lang-'.$language->slug); // deletes translations of this term
174
  }
175
  delete_metadata('term', $term->term_id, '_language', $lang_id); // delete language of this term
182
  $wp_rewrite->flush_rules(); // refresh rewrite rules
183
 
184
  // oops ! we deleted the default language...
185
+ if ($options['default_lang'] == $lang_slug) {
186
+ if (!empty($listlanguages))
187
+ $options['default_lang'] = reset($this->get_languages_list())->slug; // arbitrary choice...
188
  else
189
  unset($options['default_lang']);
190
  update_option('polylang', $options);
191
+ }
192
  }
193
  wp_redirect('admin.php?page=mlang'); // to refresh the page (possible thanks to the $_GET['noheader']=true)
194
  exit;
196
 
197
  case 'edit':
198
  if (isset($_GET['lang']) && $_GET['lang'])
199
+ $edit_lang = $this->get_language((int) $_GET['lang']);
200
  break;
201
 
202
  case 'update':
203
  check_admin_referer( 'add-lang', '_wpnonce_add-lang' );
204
+ $lang_id = (int) $_POST['lang'];
205
+ $lang = $this->get_language($lang_id);
206
+ $error = $this->validate_lang($lang);
207
 
208
+ if ($error == 0) {
 
209
  // Update links to this language in posts and terms in case the slug has been modified
 
 
210
  $old_slug = $lang->slug;
211
 
212
  if ($old_slug != $_POST['slug']) {
220
  }
221
 
222
  // update the language slug in categories & post tags meta
223
+ $terms = get_terms(get_taxonomies(array('show_ui'=>true)), 'get=all');
224
  foreach ($terms as $term) {
225
+ if ($term_id = get_metadata('term', $term->term_id, '_lang-'.$old_slug, true)) {
 
226
  delete_metadata('term', $term->term_id, '_lang-'.$old_slug);
227
  update_metadata('term', $term->term_id, '_lang-'.$_POST['slug'], $term_id);
228
  }
229
+ }
230
  }
231
 
232
+ // and finally update the language itself
233
  wp_update_term($lang_id, 'language', array('name'=>$_POST['name'], 'slug'=>$_POST['slug'], 'description'=>$_POST['description']));
234
  $wp_rewrite->flush_rules(); // refresh rewrite rules
235
  }
236
+
237
+ wp_redirect('admin.php?page=mlang'. ($error ? '&error='.$error : '') ); // to refresh the page (possible thanks to the $_GET['noheader']=true)
238
  exit;
239
  break;
240
 
248
  case 'options':
249
  check_admin_referer( 'options-lang', '_wpnonce_options-lang' );
250
 
 
 
251
  $options['default_lang'] = $_POST['default_lang'];
252
+ $options['browser'] = isset($_POST['browser']) ? 1 : 0;
253
+ $options['rewrite'] = $_POST['rewrite'];
254
+ $options['hide_default'] = isset($_POST['hide_default']) ? 1 : 0;
255
  update_option('polylang', $options);
256
 
257
+ // refresh refresh permalink structure and rewrite rules in case rewrite or hide_default options have been modified
258
+ $wp_rewrite->extra_permastructs['language'][0] = $options['rewrite'] ? '%language%' : '/language/%language%';
259
+ $wp_rewrite->flush_rules();
260
+
261
+ // fills existing posts & terms with default language
262
+ if (isset($_POST['fill_languages'])) {
263
+ if(isset($_POST['posts'])) {
264
+ foreach(explode(',', $_POST['posts']) as $post_id) {
265
+ wp_set_post_terms($post_id, $options['default_lang'], 'language' );
266
+ }
267
+ }
268
+ if(isset($_POST['terms'])) {
269
+ foreach(explode(',', $_POST['terms']) as $term_id) {
270
+ update_metadata('term', $term_id, '_language', $options['default_lang'] );
271
+ }
272
+ }
273
+ }
274
+ break;
275
 
276
  default:
277
  }
278
 
279
  // prepare the list table of languages
280
  $data = array();
281
+ foreach ($listlanguages as $lang)
282
  $data[] = (array) $lang;
283
 
284
  $list_table->prepare_items($data);
285
 
286
+
287
+ // detects posts & pages without language set
288
+ $q = array(
289
+ 'numberposts'=>-1,
290
+ 'post_type' => 'any',
291
+ 'post_status'=>'any',
292
+ 'fields' => 'ids',
293
+ 'tax_query' => array(array(
294
+ 'taxonomy'=> 'language',
295
+ 'terms'=> get_terms('language', array('fields'=>'ids')),
296
+ 'operator'=>'NOT IN'
297
+ ))
298
+ );
299
+ $posts = implode(',', get_posts($q));
300
+
301
+ // detects categories & post tags without language set
302
+ $terms = get_terms(get_taxonomies(array('show_ui'=>true)), array('get'=>'all', 'fields'=>'ids'));
303
+ foreach ($terms as $key => $term_id) {
304
+ if (get_metadata('term', $term_id, '_language'))
305
+ unset($terms[$key]);
306
+ }
307
+ $terms = implode(',', $terms);
308
+
309
+ $errors[1] = __('Enter a valid WorPress locale', 'polylang');
310
+ $errors[2] = __('The language code must be 2 characters long', 'polylang');
311
+ $errors[3] = __('The language code must be unique', 'polylang');
312
+ $errors[4] = __('The language must have a name', 'polylang');
313
+
314
+ // displays the page
315
+ include(INC_DIR.'/languages-form.php');
316
+ }
317
+
318
+ // validates data entered when creating or updating a language
319
+ function validate_lang($lang = null) {
320
+ // validate locale
321
+ $loc = $_POST['description'];
322
+ if ( !preg_match('#^[a-z]{2}$#', $loc) && !preg_match('#^[a-z]{2}_[A-Z]{2}$#', $loc) )
323
+ $error = 1;
324
+
325
+ // validate slug length
326
+ if (strlen($_POST['slug']) != 2)
327
+ $error = 2;
328
+
329
+ // validate slug is unique
330
+ if ($this->get_language($_POST['slug']) != null && isset($lang) && $lang->slug != $_POST['slug'])
331
+ $error = 3;
332
+
333
+ // validate name
334
+ if ($_POST['name'] == '')
335
+ $error = 4;
336
+
337
+ return isset($error) ? $error : 0;
338
  }
339
 
340
  // adds the language column (before the date column) in the posts and pages list table
341
  function add_post_column($columns, $post_type ='') {
342
+ if ($post_type == '' || get_post_type_object($post_type)->show_ui) {
343
+ foreach (array( 'date', 'comments' ) as $k) {
 
344
  if (array_key_exists($k, $columns))
345
  $end[$k] = array_pop($columns);
346
  }
355
 
356
  // fills the language column in the posts table
357
  function post_column($column, $post_id) {
358
+ if ($column == 'language' && $lang = $this->get_post_language($post_id))
 
359
  echo esc_attr($lang->name);
360
  }
361
 
364
  function parse_query($query) {
365
  global $pagenow;
366
  $qvars = &$query->query_vars;
367
+ if ($pagenow=='edit.php' && isset($qvars['lang']) && $qvars['lang'] && is_numeric($qvars['lang']) && $lang = $this->get_language($qvars['lang']))
368
+ $qvars['lang'] = $lang->slug;
 
 
 
369
  }
370
 
371
  // adds a filter for languages in the Posts and Pages panels
372
  function restrict_manage_posts() {
373
  global $wp_query;
374
+ $screen = get_current_screen(); // since WP 3.1
375
  $languages = $this->get_languages_list();
376
 
377
  if (!empty($languages) && $screen->base == 'edit') {
378
  $qvars = $wp_query->query;
379
  wp_dropdown_categories(array(
380
  'show_option_all' => __('Show all languages', 'polylang'),
381
+ 'name' => 'lang',
382
  'selected' => isset($qvars['lang']) ? $qvars['lang'] : 0,
383
+ 'taxonomy' => 'language',
384
+ 'hide_empty' => 0
385
+ ));
386
  }
387
  }
388
 
389
+ // adds the Languages box in the 'Edit Post' and 'Edit Page' panels (as well as in custom post types panels
390
  function add_meta_boxes() {
391
+ foreach(get_post_types( array( 'show_ui' => true ) ) as $ptype)
392
+ add_meta_box('ml_box', __('Languages','polylang'), array(&$this,'post_language'), $ptype, 'side','high');
393
  }
394
 
395
+ // the Languages metabox in the 'Edit Post' and 'Edit Page' panels
396
  function post_language() {
397
  global $post_ID;
398
  $post_type = get_post_type($post_ID);
402
  $lang = $this->get_language($_GET['new_lang']);
403
 
404
  $listlanguages = $this->get_languages_list();
405
+
406
+ include(INC_DIR.'/post-metabox.php');
407
  }
408
 
409
  // ajax response for post metabox
415
  $post_type = get_post_type($post_ID);
416
 
417
  if ($lang && !is_wp_error($lang))
418
+ include(INC_DIR.'/post-translations.php');
419
 
420
  die();
421
  }
423
  // called when a post (or page) is saved, published or updated
424
  // the underscore in '_lang' hides the post meta in the Custom Fields metabox in the Edit Post screen
425
  function save_post($post_id) {
426
+ if ($id = wp_is_post_revision($post_id))
 
 
427
  $post_id = $id;
428
 
429
  if (isset($_POST['post_lang_choice']))
430
  wp_set_post_terms($post_id, $_POST['post_lang_choice'], 'language' );
431
 
432
+ $lang = $this->get_post_language($post_id);
433
  $listlanguages = $this->get_languages_list();
434
 
435
  foreach ($listlanguages as $language) {
436
 
437
  if (isset($_POST[$language->slug]) && $_POST[$language->slug]) {
438
  // FIXME I don't check that the translated post is in the right language !
439
+ update_post_meta($post_id, '_lang-'.$language->slug, $_POST[$language->slug]); // saves the links to translated posts
440
  if ($lang)
441
  update_post_meta($this->get_translated_post($post_id, $language), '_lang-'.$lang->slug, $post_id); // tells the translated to link to this post
442
  }
444
  // deletes the translation in case there was previously one
445
  if ($lang)
446
  delete_post_meta($this->get_translated_post($post_id, $language), '_lang-'.$lang->slug); // in the translated post
447
+
448
  delete_post_meta($post_id, '_lang-'.$language->slug); // in this post
449
  }
450
  }
452
  // propagates translations between them
453
  foreach ($listlanguages as $language) {
454
  foreach ($listlanguages as $lg) {
455
+ if ($lg != $lang && $lg != $language && $id = $this->get_translated_post($post_id, $lg))
 
456
  update_post_meta($this->get_translated_post($post_id, $language), '_lang-'.$lg->slug, $id);
457
  }
458
  }
460
 
461
  // called when a post (or page) is deleted
462
  function delete_post($post_id) {
463
+ if ($id = wp_is_post_revision($post_id))
 
464
  $post_id = $id;
465
 
466
+ if($lang = $this->get_post_language($post_id)) {
467
+ foreach ($this->get_languages_list() as $language) {
 
 
468
  delete_post_meta($this->get_translated_post($post_id, $language), '_lang-'.$lang->slug); // delete links to this post
469
  // WP deletes post metas linked to this post so it is useless to do it before
470
+ }
471
  }
472
  }
473
 
476
  $taxonomy = $_GET['taxonomy'];
477
  $lang = null;
478
  if (isset($_GET['new_lang']))
479
+ $lang = $this->get_language($_GET['new_lang']);
480
 
481
  $listlanguages = $this->get_languages_list();
482
 
483
  // displays the language field
484
+ include(INC_DIR.'/add-term-form.php');
485
  }
486
 
487
  // adds the language field and translations tables in the 'Edit Category' and 'Edit Tag' panels
491
  $taxonomy = $tag->taxonomy;
492
  $listlanguages = $this->get_languages_list();
493
 
494
+ include(INC_DIR.'/edit-term-form.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
495
  }
496
 
497
  // adds the language column (before the posts column) in the 'Categories' or Post Tags table
509
 
510
  // fills the language column in the 'Categories' or Post Tags table
511
  function term_column($empty, $column, $term_id) {
512
+ if ($column == 'language' && $lang = $this->get_term_language($term_id))
 
513
  echo esc_attr($lang->name);
514
  }
515
 
516
+
517
  // called when a category or post tag is created or edited
518
  function save_term($term_id) {
519
 
547
  if (isset($lang)) {
548
  foreach ($listlanguages as $language) {
549
  foreach ($listlanguages as $lg) {
550
+ if ($lg != $lang && $lg != $language && $id = $this->get_translated_term($term_id, $lg))
 
551
  update_metadata('term',$this->get_translated_term($term_id, $language), '_lang-'.$lg->slug, $id);
552
  }
553
  }
557
 
558
  // called when a category or post tag is deleted
559
  function delete_term($term_id) {
560
+ if($lang = $this->get_term_language($term_id)) {
561
+ delete_metadata('term', $term_id, '_language' );
 
562
  $listlanguages = $this->get_languages_list();
563
  foreach ($listlanguages as $language) {
564
  delete_metadata('term', $this->get_translated_term($term_id, $language), '_lang-'.$lang->slug); // delete links to this term
565
+ }
566
  foreach ($listlanguages as $language) {
567
  delete_metadata('term', $term_id, '_lang-'.$language->slug);
568
+ }
569
  }
570
  }
571
 
572
  // returns all terms in the $taxonomy in the $term_language which have no translation in the $translation_language
573
  function get_terms_not_translated($taxonomy, $term_language, $translation_language) {
574
  $new_terms = array();
575
+ foreach (get_terms($taxonomy, 'hide_empty=0') as $term) {
 
576
  $lang = $this->get_term_language($term->term_id);
577
+ if ($lang && $lang->name == $term_language->name && !$this->get_translated_term($term->term_id, $translation_language))
578
+ $new_terms[] = $term;
 
 
 
579
  }
580
  return $new_terms;
581
  }
582
 
583
+ // ajax response for edit term form
584
+ function term_lang_choice()
585
+ {
586
+ if ($_POST['lang']) {
587
+ $lang = $this->get_language($_POST['lang']);
588
+ $term_id = isset($_POST['term_id']) ? $_POST['term_id'] : null;
589
+ $taxonomy = $_POST['taxonomy'];
590
+
591
+ $listlanguages = $this->get_languages_list();
592
+
593
+ include(INC_DIR.'/term-translations.php');
594
+ }
595
+ die();
596
+ }
597
+
598
  // modifies the theme location nav menu metabox
599
  function nav_menu_theme_locations() {
600
+ // only if the theme supports nav menus and a nav menu exists
601
+ if ( ! current_theme_supports( 'menus' ) || !isset($_REQUEST['menu']) )
602
  return;
603
 
604
+ // thanks to: http://wordpress.stackexchange.com/questions/2770/how-to-add-a-custom-metabox-to-the-menu-management-admin-screen
605
  $metabox = &$GLOBALS['wp_meta_boxes']['nav-menus']['side']['default']['nav-menu-theme-locations'];
606
  $metabox['callback'] = array(&$this,'nav_menu_language');
607
  $metabox['title'] = __('Theme locations and languages', 'polylang');
616
  // modifies the widgets forms to add our language dropdwown list
617
  function in_widget_form($widget) {
618
  $id = esc_attr($widget->id.'_lang_choice');
 
619
  $widget_lang = get_option('polylang_widgets');
620
 
621
  printf(
622
+ '<p><label for="%s">%s<select name="%s" id="%s" class="tags-input"><option value="0">%s</option>',
623
  $id,
624
  __('The widget is displayed for:', 'polylang'),
625
  $id,
626
  $id,
627
  __('All languages', 'polylang')
628
  );
629
+ foreach ($this->get_languages_list() as $language) {
630
  printf(
631
  "<option value='%s'%s>%s</option>\n",
632
  esc_attr($language->slug),
633
+ isset($widget_lang[$widget->id]) && $language->slug == $widget_lang[$widget->id] ? ' selected="selected"' : '',
634
  esc_attr($language->name)
635
  );
636
  }
639
 
640
  // called when widget options are saved
641
  function widget_update_callback($instance, $new_instance, $old_instance, $widget) {
642
+ $widget_lang = get_option('polylang_widgets');
643
+ $widget_lang[$widget->id] = $_POST[$widget->id.'_lang_choice'];
644
+ update_option('polylang_widgets', $widget_lang);
 
 
 
645
  return $instance;
646
  }
647
 
648
+ // returns the locale based on user preference
649
+ function get_locale($locale) {
650
+ return get_user_meta(get_current_user_id(), 'user_lang', 'true');
651
+ }
652
+
653
+ // updates language user preference
654
+ function personal_options_update($user_id) {
655
+ update_user_meta($user_id, 'user_lang', $_POST['user_lang']);
656
+ }
657
+
658
+ // form for language user preference
659
+ function personal_options($profileuser) {
660
+ include(INC_DIR.'/personal-options.php');
661
+ }
662
+
663
  // refresh rewrite rules if the 'page_on_front' option is modified
664
  function update_option($option) {
665
  global $wp_rewrite;
666
  if ($option == 'page_on_front')
667
+ $wp_rewrite->flush_rules();
668
  }
669
  } // class Polylang_Admin
670
 
base.php → include/base.php RENAMED
@@ -52,9 +52,9 @@ class Polylang_Base {
52
  return $this->get_language(get_metadata('term', $term_id, '_language', true));
53
  }
54
 
55
- // returns the id of the translation of a term (category or post_tag)
56
  function get_translated_term($term_id, $language) {
57
- return get_metadata('term', $term_id, '_lang-'.$language->slug, true);
58
  }
59
 
60
  } //class Polylang_Base
52
  return $this->get_language(get_metadata('term', $term_id, '_language', true));
53
  }
54
 
55
+ // returns the id of the translation of a term (category, post tag or custom taxonomy)
56
  function get_translated_term($term_id, $language) {
57
+ return get_metadata('term', $term_id, '_lang-'.$language->slug, true); // since WP 2.9
58
  }
59
 
60
  } //class Polylang_Base
include/calendar.php ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // obliged to rewrite the whole WordPress function as there is no filter on sql queries and only a filter on final output
4
+ // not very efficient -> add 4 to 5 sql queries
5
+ global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
6
+
7
+ $lang = $this->curlang->term_id;
8
+ $initial = true; // no other way than hardcoded this -> no impact on calendar widget output
9
+ $key = md5( $lang . $m . $monthnum . $year );
10
+
11
+ if ( ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) && is_array($cache) && isset( $cache[ $key ] ) )
12
+ return $cache[$key];
13
+
14
+ if ( isset($_GET['w']) )
15
+ $w = ''.intval($_GET['w']);
16
+
17
+ // week_begins = 0 stands for Sunday
18
+ $week_begins = intval(get_option('start_of_week'));
19
+
20
+ // Let's figure out when we are
21
+ if ( !empty($monthnum) && !empty($year) ) {
22
+ $thismonth = ''.zeroise(intval($monthnum), 2);
23
+ $thisyear = ''.intval($year);
24
+ } elseif ( !empty($w) ) {
25
+ // We need to get the month from MySQL
26
+ $thisyear = ''.intval(substr($m, 0, 4));
27
+ $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
28
+ $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
29
+ } elseif ( !empty($m) ) {
30
+ $thisyear = ''.intval(substr($m, 0, 4));
31
+ if ( strlen($m) < 6 )
32
+ $thismonth = '01';
33
+ else
34
+ $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
35
+ } else {
36
+ $thisyear = gmdate('Y', current_time('timestamp'));
37
+ $thismonth = gmdate('m', current_time('timestamp'));
38
+ }
39
+
40
+ $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
41
+ $last_day = date('t', $unixmonth);
42
+
43
+ // Get the next and previous month and year with at least one post
44
+ $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
45
+ FROM $wpdb->posts
46
+ INNER JOIN $wpdb->term_relationships AS tr ON tr.object_id = ID
47
+ INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
48
+ WHERE post_date < '$thisyear-$thismonth-01'
49
+ AND post_type = 'post' AND post_status = 'publish' AND tt.term_id = $lang
50
+ ORDER BY post_date DESC
51
+ LIMIT 1");
52
+ $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
53
+ FROM $wpdb->posts
54
+ INNER JOIN $wpdb->term_relationships AS tr ON tr.object_id = ID
55
+ INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
56
+ WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
57
+ AND post_type = 'post' AND post_status = 'publish' AND tt.term_id = $lang
58
+ ORDER BY post_date ASC
59
+ LIMIT 1");
60
+
61
+ /* translators: Calendar caption: 1: month name, 2: 4-digit year */
62
+ $calendar_caption = _x('%1$s %2$s', 'calendar caption');
63
+ $calendar_output = '<table id="wp-calendar">
64
+ <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
65
+ <thead>
66
+ <tr>';
67
+
68
+ $myweek = array();
69
+
70
+ for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
71
+ $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
72
+ }
73
+
74
+ foreach ( $myweek as $wd ) {
75
+ $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
76
+ $wd = esc_attr($wd);
77
+ $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
78
+ }
79
+
80
+ $calendar_output .= '
81
+ </tr>
82
+ </thead>
83
+
84
+ <tfoot>
85
+ <tr>';
86
+
87
+ if ( $previous ) {
88
+ $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
89
+ } else {
90
+ $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
91
+ }
92
+
93
+ $calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
94
+
95
+ if ( $next ) {
96
+ $calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>';
97
+ } else {
98
+ $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
99
+ }
100
+
101
+ $calendar_output .= '
102
+ </tr>
103
+ </tfoot>
104
+
105
+ <tbody>
106
+ <tr>';
107
+
108
+ // Get days with posts
109
+ $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
110
+ FROM $wpdb->posts
111
+ INNER JOIN $wpdb->term_relationships AS tr ON tr.object_id = ID
112
+ INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
113
+ WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
114
+ AND post_type = 'post' AND post_status = 'publish' AND tt.term_id = $lang
115
+ AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
116
+ if ( $dayswithposts ) {
117
+ foreach ( (array) $dayswithposts as $daywith ) {
118
+ $daywithpost[] = $daywith[0];
119
+ }
120
+ } else {
121
+ $daywithpost = array();
122
+ }
123
+
124
+ if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
125
+ $ak_title_separator = "\n";
126
+ else
127
+ $ak_title_separator = ', ';
128
+
129
+ $ak_titles_for_day = array();
130
+ $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
131
+ ."FROM $wpdb->posts "
132
+ ."INNER JOIN $wpdb->term_relationships AS tr ON tr.object_id = ID "
133
+ ."INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id "
134
+ ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
135
+ ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
136
+ ."AND post_type = 'post' AND post_status = 'publish' AND tt.term_id = $lang"
137
+ );
138
+ if ( $ak_post_titles ) {
139
+ foreach ( (array) $ak_post_titles as $ak_post_title ) {
140
+
141
+ $post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
142
+
143
+ if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
144
+ $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
145
+ if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
146
+ $ak_titles_for_day["$ak_post_title->dom"] = $post_title;
147
+ else
148
+ $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
149
+ }
150
+ }
151
+
152
+ // See how much we should pad in the beginning
153
+ $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
154
+ if ( 0 != $pad )
155
+ $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad">&nbsp;</td>';
156
+
157
+ $daysinmonth = intval(date('t', $unixmonth));
158
+ for ( $day = 1; $day <= $daysinmonth; ++$day ) {
159
+ if ( isset($newrow) && $newrow )
160
+ $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
161
+ $newrow = false;
162
+
163
+ if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
164
+ $calendar_output .= '<td id="today">';
165
+ else
166
+ $calendar_output .= '<td>';
167
+
168
+ if ( in_array($day, $daywithpost) ) // any posts today?
169
+ $calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
170
+ else
171
+ $calendar_output .= $day;
172
+ $calendar_output .= '</td>';
173
+
174
+ if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
175
+ $newrow = true;
176
+ }
177
+
178
+ $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
179
+ if ( $pad != 0 && $pad != 7 )
180
+ $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'">&nbsp;</td>';
181
+
182
+ $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
183
+
184
+ $cache[ $key ] = $calendar_output;
185
+ wp_cache_set( 'get_calendar', $cache, 'calendar' );
186
+
187
+ ?>
edit-term-form.php → include/edit-term-form.php RENAMED
@@ -21,5 +21,5 @@
21
  <tr id="term-translations" class="form-field"><?php
22
  // do not display translation fields if term language is not set
23
  if ($lang)
24
- include(POLYLANG_DIR.'/term-translations.php');?>
25
  </tr>
21
  <tr id="term-translations" class="form-field"><?php
22
  // do not display translation fields if term language is not set
23
  if ($lang)
24
+ include(INC_DIR.'/term-translations.php');?>
25
  </tr>
languages-form.php → include/languages-form.php RENAMED
@@ -11,7 +11,11 @@
11
  ?>
12
  <div class="wrap">
13
  <?php screen_icon('options-general'); ?>
14
- <h2><?php _e('Languages','polylang') ?></h2>
 
 
 
 
15
 
16
  <div id="col-container">
17
  <div id="col-right">
@@ -50,13 +54,13 @@ else { ?>
50
 
51
  <div class="form-field form-required">
52
  <label for="description"><?php _e('Locale', 'polylang');?></label>
53
- <input name="description" id="description" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->description);?>" size="40" aria-required="true" />
54
  <p><?php _e('Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language.', 'polylang');?></p>
55
  </div>
56
 
57
  <div class="form-field">
58
  <label for="slug"><?php _e('Language code', 'polylang');?></label>
59
- <input name="slug" id="slug" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->slug);?>" size="40" />
60
  <p><?php _e('2-letters ISO 639-1 language code (for example: en)', 'polylang');?></p>
61
  </div>
62
 
@@ -125,8 +129,7 @@ if (current_theme_supports( 'menus' )) { ?>
125
 
126
  } // if (current_theme_supports( 'menus' ))
127
 
128
- // displays the Polylang options form
129
- //FIXME one inline CSS ?>
130
  <div class="form-wrap">
131
  <h3><?php _e('Options','polylang');?></h3>
132
 
@@ -137,38 +140,9 @@ if (current_theme_supports( 'menus' )) { ?>
137
  <table class="form-table">
138
 
139
  <tr>
140
- <th style="width: 300px;"><label><?php
141
- printf(
142
- '<input name="rewrite" type="radio" value="0" %s /> %s',
143
- $options['rewrite'] ? '' : 'checked="checked"',
144
- __('Keep /language/ in pretty permalinks', 'polylang')
145
- );?>
146
- </label></th>
147
- <td><code><?php echo home_url('language/en/'); ?></code></td>
148
- </tr>
149
-
150
- <tr>
151
- <th><label><?php
152
- printf(
153
- '<input name="rewrite" type="radio" value="1" %s /> %s',
154
- $options['rewrite'] ? 'checked="checked"' : '',
155
- __('Remove /language/ in pretty permalinks', 'polylang')
156
- );?>
157
- </label></th>
158
- <td><code><?php echo home_url('en/'); ?></code></td>
159
- </tr>
160
-
161
- <tr>
162
- <th><?php _e('The front page default language is : ', 'polylang');?></th>
163
- <td><label><?php
164
- printf(
165
- '<input name="browser" type="checkbox" value="1" %s /> %s',
166
- $options['browser'] ? 'checked="checked"' :'',
167
- __('set by the browser preference', 'polylang')
168
- );?>
169
- </label>
170
- <label><?php _e('otherwise: ', 'polylang');?><select name="default_lang" id="default_lang">
171
- <?php $listlanguages = $this->get_languages_list();
172
  foreach ($listlanguages as $language) {
173
  printf(
174
  "<option value='%s'%s>%s</option>\n",
@@ -177,7 +151,70 @@ if (current_theme_supports( 'menus' )) { ?>
177
  esc_attr($language->name)
178
  );
179
  } ?>
180
- </select></label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  </td>
182
  </tr>
183
 
11
  ?>
12
  <div class="wrap">
13
  <?php screen_icon('options-general'); ?>
14
+ <h2><?php _e('Languages','polylang') ?></h2><?php
15
+
16
+ if (isset($_GET['error'])) {?>
17
+ <div id="message" class="error fade"><p><?php echo $errors[$_GET['error']]; ?></p></div><?php
18
+ }?>
19
 
20
  <div id="col-container">
21
  <div id="col-right">
54
 
55
  <div class="form-field form-required">
56
  <label for="description"><?php _e('Locale', 'polylang');?></label>
57
+ <input name="description" id="description" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->description);?>" size="5" maxlength="5" aria-required="true" />
58
  <p><?php _e('Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language.', 'polylang');?></p>
59
  </div>
60
 
61
  <div class="form-field">
62
  <label for="slug"><?php _e('Language code', 'polylang');?></label>
63
+ <input name="slug" id="slug" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->slug);?>" size="2" maxlength="2"/>
64
  <p><?php _e('2-letters ISO 639-1 language code (for example: en)', 'polylang');?></p>
65
  </div>
66
 
129
 
130
  } // if (current_theme_supports( 'menus' ))
131
 
132
+ // displays the Polylang options form ?>
 
133
  <div class="form-wrap">
134
  <h3><?php _e('Options','polylang');?></h3>
135
 
140
  <table class="form-table">
141
 
142
  <tr>
143
+ <th><label for='default_lang'><?php _e('Default language', 'polylang');?></label></th>
144
+ <td>
145
+ <select name="default_lang" id="default_lang"><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  foreach ($listlanguages as $language) {
147
  printf(
148
  "<option value='%s'%s>%s</option>\n",
151
  esc_attr($language->name)
152
  );
153
  } ?>
154
+ </select>
155
+ </td>
156
+ </tr><?php
157
+
158
+ // posts or terms without language set
159
+ if (!empty($posts) || !empty($terms) && $options['default_lang']) {
160
+
161
+ if (!empty($posts))
162
+ echo '<input type="hidden" name="posts" value="'.esc_attr($posts).'" />';
163
+ if (!empty($terms))
164
+ echo '<input type="hidden" name="terms" value="'.esc_attr($terms).'" />';?>
165
+
166
+ <tr>
167
+ <th></th>
168
+ <td>
169
+ <label style="color: red"><?php
170
+ printf(
171
+ '<input name="fill_languages" type="checkbox" value="1" /> %s',
172
+ __('There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?', 'polylang')
173
+ );?>
174
+ </label>
175
+ </td>
176
+ </tr><?php
177
+ }?>
178
+
179
+ <tr>
180
+ <th><?php _e('Detect browser language', 'polylang');?></th>
181
+ <td>
182
+ <label><?php
183
+ printf(
184
+ '<input name="browser" type="checkbox" value="1" %s /> %s',
185
+ $options['browser'] ? 'checked="checked"' :'',
186
+ __('When the front page is visited, set the language according to the browser preference', 'polylang')
187
+ );?>
188
+ </label>
189
+ </td>
190
+ </tr>
191
+
192
+ <tr>
193
+ <th><?php _e('URL modifications', 'Polylang') ?></th>
194
+ <td scope="row">
195
+ <label><?php
196
+ printf(
197
+ '<input name="rewrite" type="radio" value="0" %s /> %s',
198
+ $options['rewrite'] ? '' : 'checked="checked"',
199
+ __('Keep /language/ in pretty permalinks. Example: ', 'polylang')
200
+ );?>
201
+ <code><?php echo home_url('language/en/'); ?></code>
202
+ </label>
203
+ <label><?php
204
+ printf(
205
+ '<input name="rewrite" type="radio" value="1" %s /> %s',
206
+ $options['rewrite'] ? 'checked="checked"' : '',
207
+ __('Remove /language/ in pretty permalinks. Example: ', 'polylang')
208
+ );?>
209
+ <code><?php echo home_url('en/'); ?></code>
210
+ </label>
211
+ <label><?php
212
+ printf(
213
+ '<input name="hide_default" type="checkbox" value="1" %s /> %s',
214
+ $options['hide_default'] ? 'checked="checked"' :'',
215
+ __('Hide URL language information for default language', 'polylang')
216
+ );?>
217
+ </label>
218
  </td>
219
  </tr>
220
 
list-table.php → include/list-table.php RENAMED
File without changes
include/personal-options.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php // allows each user to choose the admin language ?>
2
+ <tr>
3
+ <th><label for='user_lang'><?php _e('Language', 'polylang');?></label></th>
4
+ <td>
5
+ <select name="user_lang" id="user_lang">
6
+ <option value="0"></option><?php
7
+ $listlanguages = $this->get_languages_list();
8
+ foreach ($listlanguages as $language) {
9
+ printf(
10
+ "<option value='%s'%s>%s</option>\n",
11
+ esc_attr($language->description),
12
+ get_user_meta($profileuser->ID, 'user_lang', true) == $language->description ? ' selected="selected"' : '',
13
+ esc_attr($language->name)
14
+ );
15
+ } ?>
16
+ </select>
17
+ </td>
18
+ </tr>
post-metabox.php → include/post-metabox.php RENAMED
@@ -2,7 +2,7 @@
2
  // NOTE: the class "tags-input" allows to include the field in the autosave $_POST (see autosave.js)?>
3
  <p><em><?php $post_type == 'page' ? _e('Page\'s language:', 'polylang') : _e('Post\'s language:', 'polylang');?></em></p>
4
  <p>
5
- <select name="post_lang_choice" id="post_lang_choice" class="tags-input">
6
  <option value="0"></option> <?php
7
  foreach ($listlanguages as $language) {
8
  printf(
@@ -17,6 +17,6 @@
17
  <div id="post-translations">
18
  <?php // allowing to determine the linked posts
19
  if (isset($lang))
20
- include(POLYLANG_DIR.'/post-translations.php');
21
  ?>
22
  </div>
2
  // NOTE: the class "tags-input" allows to include the field in the autosave $_POST (see autosave.js)?>
3
  <p><em><?php $post_type == 'page' ? _e('Page\'s language:', 'polylang') : _e('Post\'s language:', 'polylang');?></em></p>
4
  <p>
5
+ <select name="post_lang_choice" id="post_lang_choice">
6
  <option value="0"></option> <?php
7
  foreach ($listlanguages as $language) {
8
  printf(
17
  <div id="post-translations">
18
  <?php // allowing to determine the linked posts
19
  if (isset($lang))
20
+ include(INC_DIR.'/post-translations.php');
21
  ?>
22
  </div>
post-translations.php → include/post-translations.php RENAMED
@@ -1,6 +1,5 @@
1
- <?php // FIXME inline CSS ! ?>
2
  <p><em><?php $post_type == 'page' ? _e('ID of pages in other languages:', 'polylang') : _e('ID of posts in other languages:', 'polylang');?></em></p>
3
- <table style="width: 100%; text-align: left; font-size: 11px; margin: 0 6px;">
4
  <thead><tr>
5
  <th><?php _e('Language', 'polylang');?></th>
6
  <th><?php $post_type == 'page' ? _e('Page ID', 'polylang') : _e('Post ID', 'polylang');?></th>
@@ -14,7 +13,7 @@
14
  if (isset($_GET['from_post']))
15
  $value = $this->get_post($_GET['from_post'], $language); ?>
16
  <tr>
17
- <td style="font-size: 11px;"><?php echo esc_attr($language->name);?></td><?php
18
  printf(
19
  '<td><input name="%s" id="%s" class="tags-input" type="text" value="%s" size="6"/></td>',
20
  esc_attr($language->slug),
@@ -33,7 +32,7 @@
33
  esc_url(admin_url('post-new.php?post_type=' . $post_type . '&amp;from_post=' . $post_ID . '&amp;new_lang=' . $language->slug)),
34
  __('Add new','polylang')
35
  );?>
36
- <td style="font-size: 11px;"><?php echo $link ?><td><?php
37
  }?>
38
  </tr><?php
39
  }
 
1
  <p><em><?php $post_type == 'page' ? _e('ID of pages in other languages:', 'polylang') : _e('ID of posts in other languages:', 'polylang');?></em></p>
2
+ <table>
3
  <thead><tr>
4
  <th><?php _e('Language', 'polylang');?></th>
5
  <th><?php $post_type == 'page' ? _e('Page ID', 'polylang') : _e('Post ID', 'polylang');?></th>
13
  if (isset($_GET['from_post']))
14
  $value = $this->get_post($_GET['from_post'], $language); ?>
15
  <tr>
16
+ <td><?php echo esc_attr($language->name);?></td><?php
17
  printf(
18
  '<td><input name="%s" id="%s" class="tags-input" type="text" value="%s" size="6"/></td>',
19
  esc_attr($language->slug),
32
  esc_url(admin_url('post-new.php?post_type=' . $post_type . '&amp;from_post=' . $post_ID . '&amp;new_lang=' . $language->slug)),
33
  __('Add new','polylang')
34
  );?>
35
+ <td><?php echo $link ?><td><?php
36
  }?>
37
  </tr><?php
38
  }
term-translations.php → include/term-translations.php RENAMED
@@ -1,6 +1,5 @@
1
  <?php
2
  // displays the translations fields
3
- // FIXME inline CSS
4
 
5
  if (isset($term_id)) { // edit term form?>
6
  <th scope="row" valign="top"><?php _e('Translations', 'polylang');?></th>
@@ -10,11 +9,10 @@ else { // add term form?>
10
  <label><?php _e('Translations', 'polylang');?></label><?php
11
  }
12
  ?>
13
- <table style="width: 100%">
14
  <thead><tr><?php
15
- $style = 'style="padding: 0px; font-weight: bold; text-align: left"';
16
  foreach (array(__('Language', 'polylang'), __('Translation', 'polylang'), __('Edit', 'polylang')) as $title)
17
- printf('<th %s>%s</th>', $style, $title);?>
18
  </tr></thead>
19
  <tbody>
20
  <?php foreach ($listlanguages as $language) {
@@ -31,14 +29,14 @@ else { // add term form?>
31
  $translation = get_term($translation_id, $taxonomy);
32
  }?>
33
 
34
- <tr><td style="padding: 0px"><?php echo esc_attr($language->name);?></td><?php
35
 
36
  // no translation exits in this language
37
  if (!$translation) {
38
  $translations = $this->get_terms_not_translated($taxonomy, $language, $lang);
39
  if (!empty($translations)) { ?>
40
- <td style="padding: 0px">
41
- <select name="_lang-<?php echo esc_attr($language->slug);?>" id="_lang-<?php echo esc_attr($language->slug);?>" style="width: 15em">
42
  <option value="0"></option><?php
43
  foreach ($translations as $translation) { ?>
44
  <option value="<?php echo esc_attr($translation->term_id);?>"><?php echo esc_attr($translation->name);?></option><?php
@@ -47,10 +45,10 @@ else { // add term form?>
47
  </td><?php
48
  }
49
  else { ?>
50
- <td style="padding: 0px">
51
  </td><?php
52
  } ?>
53
- <td style="padding: 0px"><?php
54
  // do not display the add new link in add term form ($term_id not set !!!)
55
  if (isset($term_id)) {
56
  $link = esc_url(admin_url(sprintf(
@@ -67,8 +65,8 @@ else { // add term form?>
67
 
68
  // a translation exists
69
  else { ?>
70
- <td style="padding: 0px"><?php echo esc_attr($translation->name); ?></td>
71
- <td style="padding: 0px"><?php
72
  $link = esc_url(admin_url(sprintf(
73
  'edit-tags.php?action=edit&amp;taxonomy=%s&amp;tag_ID=%s',
74
  $taxonomy,
1
  <?php
2
  // displays the translations fields
 
3
 
4
  if (isset($term_id)) { // edit term form?>
5
  <th scope="row" valign="top"><?php _e('Translations', 'polylang');?></th>
9
  <label><?php _e('Translations', 'polylang');?></label><?php
10
  }
11
  ?>
12
+ <table>
13
  <thead><tr><?php
 
14
  foreach (array(__('Language', 'polylang'), __('Translation', 'polylang'), __('Edit', 'polylang')) as $title)
15
+ printf('<th>%s</th>', $title);?>
16
  </tr></thead>
17
  <tbody>
18
  <?php foreach ($listlanguages as $language) {
29
  $translation = get_term($translation_id, $taxonomy);
30
  }?>
31
 
32
+ <tr><td><?php echo esc_attr($language->name);?></td><?php
33
 
34
  // no translation exits in this language
35
  if (!$translation) {
36
  $translations = $this->get_terms_not_translated($taxonomy, $language, $lang);
37
  if (!empty($translations)) { ?>
38
+ <td>
39
+ <select name="_lang-<?php echo esc_attr($language->slug);?>" id="_lang-<?php echo esc_attr($language->slug);?>">
40
  <option value="0"></option><?php
41
  foreach ($translations as $translation) { ?>
42
  <option value="<?php echo esc_attr($translation->term_id);?>"><?php echo esc_attr($translation->name);?></option><?php
45
  </td><?php
46
  }
47
  else { ?>
48
+ <td>
49
  </td><?php
50
  } ?>
51
+ <td><?php
52
  // do not display the add new link in add term form ($term_id not set !!!)
53
  if (isset($term_id)) {
54
  $link = esc_url(admin_url(sprintf(
65
 
66
  // a translation exists
67
  else { ?>
68
+ <td><?php echo esc_attr($translation->name); ?></td>
69
+ <td><?php
70
  $link = esc_url(admin_url(sprintf(
71
  'edit-tags.php?action=edit&amp;taxonomy=%s&amp;tag_ID=%s',
72
  $taxonomy,
include/widget.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Polylang_Widget extends WP_Widget {
4
+ function __construct() {
5
+ $widget_ops = array( 'description' => __( 'Displays a language switcher', 'polylang') );
6
+ parent::__construct('polylang', __('Language Switcher', 'polylang'), $widget_ops);
7
+ }
8
+
9
+ // displays the widget
10
+ function widget($args, $instance) {
11
+ extract($args);
12
+ extract($instance);
13
+
14
+ echo "$before_widget\n";
15
+ do_action('the_languages', $instance);
16
+ echo "$after_widget\n";
17
+
18
+ // javascript to switch the language when using a dropdown list
19
+ // keep the things simple for now as we switch to the posts page
20
+ if ($dropdown) {
21
+ $url = home_url('?lang=');
22
+ $js = "
23
+ <script type='text/javascript'>
24
+ var d = document.getElementById('lang_choice');
25
+ d.onchange = function() {location.href ='$url'+this.value;}
26
+ </script>";
27
+
28
+ echo $js;
29
+ }
30
+ }
31
+
32
+ // updates the widget options
33
+ function update( $new_instance, $old_instance ) {
34
+ $instance = $old_instance;
35
+ $instance['show_names'] = !empty($new_instance['show_names']) ? 1 : 0;
36
+ $instance['show_flags'] = !empty($new_instance['show_flags']) ? 1 : 0;
37
+ $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
38
+
39
+ return $instance;
40
+ }
41
+
42
+ // displays the widget form
43
+ function form($instance) {
44
+ $instance = wp_parse_args( (array) $instance, array( 'show_names' => 1, 'show_flags' => 0, 'dropdown' => 0) ); // default values
45
+
46
+ // language names checkbox
47
+ $id = $this->get_field_id('show_names');
48
+ $name = $this->get_field_name('show_names');
49
+ $output = sprintf('<input type="checkbox" class="checkbox" id="%s" name="%s"%s /> <label for="%s">%s</label><br />',
50
+ $id, $name, $instance['show_names'] ? 'checked="checked"' : '', $id, __('Display language names', 'polylang'));
51
+
52
+ // flags checkbox
53
+ $id = $this->get_field_id('show_flags');
54
+ $name = $this->get_field_name('show_flags');
55
+ $output .= sprintf('<input type="checkbox" class="checkbox" id="%s" name="%s"%s /> <label for="%s">%s</label><br />',
56
+ $id, $name, $instance['show_flags'] ? 'checked="checked"' : '', $id, __('Display flags', 'polylang'));
57
+
58
+ // dropdown checkbox
59
+ $id = $this->get_field_id('dropdown');
60
+ $name = $this->get_field_name('dropdown');
61
+ $output .= sprintf('<input type="checkbox" class="checkbox" id="%s" name="%s"%s /> <label for="%s">%s</label><br />',
62
+ $id, $name, $instance['dropdown'] ? 'checked="checked"' : '', $id, __('Display as dropdown', 'polylang'));
63
+
64
+ echo '<p>'.$output.'</p>';
65
+ }
66
+
67
+ } // Class Polylang_Widget
68
+
69
+ ?>
admin.js → js/admin.js RENAMED
@@ -10,7 +10,7 @@ jQuery(document).ready(function($) {
10
 
11
  jQuery.post(ajaxurl, data , function(response) {
12
  jQuery("#post-translations").html(response);
13
- });
14
  })
15
 
16
  // ajax for term edit
@@ -24,7 +24,7 @@ jQuery(document).ready(function($) {
24
 
25
  jQuery.post(ajaxurl, data, function(response) {
26
  jQuery("#term-translations").html(response);
27
- });
28
  })
29
 
30
  });
10
 
11
  jQuery.post(ajaxurl, data , function(response) {
12
  jQuery("#post-translations").html(response);
13
+ });
14
  })
15
 
16
  // ajax for term edit
24
 
25
  jQuery.post(ajaxurl, data, function(response) {
26
  jQuery("#term-translations").html(response);
27
+ });
28
  })
29
 
30
  });
languages/polylang-de_DE.mo ADDED
Binary file
languages/polylang-de_DE.po ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: polylang\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-11-07 21:37+0100\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: F. Demarle\n"
8
+ "Language-Team: \n"
9
+ "Language: \n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "Plural-Forms: nplurals=2: nplural=n>1\n"
14
+ "X-Poedit-SourceCharset: utf-8\n"
15
+ "X-Poedit-KeywordsList: _e;__;_c\n"
16
+ "X-Poedit-Basepath: .\n"
17
+ "X-Poedit-SearchPath-0: ..\n"
18
+ "X-Poedit-SearchPath-1: ../include\n"
19
+
20
+ #: ../include/edit-term-form.php:6
21
+ #: ../include/admin.php:342
22
+ #: ../include/admin.php:496
23
+ #: ../include/term-translations.php:16
24
+ #: ../include/add-term-form.php:3
25
+ #: ../include/list-table.php:12
26
+ #: ../include/post-translations.php:5
27
+ #: ../include/personal-options.php:3
28
+ msgid "Language"
29
+ msgstr "Sprache"
30
+
31
+ #: ../include/edit-term-form.php:18
32
+ #: ../include/add-term-form.php:10
33
+ msgid "Sets the language"
34
+ msgstr "definiert die Sprache"
35
+
36
+ #: ../include/widget.php:5
37
+ msgid "Displays a language switcher"
38
+ msgstr "Zeigen die Sprachenliste"
39
+
40
+ #: ../include/widget.php:6
41
+ msgid "Language Switcher"
42
+ msgstr "Sprachenliste"
43
+
44
+ #: ../include/widget.php:44
45
+ msgid "Display language names"
46
+ msgstr "Zeigen die Sprachen Namen"
47
+
48
+ #: ../include/widget.php:49
49
+ msgid "Display flags"
50
+ msgstr "Zeigen Flaggen"
51
+
52
+ #: ../include/widget.php:54
53
+ msgid "Display as dropdown"
54
+ msgstr "Als Auswahlbox darstellen"
55
+
56
+ #: ../include/admin.php:89
57
+ msgid "Settings"
58
+ msgstr "Einstellungen"
59
+
60
+ #: ../include/admin.php:96
61
+ #: ../include/admin.php:386
62
+ #: ../include/list-table.php:13
63
+ #: ../include/languages-form.php:14
64
+ msgid "Languages"
65
+ msgstr "Sprachen"
66
+
67
+ #: ../include/admin.php:303
68
+ #, fuzzy
69
+ msgid "Enter a valid WorPress locale"
70
+ msgstr "Das WordPress Locale ist ungültig"
71
+
72
+ #: ../include/admin.php:304
73
+ msgid "The language code must be 2 characters long"
74
+ msgstr "Der Sprachcode muss 2 Buchstaben lang sein"
75
+
76
+ #: ../include/admin.php:305
77
+ msgid "The language code must be unique"
78
+ msgstr "Eine andere Sprache hat dem selben Sprachcode"
79
+
80
+ #: ../include/admin.php:306
81
+ msgid "The language must have a name"
82
+ msgstr "Die Sprache muss einen Namen haben"
83
+
84
+ #: ../include/admin.php:374
85
+ msgid "Show all languages"
86
+ msgstr "Zeigen alle Sprachen"
87
+
88
+ #: ../include/admin.php:601
89
+ msgid "Theme locations and languages"
90
+ msgstr "Anordnung im Theme und Sprachen"
91
+
92
+ #: ../include/admin.php:606
93
+ #, php-format
94
+ msgid "Please go to the %slanguages page%s to set theme locations and languages"
95
+ msgstr "Du solltest zu der %sSprachen Seite%s gehen, um Anordnung im Theme und Sprachen zu definieren."
96
+
97
+ #: ../include/admin.php:618
98
+ msgid "The widget is displayed for:"
99
+ msgstr "Zeigen das Widget für :"
100
+
101
+ #: ../include/admin.php:621
102
+ msgid "All languages"
103
+ msgstr "Alle Sprachen"
104
+
105
+ #: ../include/post-metabox.php:3
106
+ msgid "Page's language:"
107
+ msgstr "Sprache für die Seite :"
108
+
109
+ #: ../include/post-metabox.php:3
110
+ msgid "Post's language:"
111
+ msgstr "Sprache für die Artikel :"
112
+
113
+ #: ../include/term-translations.php:6
114
+ #: ../include/term-translations.php:10
115
+ msgid "Translations"
116
+ msgstr "Übersetzungen"
117
+
118
+ #: ../include/term-translations.php:16
119
+ msgid "Translation"
120
+ msgstr "Übersetzung"
121
+
122
+ #: ../include/term-translations.php:16
123
+ #: ../include/term-translations.php:77
124
+ #: ../include/list-table.php:32
125
+ #: ../include/post-translations.php:7
126
+ #: ../include/post-translations.php:29
127
+ msgid "Edit"
128
+ msgstr "Bearbeiten"
129
+
130
+ #: ../include/term-translations.php:63
131
+ #: ../include/post-translations.php:34
132
+ msgid "Add new"
133
+ msgstr "Hinzufügen"
134
+
135
+ #: ../include/list-table.php:33
136
+ msgid "Delete"
137
+ msgstr "Löschen"
138
+
139
+ #: ../include/list-table.php:50
140
+ #: ../include/languages-form.php:50
141
+ msgid "Full name"
142
+ msgstr "Name"
143
+
144
+ #: ../include/list-table.php:51
145
+ #: ../include/languages-form.php:56
146
+ #, fuzzy
147
+ msgid "Locale"
148
+ msgstr "Locale"
149
+
150
+ #: ../include/list-table.php:52
151
+ msgid "Code"
152
+ msgstr "Code"
153
+
154
+ #: ../include/list-table.php:53
155
+ msgid "Posts"
156
+ msgstr "Artikel"
157
+
158
+ #: ../include/languages-form.php:33
159
+ msgid "Edit language"
160
+ msgstr "Sprache bearbeiten"
161
+
162
+ #: ../include/languages-form.php:33
163
+ #: ../include/languages-form.php:70
164
+ msgid "Add new language"
165
+ msgstr "Neue Sprache hinzufügen"
166
+
167
+ #: ../include/languages-form.php:52
168
+ msgid "The name is how it is displayed on your site (for example: English)."
169
+ msgstr "Dieser Name wird dann auf der Website angezeigt (beispielweise : Deutsch)"
170
+
171
+ #: ../include/languages-form.php:58
172
+ msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
173
+ msgstr "Wordpress Locale für die Sprache (beispielweise : de_DE). Du musst die .mo Datei für diese Sprache installieren."
174
+
175
+ #: ../include/languages-form.php:62
176
+ msgid "Language code"
177
+ msgstr "Sprachcode"
178
+
179
+ #: ../include/languages-form.php:64
180
+ msgid "2-letters ISO 639-1 language code (for example: en)"
181
+ msgstr "2 Buchstaben ISO 639-1 Sprachcode (beispielweise : de)"
182
+
183
+ #: ../include/languages-form.php:68
184
+ msgid "Update"
185
+ msgstr "Aktualisieren"
186
+
187
+ #: ../include/languages-form.php:82
188
+ msgid "Menus"
189
+ msgstr "Menüs"
190
+
191
+ #: ../include/languages-form.php:90
192
+ msgid "Theme location"
193
+ msgstr "Anordnung im Theme"
194
+
195
+ #: ../include/languages-form.php:134
196
+ msgid "Options"
197
+ msgstr "Einstellungen"
198
+
199
+ #: ../include/languages-form.php:143
200
+ msgid "Default language"
201
+ msgstr "Standard Sprache"
202
+
203
+ #: ../include/languages-form.php:172
204
+ #, fuzzy
205
+ msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
206
+ msgstr "Es gibt Artikel, Seite, Kategorien oder Schlagwörter ohne Sprache definiert. Willst du alle zu standard Sprache definieren ?"
207
+
208
+ #: ../include/languages-form.php:180
209
+ msgid "Detect browser language"
210
+ msgstr "Browser Spracherkennung"
211
+
212
+ #: ../include/languages-form.php:186
213
+ msgid "When the front page is visited, set the language according to the browser preference"
214
+ msgstr "Wenn die Startseite besucht ist, definiert die Sprache durch den Browser Einstellung"
215
+
216
+ #: ../include/languages-form.php:193
217
+ msgid "URL modifications"
218
+ msgstr "URL Veränderung"
219
+
220
+ #: ../include/languages-form.php:199
221
+ msgid "Keep /language/ in pretty permalinks. Example: "
222
+ msgstr "/language/ in Permalinks behalten. Zum Beispiel :"
223
+
224
+ #: ../include/languages-form.php:207
225
+ msgid "Remove /language/ in pretty permalinks. Example: "
226
+ msgstr "/language/ in Permalinks entfernen. Zum Beispiel :"
227
+
228
+ #: ../include/languages-form.php:215
229
+ msgid "Hide URL language information for default language"
230
+ msgstr "URL Informationen für die Standardsprache verstecken"
231
+
232
+ #: ../include/post-translations.php:2
233
+ msgid "ID of pages in other languages:"
234
+ msgstr "ID für die Seiten in andere Sprache :"
235
+
236
+ #: ../include/post-translations.php:2
237
+ msgid "ID of posts in other languages:"
238
+ msgstr "ID für die Artikel in andere Sprache :"
239
+
240
+ #: ../include/post-translations.php:6
241
+ msgid "Page ID"
242
+ msgstr "ID für die Seite"
243
+
244
+ #: ../include/post-translations.php:6
245
+ msgid "Post ID"
246
+ msgstr "ID für die Artikel"
247
+
248
+ #, fuzzy
249
+ #~ msgid "The front page default language is : "
250
+ #~ msgstr "Die Sprache für die Startseite ist :"
251
+ #~ msgid "set by the browser preference"
252
+ #~ msgstr "durch den Browser Einstellung definiert"
253
+ #~ msgid "otherwise: "
254
+ #~ msgstr "sonst :"
255
+ #~ msgid "Title:"
256
+ #~ msgstr "Titre :"
257
+
languages/polylang-fr_FR.mo ADDED
Binary file
languages/polylang-fr_FR.po ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: polylang\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-11-07 21:34+0100\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: F. Demarle\n"
8
+ "Language-Team: \n"
9
+ "Language: \n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "Plural-Forms: nplurals=2: nplural=n>1\n"
14
+ "X-Poedit-SourceCharset: utf-8\n"
15
+ "X-Poedit-KeywordsList: _e;__;_c\n"
16
+ "X-Poedit-Basepath: .\n"
17
+ "X-Poedit-SearchPath-0: ..\n"
18
+ "X-Poedit-SearchPath-1: ../include\n"
19
+
20
+ #: ../include/edit-term-form.php:6
21
+ #: ../include/admin.php:342
22
+ #: ../include/admin.php:496
23
+ #: ../include/term-translations.php:16
24
+ #: ../include/add-term-form.php:3
25
+ #: ../include/list-table.php:12
26
+ #: ../include/post-translations.php:5
27
+ #: ../include/personal-options.php:3
28
+ msgid "Language"
29
+ msgstr "Langue"
30
+
31
+ #: ../include/edit-term-form.php:18
32
+ #: ../include/add-term-form.php:10
33
+ msgid "Sets the language"
34
+ msgstr "Définit la langue"
35
+
36
+ #: ../include/widget.php:5
37
+ msgid "Displays a language switcher"
38
+ msgstr "Affiche la liste des langues "
39
+
40
+ #: ../include/widget.php:6
41
+ msgid "Language Switcher"
42
+ msgstr "Liste des langues"
43
+
44
+ #: ../include/widget.php:44
45
+ msgid "Display language names"
46
+ msgstr "Afficher le nom des langues "
47
+
48
+ #: ../include/widget.php:49
49
+ msgid "Display flags"
50
+ msgstr "Afficher les drapeaux"
51
+
52
+ #: ../include/widget.php:54
53
+ msgid "Display as dropdown"
54
+ msgstr "Afficher comme liste déroulante"
55
+
56
+ #: ../include/admin.php:89
57
+ msgid "Settings"
58
+ msgstr "Réglages"
59
+
60
+ #: ../include/admin.php:96
61
+ #: ../include/admin.php:386
62
+ #: ../include/list-table.php:13
63
+ #: ../include/languages-form.php:14
64
+ msgid "Languages"
65
+ msgstr "Langues"
66
+
67
+ #: ../include/admin.php:303
68
+ msgid "Enter a valid WorPress locale"
69
+ msgstr "Entrez un code local WordPress valide"
70
+
71
+ #: ../include/admin.php:304
72
+ msgid "The language code must be 2 characters long"
73
+ msgstr "Le code de la langue doit avoir 2 lettres"
74
+
75
+ #: ../include/admin.php:305
76
+ msgid "The language code must be unique"
77
+ msgstr "Le code de la langue doit être unique"
78
+
79
+ #: ../include/admin.php:306
80
+ msgid "The language must have a name"
81
+ msgstr "La langue doit avoir un nom"
82
+
83
+ #: ../include/admin.php:374
84
+ msgid "Show all languages"
85
+ msgstr "Afficher toutes les langues"
86
+
87
+ #: ../include/admin.php:601
88
+ msgid "Theme locations and languages"
89
+ msgstr "Emplacements du thème et langues"
90
+
91
+ #: ../include/admin.php:606
92
+ #, php-format
93
+ msgid "Please go to the %slanguages page%s to set theme locations and languages"
94
+ msgstr "Aller à la %spage langues%s pour définir les emplacements du thème et les langues "
95
+
96
+ #: ../include/admin.php:618
97
+ msgid "The widget is displayed for:"
98
+ msgstr "Afficher le widget pour :"
99
+
100
+ #: ../include/admin.php:621
101
+ msgid "All languages"
102
+ msgstr "Toutes les langues"
103
+
104
+ #: ../include/post-metabox.php:3
105
+ msgid "Page's language:"
106
+ msgstr "Langue de la page"
107
+
108
+ #: ../include/post-metabox.php:3
109
+ msgid "Post's language:"
110
+ msgstr "Langue de l'article"
111
+
112
+ #: ../include/term-translations.php:6
113
+ #: ../include/term-translations.php:10
114
+ msgid "Translations"
115
+ msgstr "Traductions"
116
+
117
+ #: ../include/term-translations.php:16
118
+ msgid "Translation"
119
+ msgstr "Traduction"
120
+
121
+ #: ../include/term-translations.php:16
122
+ #: ../include/term-translations.php:77
123
+ #: ../include/list-table.php:32
124
+ #: ../include/post-translations.php:7
125
+ #: ../include/post-translations.php:29
126
+ msgid "Edit"
127
+ msgstr "Modifier"
128
+
129
+ #: ../include/term-translations.php:63
130
+ #: ../include/post-translations.php:34
131
+ msgid "Add new"
132
+ msgstr "Ajouter"
133
+
134
+ #: ../include/list-table.php:33
135
+ msgid "Delete"
136
+ msgstr "Supprimer"
137
+
138
+ #: ../include/list-table.php:50
139
+ #: ../include/languages-form.php:50
140
+ msgid "Full name"
141
+ msgstr "Nom"
142
+
143
+ #: ../include/list-table.php:51
144
+ #: ../include/languages-form.php:56
145
+ msgid "Locale"
146
+ msgstr "Code local"
147
+
148
+ #: ../include/list-table.php:52
149
+ msgid "Code"
150
+ msgstr "Code"
151
+
152
+ #: ../include/list-table.php:53
153
+ msgid "Posts"
154
+ msgstr "Articles"
155
+
156
+ #: ../include/languages-form.php:33
157
+ msgid "Edit language"
158
+ msgstr "Modifier la langue"
159
+
160
+ #: ../include/languages-form.php:33
161
+ #: ../include/languages-form.php:70
162
+ msgid "Add new language"
163
+ msgstr "Ajouter une nouvelle langue"
164
+
165
+ #: ../include/languages-form.php:52
166
+ msgid "The name is how it is displayed on your site (for example: English)."
167
+ msgstr "Le nom est utilisé un peu partout sur le site (par exemple : Français)"
168
+
169
+ #: ../include/languages-form.php:58
170
+ msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
171
+ msgstr "Code local utilisé par Wordpress pour la langue (par exemple : fr_FR). Vous aurez besoin d'installer les fichiers .mo correspondant"
172
+
173
+ #: ../include/languages-form.php:62
174
+ msgid "Language code"
175
+ msgstr "Code de la langue"
176
+
177
+ #: ../include/languages-form.php:64
178
+ msgid "2-letters ISO 639-1 language code (for example: en)"
179
+ msgstr "Code ISO 639-1 à 2 lettres (par exemple : fr)"
180
+
181
+ #: ../include/languages-form.php:68
182
+ msgid "Update"
183
+ msgstr "Mettre à jour"
184
+
185
+ #: ../include/languages-form.php:82
186
+ msgid "Menus"
187
+ msgstr "Menus"
188
+
189
+ #: ../include/languages-form.php:90
190
+ msgid "Theme location"
191
+ msgstr "Emplacement du thème"
192
+
193
+ #: ../include/languages-form.php:134
194
+ msgid "Options"
195
+ msgstr "Options"
196
+
197
+ #: ../include/languages-form.php:143
198
+ msgid "Default language"
199
+ msgstr "Langue par défaut"
200
+
201
+ #: ../include/languages-form.php:172
202
+ msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
203
+ msgstr "Il y a des articles, pages, catégories ou tags sans langue définie. Voulez-vous leur attribuer la langue par défaut ?"
204
+
205
+ #: ../include/languages-form.php:180
206
+ msgid "Detect browser language"
207
+ msgstr "Détecter la langue du navigateur"
208
+
209
+ #: ../include/languages-form.php:186
210
+ msgid "When the front page is visited, set the language according to the browser preference"
211
+ msgstr "Lorsque la page d'accueil est visitée pour la première fois, le visiteur est redirigé à la bonne URL en fonction des préférences de langue de son navigateur"
212
+
213
+ #: ../include/languages-form.php:193
214
+ msgid "URL modifications"
215
+ msgstr "Modifications des URL"
216
+
217
+ #: ../include/languages-form.php:199
218
+ msgid "Keep /language/ in pretty permalinks. Example: "
219
+ msgstr "Conserve /language/ dans les permaliens. Exemple :"
220
+
221
+ #: ../include/languages-form.php:207
222
+ msgid "Remove /language/ in pretty permalinks. Example: "
223
+ msgstr "Supprime /language/ dans les permaliens. Exemple :"
224
+
225
+ #: ../include/languages-form.php:215
226
+ msgid "Hide URL language information for default language"
227
+ msgstr "Cacher l'information de langue dans l'URL pour la langue par défaut"
228
+
229
+ #: ../include/post-translations.php:2
230
+ msgid "ID of pages in other languages:"
231
+ msgstr "ID des pages dans les autres langues"
232
+
233
+ #: ../include/post-translations.php:2
234
+ msgid "ID of posts in other languages:"
235
+ msgstr "ID des articles dans les autres langues"
236
+
237
+ #: ../include/post-translations.php:6
238
+ msgid "Page ID"
239
+ msgstr "ID de la page"
240
+
241
+ #: ../include/post-translations.php:6
242
+ msgid "Post ID"
243
+ msgstr "ID de l'article"
244
+
245
+ #~ msgid "The front page default language is : "
246
+ #~ msgstr "La langue par défaut de la page d'accueil est :"
247
+ #~ msgid "set by the browser preference"
248
+ #~ msgstr "définie par les préférences du navigateur"
249
+ #~ msgid "otherwise: "
250
+ #~ msgstr "sinon :"
251
+ #~ msgid "Title:"
252
+ #~ msgstr "Titre :"
253
+
languages/polylang.pot ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: polylang\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-11-07 21:46+0100\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: F. Demarle\n"
8
+ "Language-Team: \n"
9
+ "Language: \n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "Plural-Forms: nplurals=2: nplural=n>1\n"
14
+ "X-Poedit-SourceCharset: utf-8\n"
15
+ "X-Poedit-KeywordsList: _e;__;_c\n"
16
+ "X-Poedit-Basepath: .\n"
17
+ "X-Poedit-SearchPath-0: ..\n"
18
+ "X-Poedit-SearchPath-1: ../include\n"
19
+
20
+ #: ../include/edit-term-form.php:6
21
+ #: ../include/admin.php:342
22
+ #: ../include/admin.php:496
23
+ #: ../include/term-translations.php:16
24
+ #: ../include/add-term-form.php:3
25
+ #: ../include/list-table.php:12
26
+ #: ../include/post-translations.php:5
27
+ #: ../include/personal-options.php:3
28
+ msgid "Language"
29
+ msgstr ""
30
+
31
+ #: ../include/edit-term-form.php:18
32
+ #: ../include/add-term-form.php:10
33
+ msgid "Sets the language"
34
+ msgstr ""
35
+
36
+ #: ../include/widget.php:5
37
+ msgid "Displays a language switcher"
38
+ msgstr ""
39
+
40
+ #: ../include/widget.php:6
41
+ msgid "Language Switcher"
42
+ msgstr ""
43
+
44
+ #: ../include/widget.php:44
45
+ msgid "Display language names"
46
+ msgstr ""
47
+
48
+ #: ../include/widget.php:49
49
+ msgid "Display flags"
50
+ msgstr ""
51
+
52
+ #: ../include/widget.php:54
53
+ msgid "Display as dropdown"
54
+ msgstr ""
55
+
56
+ #: ../include/admin.php:89
57
+ msgid "Settings"
58
+ msgstr ""
59
+
60
+ #: ../include/admin.php:96
61
+ #: ../include/admin.php:386
62
+ #: ../include/list-table.php:13
63
+ #: ../include/languages-form.php:14
64
+ msgid "Languages"
65
+ msgstr ""
66
+
67
+ #: ../include/admin.php:303
68
+ msgid "Enter a valid WorPress locale"
69
+ msgstr ""
70
+
71
+ #: ../include/admin.php:304
72
+ msgid "The language code must be 2 characters long"
73
+ msgstr ""
74
+
75
+ #: ../include/admin.php:305
76
+ msgid "The language code must be unique"
77
+ msgstr ""
78
+
79
+ #: ../include/admin.php:306
80
+ msgid "The language must have a name"
81
+ msgstr ""
82
+
83
+ #: ../include/admin.php:374
84
+ msgid "Show all languages"
85
+ msgstr ""
86
+
87
+ #: ../include/admin.php:601
88
+ msgid "Theme locations and languages"
89
+ msgstr ""
90
+
91
+ #: ../include/admin.php:606
92
+ #, php-format
93
+ msgid "Please go to the %slanguages page%s to set theme locations and languages"
94
+ msgstr ""
95
+
96
+ #: ../include/admin.php:618
97
+ msgid "The widget is displayed for:"
98
+ msgstr ""
99
+
100
+ #: ../include/admin.php:621
101
+ msgid "All languages"
102
+ msgstr ""
103
+
104
+ #: ../include/post-metabox.php:3
105
+ msgid "Page's language:"
106
+ msgstr ""
107
+
108
+ #: ../include/post-metabox.php:3
109
+ msgid "Post's language:"
110
+ msgstr ""
111
+
112
+ #: ../include/term-translations.php:6
113
+ #: ../include/term-translations.php:10
114
+ msgid "Translations"
115
+ msgstr ""
116
+
117
+ #: ../include/term-translations.php:16
118
+ msgid "Translation"
119
+ msgstr ""
120
+
121
+ #: ../include/term-translations.php:16
122
+ #: ../include/term-translations.php:77
123
+ #: ../include/list-table.php:32
124
+ #: ../include/post-translations.php:7
125
+ #: ../include/post-translations.php:29
126
+ msgid "Edit"
127
+ msgstr ""
128
+
129
+ #: ../include/term-translations.php:63
130
+ #: ../include/post-translations.php:34
131
+ msgid "Add new"
132
+ msgstr ""
133
+
134
+ #: ../include/list-table.php:33
135
+ msgid "Delete"
136
+ msgstr ""
137
+
138
+ #: ../include/list-table.php:50
139
+ #: ../include/languages-form.php:50
140
+ msgid "Full name"
141
+ msgstr ""
142
+
143
+ #: ../include/list-table.php:51
144
+ #: ../include/languages-form.php:56
145
+ msgid "Locale"
146
+ msgstr ""
147
+
148
+ #: ../include/list-table.php:52
149
+ msgid "Code"
150
+ msgstr ""
151
+
152
+ #: ../include/list-table.php:53
153
+ msgid "Posts"
154
+ msgstr ""
155
+
156
+ #: ../include/languages-form.php:33
157
+ msgid "Edit language"
158
+ msgstr ""
159
+
160
+ #: ../include/languages-form.php:33
161
+ #: ../include/languages-form.php:70
162
+ msgid "Add new language"
163
+ msgstr ""
164
+
165
+ #: ../include/languages-form.php:52
166
+ msgid "The name is how it is displayed on your site (for example: English)."
167
+ msgstr ""
168
+
169
+ #: ../include/languages-form.php:58
170
+ msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
171
+ msgstr ""
172
+
173
+ #: ../include/languages-form.php:62
174
+ msgid "Language code"
175
+ msgstr ""
176
+
177
+ #: ../include/languages-form.php:64
178
+ msgid "2-letters ISO 639-1 language code (for example: en)"
179
+ msgstr ""
180
+
181
+ #: ../include/languages-form.php:68
182
+ msgid "Update"
183
+ msgstr ""
184
+
185
+ #: ../include/languages-form.php:82
186
+ msgid "Menus"
187
+ msgstr ""
188
+
189
+ #: ../include/languages-form.php:90
190
+ msgid "Theme location"
191
+ msgstr ""
192
+
193
+ #: ../include/languages-form.php:134
194
+ msgid "Options"
195
+ msgstr ""
196
+
197
+ #: ../include/languages-form.php:143
198
+ msgid "Default language"
199
+ msgstr ""
200
+
201
+ #: ../include/languages-form.php:172
202
+ msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
203
+ msgstr ""
204
+
205
+ #: ../include/languages-form.php:180
206
+ msgid "Detect browser language"
207
+ msgstr ""
208
+
209
+ #: ../include/languages-form.php:186
210
+ msgid "When the front page is visited, set the language according to the browser preference"
211
+ msgstr ""
212
+
213
+ #: ../include/languages-form.php:193
214
+ msgid "URL modifications"
215
+ msgstr ""
216
+
217
+ #: ../include/languages-form.php:199
218
+ msgid "Keep /language/ in pretty permalinks. Example: "
219
+ msgstr ""
220
+
221
+ #: ../include/languages-form.php:207
222
+ msgid "Remove /language/ in pretty permalinks. Example: "
223
+ msgstr ""
224
+
225
+ #: ../include/languages-form.php:215
226
+ msgid "Hide URL language information for default language"
227
+ msgstr ""
228
+
229
+ #: ../include/post-translations.php:2
230
+ msgid "ID of pages in other languages:"
231
+ msgstr ""
232
+
233
+ #: ../include/post-translations.php:2
234
+ msgid "ID of posts in other languages:"
235
+ msgstr ""
236
+
237
+ #: ../include/post-translations.php:6
238
+ msgid "Page ID"
239
+ msgstr ""
240
+
241
+ #: ../include/post-translations.php:6
242
+ msgid "Post ID"
243
+ msgstr ""
244
+
245
+ #~ msgid "Title:"
246
+ #~ msgstr "Titre :"
247
+
polylang-de_DE.mo DELETED
Binary file
polylang-de_DE.po DELETED
@@ -1,208 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: polylang\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2011-10-19 20:41+0100\n"
6
- "PO-Revision-Date: \n"
7
- "Last-Translator: F. Demarle\n"
8
- "Language-Team: \n"
9
- "Language: \n"
10
- "MIME-Version: 1.0\n"
11
- "Content-Type: text/plain; charset=UTF-8\n"
12
- "Content-Transfer-Encoding: 8bit\n"
13
- "Plural-Forms: nplurals=2: nplural=n>1\n"
14
- "X-Poedit-SourceCharset: utf-8\n"
15
- "X-Poedit-KeywordsList: _e;__;_c\n"
16
- "X-Poedit-Basepath: .\n"
17
- "X-Poedit-SearchPath-0: .\n"
18
-
19
- #: edit-term-form.php:6
20
- #: admin.php:277
21
- #: admin.php:453
22
- #: term-translations.php:16
23
- #: add-term-form.php:3
24
- #: list-table.php:12
25
- #: post-translations.php:5
26
- msgid "Language"
27
- msgstr "Sprache"
28
-
29
- #: edit-term-form.php:18
30
- #: add-term-form.php:10
31
- msgid "Sets the language"
32
- msgstr "definiert die Sprache"
33
-
34
- #: widget.php:5
35
- msgid "Displays a language switcher"
36
- msgstr "Zeige die Sprachenliste"
37
-
38
- #: widget.php:6
39
- msgid "Language Switcher"
40
- msgstr "Sprachenliste"
41
-
42
- #: admin.php:86
43
- msgid "Settings"
44
- msgstr "Einstellungen"
45
-
46
- #: admin.php:93
47
- #: admin.php:322
48
- #: admin.php:323
49
- #: list-table.php:13
50
- #: languages-form.php:14
51
- msgid "Languages"
52
- msgstr "Sprachen"
53
-
54
- #: admin.php:313
55
- msgid "Show all languages"
56
- msgstr "Zeige alle Sprachen"
57
-
58
- #: admin.php:549
59
- msgid "Theme locations and languages"
60
- msgstr "Anordnung im Theme und Sprachen"
61
-
62
- #: admin.php:554
63
- #, php-format
64
- msgid "Please go to the %slanguages page%s to set theme locations and languages"
65
- msgstr "Du solltest zu der %sSprachen Seite%s gehen, um Anordnung im Theme und Sprachen zu definieren."
66
-
67
- #: admin.php:567
68
- msgid "The widget is displayed for:"
69
- msgstr "Zeigen das Widget für :"
70
-
71
- #: admin.php:570
72
- msgid "All languages"
73
- msgstr "Alle Sprachen"
74
-
75
- #: post-metabox.php:3
76
- msgid "Page's language:"
77
- msgstr "Sprache für die Seite :"
78
-
79
- #: post-metabox.php:3
80
- msgid "Post's language:"
81
- msgstr "Sprache für die Artikel :"
82
-
83
- #: term-translations.php:6
84
- #: term-translations.php:10
85
- msgid "Translations"
86
- msgstr "Übersetzungen"
87
-
88
- #: term-translations.php:16
89
- msgid "Translation"
90
- msgstr "Übersetzung"
91
-
92
- #: term-translations.php:16
93
- #: term-translations.php:77
94
- #: list-table.php:32
95
- #: post-translations.php:7
96
- #: post-translations.php:29
97
- msgid "Edit"
98
- msgstr "Bearbeiten"
99
-
100
- #: term-translations.php:63
101
- #: post-translations.php:34
102
- msgid "Add new"
103
- msgstr "Hinzufügen"
104
-
105
- #: list-table.php:33
106
- msgid "Delete"
107
- msgstr "Löschen"
108
-
109
- #: list-table.php:50
110
- #: languages-form.php:46
111
- msgid "Full name"
112
- msgstr "Name"
113
-
114
- #: list-table.php:51
115
- #: languages-form.php:52
116
- #, fuzzy
117
- msgid "Locale"
118
- msgstr "Locale"
119
-
120
- #: list-table.php:52
121
- msgid "Code"
122
- msgstr "Code"
123
-
124
- #: list-table.php:53
125
- msgid "Posts"
126
- msgstr "Artikel"
127
-
128
- #: languages-form.php:29
129
- msgid "Edit language"
130
- msgstr "Sprache bearbeiten"
131
-
132
- #: languages-form.php:29
133
- #: languages-form.php:66
134
- msgid "Add new language"
135
- msgstr "Neue Sprache hinzufügen"
136
-
137
- #: languages-form.php:48
138
- msgid "The name is how it is displayed on your site (for example: English)."
139
- msgstr "Dieser Name wird dann auf der Website angezeigt (beispielweise : Deutsch)"
140
-
141
- #: languages-form.php:54
142
- msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
143
- msgstr "Wordpress Locale für die Sprache (beispielweise : de_DE). Du musst die .mo Datei für diese Sprache installieren."
144
-
145
- #: languages-form.php:58
146
- msgid "Language code"
147
- msgstr "Sprache code"
148
-
149
- #: languages-form.php:60
150
- msgid "2-letters ISO 639-1 language code (for example: en)"
151
- msgstr "2 Buchstaben ISO 639-1 sprache code (beispielweise : de)"
152
-
153
- #: languages-form.php:64
154
- msgid "Update"
155
- msgstr "Aktualisieren"
156
-
157
- #: languages-form.php:78
158
- msgid "Menus"
159
- msgstr "Menüs"
160
-
161
- #: languages-form.php:86
162
- msgid "Theme location"
163
- msgstr "Anordnung im Theme"
164
-
165
- #: languages-form.php:131
166
- msgid "Options"
167
- msgstr "Einstellungen"
168
-
169
- #: languages-form.php:144
170
- msgid "Keep /language/ in pretty permalinks"
171
- msgstr "/language/ in Permalinks behalten"
172
-
173
- #: languages-form.php:155
174
- msgid "Remove /language/ in pretty permalinks"
175
- msgstr "/language/ in Permalinks entfernen"
176
-
177
- #: languages-form.php:162
178
- #, fuzzy
179
- msgid "The front page default language is : "
180
- msgstr "Die Sprache für die Startseite ist :"
181
-
182
- #: languages-form.php:167
183
- msgid "set by the browser preference"
184
- msgstr "durch den Browser Einstellung definiert"
185
-
186
- #: languages-form.php:170
187
- msgid "otherwise: "
188
- msgstr "sonst :"
189
-
190
- #: post-translations.php:2
191
- msgid "ID of pages in other languages:"
192
- msgstr "ID für die Seiten in andere Sprache :"
193
-
194
- #: post-translations.php:2
195
- msgid "ID of posts in other languages:"
196
- msgstr "ID für die Artikel in andere Sprache :"
197
-
198
- #: post-translations.php:6
199
- msgid "Page ID"
200
- msgstr "ID für die Seite"
201
-
202
- #: post-translations.php:6
203
- msgid "Post ID"
204
- msgstr "ID für die Artikel"
205
-
206
- #~ msgid "Title:"
207
- #~ msgstr "Titre :"
208
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
polylang-fr_FR.mo DELETED
Binary file
polylang-fr_FR.po DELETED
@@ -1,207 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: polylang\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2011-10-19 20:40+0100\n"
6
- "PO-Revision-Date: \n"
7
- "Last-Translator: F. Demarle\n"
8
- "Language-Team: \n"
9
- "Language: \n"
10
- "MIME-Version: 1.0\n"
11
- "Content-Type: text/plain; charset=UTF-8\n"
12
- "Content-Transfer-Encoding: 8bit\n"
13
- "Plural-Forms: nplurals=2: nplural=n>1\n"
14
- "X-Poedit-SourceCharset: utf-8\n"
15
- "X-Poedit-KeywordsList: _e;__;_c\n"
16
- "X-Poedit-Basepath: .\n"
17
- "X-Poedit-SearchPath-0: .\n"
18
-
19
- #: edit-term-form.php:6
20
- #: admin.php:277
21
- #: admin.php:453
22
- #: term-translations.php:16
23
- #: add-term-form.php:3
24
- #: list-table.php:12
25
- #: post-translations.php:5
26
- msgid "Language"
27
- msgstr "Langue"
28
-
29
- #: edit-term-form.php:18
30
- #: add-term-form.php:10
31
- msgid "Sets the language"
32
- msgstr "Définit la langue"
33
-
34
- #: widget.php:5
35
- msgid "Displays a language switcher"
36
- msgstr "Affiche la liste des langues "
37
-
38
- #: widget.php:6
39
- msgid "Language Switcher"
40
- msgstr "Liste des langues"
41
-
42
- #: admin.php:86
43
- msgid "Settings"
44
- msgstr "Réglages"
45
-
46
- #: admin.php:93
47
- #: admin.php:322
48
- #: admin.php:323
49
- #: list-table.php:13
50
- #: languages-form.php:14
51
- msgid "Languages"
52
- msgstr "Langues"
53
-
54
- #: admin.php:313
55
- msgid "Show all languages"
56
- msgstr "Afficher toutes les langues"
57
-
58
- #: admin.php:549
59
- msgid "Theme locations and languages"
60
- msgstr "Emplacements du thème et langues"
61
-
62
- #: admin.php:554
63
- #, php-format
64
- msgid "Please go to the %slanguages page%s to set theme locations and languages"
65
- msgstr "Aller à la %spage langues%s pour définir les emplacements du thème et les langues "
66
-
67
- #: admin.php:567
68
- msgid "The widget is displayed for:"
69
- msgstr "Afficher le widget pour :"
70
-
71
- #: admin.php:570
72
- msgid "All languages"
73
- msgstr "Toutes les langues"
74
-
75
- #: post-metabox.php:3
76
- msgid "Page's language:"
77
- msgstr "Langue de la page"
78
-
79
- #: post-metabox.php:3
80
- msgid "Post's language:"
81
- msgstr "Langue de l'article"
82
-
83
- #: term-translations.php:6
84
- #: term-translations.php:10
85
- msgid "Translations"
86
- msgstr "Traductions"
87
-
88
- #: term-translations.php:16
89
- msgid "Translation"
90
- msgstr "Traduction"
91
-
92
- #: term-translations.php:16
93
- #: term-translations.php:77
94
- #: list-table.php:32
95
- #: post-translations.php:7
96
- #: post-translations.php:29
97
- msgid "Edit"
98
- msgstr "Modifier"
99
-
100
- #: term-translations.php:63
101
- #: post-translations.php:34
102
- msgid "Add new"
103
- msgstr "Ajouter"
104
-
105
- #: list-table.php:33
106
- msgid "Delete"
107
- msgstr "Supprimer"
108
-
109
- #: list-table.php:50
110
- #: languages-form.php:46
111
- msgid "Full name"
112
- msgstr "Nom"
113
-
114
- #: list-table.php:51
115
- #: languages-form.php:52
116
- #, fuzzy
117
- msgid "Locale"
118
- msgstr "Locale"
119
-
120
- #: list-table.php:52
121
- msgid "Code"
122
- msgstr "Code"
123
-
124
- #: list-table.php:53
125
- msgid "Posts"
126
- msgstr "Articles"
127
-
128
- #: languages-form.php:29
129
- msgid "Edit language"
130
- msgstr "Modifier la langue"
131
-
132
- #: languages-form.php:29
133
- #: languages-form.php:66
134
- msgid "Add new language"
135
- msgstr "Ajouter une nouvelle langue"
136
-
137
- #: languages-form.php:48
138
- msgid "The name is how it is displayed on your site (for example: English)."
139
- msgstr "Le nom est utilisé un peu partout sur le site (par exemple : Français)"
140
-
141
- #: languages-form.php:54
142
- msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
143
- msgstr "Code Wordpress pour la langue (par exemple : fr_FR). Vous aurez besoin d'installer les fichiers .mo correspondant"
144
-
145
- #: languages-form.php:58
146
- msgid "Language code"
147
- msgstr "Code de la langue"
148
-
149
- #: languages-form.php:60
150
- msgid "2-letters ISO 639-1 language code (for example: en)"
151
- msgstr "Code ISO 639-1 à 2 lettres (par exemple : fr)"
152
-
153
- #: languages-form.php:64
154
- msgid "Update"
155
- msgstr "Mettre à jour"
156
-
157
- #: languages-form.php:78
158
- msgid "Menus"
159
- msgstr "Menus"
160
-
161
- #: languages-form.php:86
162
- msgid "Theme location"
163
- msgstr "Emplacement du thème"
164
-
165
- #: languages-form.php:131
166
- msgid "Options"
167
- msgstr "Options"
168
-
169
- #: languages-form.php:144
170
- msgid "Keep /language/ in pretty permalinks"
171
- msgstr "Conserve /language/ dans les permaliens"
172
-
173
- #: languages-form.php:155
174
- msgid "Remove /language/ in pretty permalinks"
175
- msgstr "Supprime /language/ dans les permaliens"
176
-
177
- #: languages-form.php:162
178
- msgid "The front page default language is : "
179
- msgstr "La langue par défaut de la page d'accueil est :"
180
-
181
- #: languages-form.php:167
182
- msgid "set by the browser preference"
183
- msgstr "définie par les préférences du navigateur"
184
-
185
- #: languages-form.php:170
186
- msgid "otherwise: "
187
- msgstr "sinon :"
188
-
189
- #: post-translations.php:2
190
- msgid "ID of pages in other languages:"
191
- msgstr "ID des pages dans les autres langues"
192
-
193
- #: post-translations.php:2
194
- msgid "ID of posts in other languages:"
195
- msgstr "ID des articles dans les autres langues"
196
-
197
- #: post-translations.php:6
198
- msgid "Page ID"
199
- msgstr "ID de la page"
200
-
201
- #: post-translations.php:6
202
- msgid "Post ID"
203
- msgstr "ID de l'article"
204
-
205
- #~ msgid "Title:"
206
- #~ msgstr "Titre :"
207
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
polylang.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://wordpress.org/extend/plugins/polylang/
5
- Version: 0.3.2
6
  Author: F. Demarle
7
  Description: Adds multilingual capability to Wordpress
8
  */
@@ -23,20 +23,22 @@ Description: Adds multilingual capability to Wordpress
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  */
25
 
26
- define('POLYLANG_VERSION', '0.3');
 
27
  define('POLYLANG_DIR', dirname(__FILE__));
28
- require_once(POLYLANG_DIR.'/base.php');
29
- require_once(POLYLANG_DIR.'/admin.php');
30
- require_once(POLYLANG_DIR.'/widget.php');
 
 
31
 
32
  class Polylang extends Polylang_Base {
33
- var $curlang;
34
  var $default_locale;
35
- var $list_textdomains = array();
36
- var $search_form_filter = false;
37
 
38
  function __construct() {
39
-
40
  // manages plugin activation and deactivation
41
  register_activation_hook( __FILE__, array(&$this, 'activate') );
42
  register_deactivation_hook( __FILE__, array(&$this, 'deactivate') );
@@ -75,8 +77,8 @@ class Polylang extends Polylang_Base {
75
  // adds the language information in the search form
76
  add_filter('get_search_form', array(&$this, 'get_search_form'));
77
 
78
- // filters the pages according to the current language
79
- add_filter('get_pages', array(&$this, 'get_pages'), 10, 2);
80
 
81
  // filters the comments according to the current language
82
  add_filter('comments_clauses', array(&$this, 'comments_clauses'), 10, 2);
@@ -87,10 +89,15 @@ class Polylang extends Polylang_Base {
87
  // rewrites archives links to filter them by language
88
  add_filter('getarchives_join', array(&$this, 'posts_join'));
89
  add_filter('getarchives_where', array(&$this, 'posts_where'));
90
- add_filter('get_archives_link', array(&$this, 'get_archives_link'));
91
 
92
- // rewrites author links to filter them by language
93
- add_filter('author_link', array(&$this, 'author_link'));
 
 
 
 
 
 
94
 
95
  // rewrites next and previous post links to filter them by language
96
  add_filter('get_previous_post_join', array(&$this, 'posts_join'));
@@ -104,6 +111,9 @@ class Polylang extends Polylang_Base {
104
  // filters the widgets according to the current language
105
  add_filter('widget_display_callback', array(&$this, 'widget_display_callback'), 10, 3);
106
 
 
 
 
107
  // allows a new value for the 'show' parameter to display the homepage url according to the current language
108
  add_filter('bloginfo_url', array(&$this, 'bloginfo_url'), 10, 2);
109
 
@@ -138,15 +148,16 @@ class Polylang extends Polylang_Base {
138
  ) $charset_collate;");
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', array('post', 'page'), 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');
145
  if (!$options) {
146
  $options['browser'] = 1; // default language for the front page is set by browser preference
147
  $options['rewrite'] = 0; // do not remove /language/ in permalinks
 
148
  }
149
- $options['version'] = POLYLANG_VERSION; // do not manage versions yet but prepare for it
150
  update_option('polylang', $options);
151
 
152
  // add our rewrite rules
@@ -169,21 +180,21 @@ class Polylang extends Polylang_Base {
169
 
170
  // registers the language taxonomy
171
  // codex: use the init action to call this function
172
- register_taxonomy('language', 'post', array(
173
  'label' => false,
 
174
  'query_var'=>'lang',
175
  'update_count_callback' => '_update_post_term_count'));
176
 
177
  // optionaly removes 'language' in permalinks so that we get http://www.myblog/en/ instead of http://www.myblog/language/en/
178
- // the simple line of code is inspired by the WP No Category Base plugin : http://wordpresssupplies.com/wordpress-plugins/no-category-base/
 
179
  $options = get_option('polylang');
180
- if ($options['rewrite']) {
181
- global $wp_rewrite;
182
  $wp_rewrite->extra_permastructs['language'][0] = '%language%';
183
- }
184
 
185
  $this->default_locale = get_locale(); // save the default locale before we start any language manipulation
186
- load_plugin_textdomain('polylang', false, dirname(plugin_basename( __FILE__ ))); // plugin i18n
187
  }
188
 
189
  // registers our widget
@@ -200,10 +211,12 @@ class Polylang extends Polylang_Base {
200
  // modifies the rules created by WordPress when '/language/' is removed in permalinks
201
  if ($options['rewrite']) {
202
  foreach ($listlanguages as $language) {
203
- $newrules[$language->slug.'/feed/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?lang='.$language->slug.'&feed=$matches[1]';
204
- $newrules[$language->slug.'/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?lang='.$language->slug.'&feed=$matches[1]';
205
- $newrules[$language->slug.'/page/?([0-9]{1,})/?$'] = 'index.php?lang='.$language->slug.'&paged=$matches[1]';
206
- $newrules[$language->slug.'/?$'] = 'index.php?lang='.$language->slug;
 
 
207
  }
208
  unset($rules['([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$']); // => index.php?lang=$matches[1]&feed=$matches[2]
209
  unset($rules['([^/]+)/(feed|rdf|rss|rss2|atom)/?$']); // => index.php?lang=$matches[1]&feed=$matches[2]
@@ -211,47 +224,50 @@ class Polylang extends Polylang_Base {
211
  unset($rules['([^/]+)/?$']); // => index.php?lang=$matches[1]
212
  }
213
 
214
- $options['rewrite'] ? $base = '' : $base = 'language/';
215
 
216
  // rewrite rules for comments feed filtered by language
217
  foreach ($listlanguages as $language) {
218
- $newrules[$base.$language->slug.'/comments/feed/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?lang='.$language->slug.'&feed=$matches[1]&withcomments=1';
219
- $newrules[$base.$language->slug.'/comments/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?lang='.$language->slug.'&feed=$matches[1]&withcomments=1';
 
220
  }
221
  unset($rules['comments/feed/(feed|rdf|rss|rss2|atom)/?$']); // => index.php?&feed=$matches[1]&withcomments=1
222
  unset($rules['comments/(feed|rdf|rss|rss2|atom)/?$']); // => index.php?&feed=$matches[1]&withcomments=1
223
 
224
  // rewrite rules for archives filtered by language
225
  foreach ($rules as $key => $rule) {
226
- $is_archive = strpos($rule, 'year=') && !(
227
  strpos($rule, 'p=') ||
228
  strpos($rule, 'name=') ||
229
  strpos($rule, 'page=') ||
230
  strpos($rule, 'cpage=') );
231
 
232
  if ($is_archive) {
233
- foreach ($listlanguages as $language)
234
- $newrules[$base.$language->slug.'/'.$key] = str_replace('?', '?lang='.$language->slug.'&', $rule);
235
-
 
236
  unset($rules[$key]); // now useless
237
  }
238
  }
239
-
240
  return $newrules + $rules;
241
  }
242
 
243
  // filters categories and post tags by language when needed (both in admin panels and frontend)
244
  function terms_clauses($clauses, $taxonomies, $args) {
245
- // does nothing except on categories and post tags
246
- if ( !in_array('category', $taxonomies) && !in_array('post_tag', $taxonomies) )
247
- return $clauses;
 
 
248
 
249
  if (is_admin()) {
250
- $screen = get_current_screen(); //FIXME breaks a user's admin -> use pagenow instead ? Or simply test the function.
251
 
252
  // NOTE: $screen is not defined in the tag cloud of the Edit Post panel ($pagenow set to admin-ajax.php)
253
  if (isset($screen))
254
- // does nothing in the Categories, Post tags, Languages an Posts* admin panels
255
  if ($screen->base == 'edit-tags' || $screen->base == 'toplevel_page_mlang' || $screen->base == 'edit')
256
  return $clauses;
257
 
@@ -330,31 +346,30 @@ class Polylang extends Polylang_Base {
330
  if (isset($post_ID))
331
  $lang = $this->get_post_language($post_ID);
332
 
333
- // trick to get the post number in the Post Tags metabox in the Edit Post screen (as $post_ID not defined)
334
- $qvars = $this->get_referer_vars();
335
- if (isset($qvars['post']))
336
- $lang = $this->get_post_language($qvars['post']);
337
- }
338
- else {
339
- $var = get_query_var('lang');
340
- if ($var)
341
- $lang = $this->get_language($var);
342
- else {
343
- $var = get_queried_object_id();
344
- if ($var && is_single() || is_page())
345
- $lang = $this->get_post_language($var);
346
- else {
347
- $var = get_query_var('cat');
348
- if ($var)
349
- $lang = $this->get_term_language($var);
350
- else {
351
- $var = get_query_var('tag_id');
352
- if ($var)
353
- $lang = $this->get_term_language($var);
354
- }
355
- }
356
  }
 
 
 
 
357
  }
 
 
 
 
 
 
 
 
 
 
 
358
 
359
  return (isset($lang)) ? $lang : NULL;
360
  }
@@ -367,14 +382,14 @@ class Polylang extends Polylang_Base {
367
  }
368
 
369
  // saves all text domains in a table for later usage
370
- function mofile( $bool, $domain, $mofile) {
371
  $this->list_textdomains[] = array ('mo' => $mofile, 'domain' => $domain);
372
  return true; // prevents WP loading text domains as we will load them all later
373
  }
374
 
375
  // NOTE: I believe there are two ways for a plugin to force the WP language
376
- // as done by xili_language and here : load text domains and reinitialize wp_locale with the action 'wp'
377
- // as done by qtranslate : define the locale with the action 'plugins_loaded', but in this case, the language must be specified in the url.
378
  function load_textdomains() {
379
  // sets the current language and set a cookie to remember it
380
  if ($this->curlang = $this->get_current_language())
@@ -394,30 +409,45 @@ class Polylang extends Polylang_Base {
394
 
395
  // filters posts according to the language
396
  function pre_get_posts($query) {
 
 
 
 
 
 
 
397
 
398
  if (empty($query->query)) {
 
 
 
 
399
 
400
- // sets the language according to browser preference or default language
401
- $this->curlang = $this->get_preferred_language();
402
-
403
- // redirect to the right translated page in case a static page is used as front page
404
- $post_id = get_option('page_on_front');
405
- if (isset($this->curlang) && $post_id) {
406
- // a static page is used as front page
407
-
408
- $language = $this->get_post_language($post_id);
409
- if ($language->slug != $this->curlang->slug) {
410
- // but the one defined in the "Reading Settings" panel is not in the right language, so let's redirect to the right one
411
- $link_id = $this->get_translated_post($post_id, $this->curlang);
412
- if ($link_id) {
413
- $url = _get_page_link($link_id);
414
- wp_redirect($url);
415
- exit;
416
- }
417
- }
418
  }
 
 
 
 
 
 
 
 
 
419
  }
420
- $qvars = $query->query_vars;
 
 
 
 
 
 
 
 
421
 
422
  // filters recent posts to the current language
423
  // FIXME if $qvars['post_type'] == 'nav_menu_item', setting lang breaks custom menus.
@@ -432,14 +462,13 @@ class Polylang extends Polylang_Base {
432
 
433
  // unset the is_archive flag for language pages to prevent loading the archive template
434
  // keep archive flag for comment feed otherwise the language filter does not work
435
- if ( isset($qvars['lang']) && $qvars['lang'] && !is_post_type_archive() && !is_date() && !is_author() && !is_category() && !is_tag() && !is_comment_feed())
436
  $query->is_archive = false;
437
 
438
  // unset the is_tax flag for authors pages
439
  // FIXME Probably I should do this for other cases
440
- if ( isset($qvars['lang']) && $qvars['lang'] && is_author() )
441
  $query->is_tax = false;
442
-
443
  }
444
 
445
  function wp_head() {
@@ -456,14 +485,9 @@ class Polylang extends Polylang_Base {
456
  }
457
 
458
  // outputs references to translated pages (if exists) in the html head section
459
- // FIXME improve this to make only one db query
460
- $listlanguages = $this->get_languages_list();
461
- foreach ($listlanguages as $language) {
462
- if ($language->slug != $this->curlang->slug) {
463
- $url = $this->get_translation_url($language);
464
- if ($url)
465
- printf("<link hreflang='%s' href='%s' rel='alternate' />\n", esc_attr($language->slug), $url);
466
- }
467
  }
468
  }
469
 
@@ -477,24 +501,7 @@ class Polylang extends Polylang_Base {
477
  // adds some javascript workaround knowing it's not perfect...
478
  function wp_print_footer_scripts() {
479
  if ($this->curlang) {
480
- $js = "<script type='text/javascript'>";
481
-
482
- // modifies links to the homepage to filter by the right language
483
- // since filtering home_url breaks things in the core and filtering bloginfo_url is not enough if the template uses home_url()
484
- $url = rtrim(home_url(), '/');
485
-
486
- if ($page = get_option('page_on_front'))
487
- $newurl = _get_page_link($this->get_post($page, $this->curlang));
488
- else
489
- $newurl = get_term_link($this->curlang->slug, 'language');
490
-
491
- $js .= "var e = document.getElementsByTagName('a');
492
- for (var i = 0; i < e.length; i++) {
493
- var href = e[i].href;
494
- if (href == '$url' || href == '$url/') {
495
- e[i].href = '$newurl';
496
- }
497
- }";
498
 
499
  // modifies the search form since filtering get_search_form won't work if the template uses searchform.php
500
  // don't use directly e[0] just in case there is somewhere else an element named 's'
@@ -513,13 +520,13 @@ class Polylang extends Polylang_Base {
513
  }";
514
  }
515
 
516
- $js .= "</script>";
517
- echo $js;
518
  }
519
  }
520
 
521
  // adds the language information in the search form
522
- // FIXME does not work if searchform.php is used
523
  function get_search_form($form) {
524
  if ($form) {
525
  $this->search_form_filter = true;
@@ -528,14 +535,22 @@ class Polylang extends Polylang_Base {
528
  return $form;
529
  }
530
 
531
- // filters the list of pages according to the current language
532
- // it seems that there is currently no way to filter before the database query (3.2)
533
- // cannot play with widget_pages_args filter either as it seems that get_pages does not query taxonomies :(
534
- // so redo the query with get_posts and the 'lang' parameter seems to be be the current best way (rather than trying to manipulate $pages)
535
- function get_pages($pages, $r) {
536
  if (isset($this->curlang)) {
537
- $r['lang'] = $this->curlang->slug;
538
- $pages = get_posts($r);
 
 
 
 
 
 
 
 
 
 
539
  }
540
  return $pages;
541
  }
@@ -553,21 +568,20 @@ class Polylang extends Polylang_Base {
553
  }
554
 
555
  // Modifies the feed link to add the language parameter
556
- // FIXME should be an option to do this ?
557
  function feed_link($url, $feed) {
558
  global $wp_rewrite;
559
  $options = get_option('polylang');
560
 
561
  if ($this->curlang) {
562
  if ($wp_rewrite->using_permalinks()) {
563
- $home = home_url();
564
- $options['rewrite'] ? $base = '/' : $base = '/language/';
565
- $url = esc_url(str_replace($home, $home.$base.$this->curlang->slug, $url));
566
- }
567
- else {
568
- if ($feed)
569
- $url = esc_url(home_url('?lang='.$this->curlang->slug.'&feed='.$feed));
570
  }
 
 
 
571
  }
572
  return $url;
573
  }
@@ -590,31 +604,17 @@ class Polylang extends Polylang_Base {
590
  return $sql;
591
  }
592
 
593
- // modifies the archives link to add the language parameter
594
- function get_archives_link($link_html) {
595
  if ($this->curlang) {
596
  global $wp_rewrite;
597
  $options = get_option('polylang');
598
- $home = home_url();
599
- if ($wp_rewrite->using_permalinks()) {
600
- $options['rewrite'] ? $base = '/' : $base = '/language/';
601
- $link_html = str_replace($home, esc_attr($home.$base.$this->curlang->slug), $link_html);
602
- }
603
- else
604
- $link_html = str_replace($home.'/?', esc_attr($home.'/?lang='.$this->curlang->slug).'&amp;', $link_html);
605
- }
606
- return $link_html;
607
- }
608
 
609
- // modifies the author link to add the language parameter
610
- function author_link($link) {
611
- if ($this->curlang) {
612
- global $wp_rewrite;
613
- $options = get_option('polylang');
614
- $home = home_url();
615
  if ($wp_rewrite->using_permalinks()) {
616
- $options['rewrite'] ? $base = '/' : $base = '/language/';
617
- $link = esc_url(str_replace($home, $home.$base.$this->curlang->slug, $link));
 
618
  }
619
  else
620
  $link = esc_url(str_replace($home.'/?', $home.'/?lang='.$this->curlang->slug.'&amp;', $link));
@@ -622,50 +622,64 @@ class Polylang extends Polylang_Base {
622
  return $link;
623
  }
624
 
 
 
 
 
 
 
625
  // returns the url of the translation (if exists) of the current page
626
  function get_translation_url($language) {
 
 
 
 
627
 
628
- // posts
629
  // is_single is set to 1 for attachment but no language is set
630
- if ( is_single() && !is_attachment() ) {
631
- $id = $this->get_post(get_the_ID(), $language);
632
- if ($id)
633
- $url = get_permalink($id);
634
- }
635
 
636
- elseif ( is_page() ) {
637
- $id = $this->get_post(get_the_ID(), $language);
638
- if ($id)
639
- $url = _get_page_link($id);
640
- }
641
 
642
  elseif ( is_category() || is_tag() ) {
643
  $term = get_queried_object();
644
- $term_id = $term->term_id;
645
  $taxonomy = $term->taxonomy;
646
- $lang = $this->get_term_language($term_id);
647
 
648
  if ($language->slug == $lang->slug)
649
- $url = get_term_link($term->slug, $taxonomy); // self link
650
- else {
651
- $link_id = $this->get_translated_term($term_id, $language);
652
- if ($link_id) {
653
- $term = get_term($link_id,$taxonomy); // We need the slug for get_term_link
654
- $url = get_term_link($term->slug, $taxonomy);
655
- }
656
- }
657
  }
658
 
659
- // FIXME for date links, if I simply modify the lang query, there is a risk that there is no posts (if all are not translated at this date)
660
- // do nothing for now
661
- elseif ( is_year() ) {
662
- }
 
 
 
 
 
663
 
664
- elseif ( is_month() ) {
 
 
 
 
 
 
 
 
 
 
665
  }
666
 
667
  elseif (is_home() || is_tax('language') )
668
- $url = get_term_link($language->slug, 'language');
669
 
670
  return isset($url) ? $url : null;
671
  }
@@ -689,16 +703,35 @@ class Polylang extends Polylang_Base {
689
  return $instance;
690
  }
691
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
692
  // returns the home url in the right language
693
  function get_home_url($language) {
694
- $post_id = get_option('page_on_front');
695
- if ($post_id) {
696
- // a static page is used as front page
697
- $id = $this->get_post($post_id, $language);
698
- if($id)
699
- $url = _get_page_link($id);
700
- }
701
- return isset($url) ? $url : get_term_link($language->slug, 'language');
 
702
  }
703
 
704
  // adds 'lang_url' as possible value to the 'show' parameter of bloginfo to display the home url in the correct language
@@ -706,23 +739,50 @@ class Polylang extends Polylang_Base {
706
  function bloginfo_url($output, $show) {
707
  if ($show == 'lang_url' && $this->curlang) {
708
  $url = $this->get_home_url($this->curlang);
709
- $output = isset($url) ? $url : home_url('/');
710
  }
711
  return $output;
712
  }
713
 
714
- // Template tag : Displays links to the current page in other languages
715
- // Usage : do_action('the_languages');
716
- function the_languages() {
717
- $listlanguages = $this->get_languages_list(true); // hides languages with no posts
718
- $output = "<ul>\n";
 
 
 
 
 
 
 
 
 
719
  foreach ($listlanguages as $language) {
720
  $url = $this->get_translation_url($language);
721
- if (!isset($url))
722
- $url = $this->get_home_url($language); // if the page is not translated, link to the home page
723
- $output .= "<li><a href='$url'>".esc_attr($language->name)."</a></li>\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
724
  }
725
- $output .= "</ul>\n";
726
  echo $output;
727
  }
728
 
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://wordpress.org/extend/plugins/polylang/
5
+ Version: 0.4
6
  Author: F. Demarle
7
  Description: Adds multilingual capability to Wordpress
8
  */
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  */
25
 
26
+ define('POLYLANG_VERSION', '0.4');
27
+
28
  define('POLYLANG_DIR', dirname(__FILE__));
29
+ define('INC_DIR', POLYLANG_DIR.'/include');
30
+
31
+ require_once(INC_DIR.'/base.php');
32
+ require_once(INC_DIR.'/admin.php');
33
+ require_once(INC_DIR.'/widget.php');
34
 
35
  class Polylang extends Polylang_Base {
36
+ var $curlang; // current language
37
  var $default_locale;
38
+ var $list_textdomains = array(); // all text domains
39
+ var $search_form_filter = false; // did we pass our get_search_form filter ?
40
 
41
  function __construct() {
 
42
  // manages plugin activation and deactivation
43
  register_activation_hook( __FILE__, array(&$this, 'activate') );
44
  register_deactivation_hook( __FILE__, array(&$this, 'deactivate') );
77
  // adds the language information in the search form
78
  add_filter('get_search_form', array(&$this, 'get_search_form'));
79
 
80
+ // filters the pages according to the current language in wp_list_pages
81
+ add_filter('wp_list_pages_excludes', array(&$this, 'wp_list_pages_excludes'));
82
 
83
  // filters the comments according to the current language
84
  add_filter('comments_clauses', array(&$this, 'comments_clauses'), 10, 2);
89
  // rewrites archives links to filter them by language
90
  add_filter('getarchives_join', array(&$this, 'posts_join'));
91
  add_filter('getarchives_where', array(&$this, 'posts_where'));
 
92
 
93
+ // rewrites author and date links to filter them by language
94
+ add_filter('author_link', array(&$this, 'archive_link'));
95
+ add_filter('year_link', array(&$this, 'archive_link'));
96
+ add_filter('month_link', array(&$this, 'archive_link'));
97
+ add_filter('day_link', array(&$this, 'archive_link'));
98
+
99
+ // modifies the calendar to filter posts by language
100
+ add_filter('get_calendar', array(&$this, 'get_calendar'));
101
 
102
  // rewrites next and previous post links to filter them by language
103
  add_filter('get_previous_post_join', array(&$this, 'posts_join'));
111
  // filters the widgets according to the current language
112
  add_filter('widget_display_callback', array(&$this, 'widget_display_callback'), 10, 3);
113
 
114
+ // modifies the home url
115
+ add_filter('home_url', array(&$this, 'home_url'));
116
+
117
  // allows a new value for the 'show' parameter to display the homepage url according to the current language
118
  add_filter('bloginfo_url', array(&$this, 'bloginfo_url'), 10, 2);
119
 
148
  ) $charset_collate;");
149
 
150
  // codex tells to use the init action to call register_taxonomy but I need it now for my rewrite rules
151
+ register_taxonomy('language', get_post_types(array('show_ui' => true)), array('label' => false, 'query_var'=>'lang'));
152
 
153
  // defines default values for options in case this is the first installation
154
  $options = get_option('polylang');
155
  if (!$options) {
156
  $options['browser'] = 1; // default language for the front page is set by browser preference
157
  $options['rewrite'] = 0; // do not remove /language/ in permalinks
158
+ $options['hide_default'] = 0; // do not remove URL language information for default language
159
  }
160
+ $options['version'] = POLYLANG_VERSION;
161
  update_option('polylang', $options);
162
 
163
  // add our rewrite rules
180
 
181
  // registers the language taxonomy
182
  // codex: use the init action to call this function
183
+ register_taxonomy('language', get_post_types(array('show_ui' => true)), array(
184
  'label' => false,
185
+ 'public' => false, // avoid displaying the 'like post tags text box' in the quick edit
186
  'query_var'=>'lang',
187
  'update_count_callback' => '_update_post_term_count'));
188
 
189
  // optionaly removes 'language' in permalinks so that we get http://www.myblog/en/ instead of http://www.myblog/language/en/
190
+ // the simple line of code is inspired by the WP No Category Base plugin: http://wordpresssupplies.com/wordpress-plugins/no-category-base/
191
+ global $wp_rewrite;
192
  $options = get_option('polylang');
193
+ if ($options['rewrite'] && $wp_rewrite->extra_permastructs)
 
194
  $wp_rewrite->extra_permastructs['language'][0] = '%language%';
 
195
 
196
  $this->default_locale = get_locale(); // save the default locale before we start any language manipulation
197
+ load_plugin_textdomain('polylang', false, basename(POLYLANG_DIR).'/languages'); // plugin i18n
198
  }
199
 
200
  // registers our widget
211
  // modifies the rules created by WordPress when '/language/' is removed in permalinks
212
  if ($options['rewrite']) {
213
  foreach ($listlanguages as $language) {
214
+ $slug = $options['default_lang'] == $language->slug && $options['hide_default'] ? '' : $language->slug . '/';
215
+ $newrules[$slug.'feed/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?lang='.$language->slug.'&feed=$matches[1]';
216
+ $newrules[$slug.'(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?lang='.$language->slug.'&feed=$matches[1]';
217
+ $newrules[$slug.'page/?([0-9]{1,})/?$'] = 'index.php?lang='.$language->slug.'&paged=$matches[1]';
218
+ if ($slug)
219
+ $newrules[$slug.'?$'] = 'index.php?lang='.$language->slug;
220
  }
221
  unset($rules['([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$']); // => index.php?lang=$matches[1]&feed=$matches[2]
222
  unset($rules['([^/]+)/(feed|rdf|rss|rss2|atom)/?$']); // => index.php?lang=$matches[1]&feed=$matches[2]
224
  unset($rules['([^/]+)/?$']); // => index.php?lang=$matches[1]
225
  }
226
 
227
+ $base = $options['rewrite'] ? '' : 'language/';
228
 
229
  // rewrite rules for comments feed filtered by language
230
  foreach ($listlanguages as $language) {
231
+ $slug = $options['default_lang'] == $language->slug && $options['hide_default'] ? '' : $base.$language->slug . '/';
232
+ $newrules[$slug.'comments/feed/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?lang='.$language->slug.'&feed=$matches[1]&withcomments=1';
233
+ $newrules[$slug.'comments/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?lang='.$language->slug.'&feed=$matches[1]&withcomments=1';
234
  }
235
  unset($rules['comments/feed/(feed|rdf|rss|rss2|atom)/?$']); // => index.php?&feed=$matches[1]&withcomments=1
236
  unset($rules['comments/(feed|rdf|rss|rss2|atom)/?$']); // => index.php?&feed=$matches[1]&withcomments=1
237
 
238
  // rewrite rules for archives filtered by language
239
  foreach ($rules as $key => $rule) {
240
+ $is_archive = strpos($rule, 'author_name=') || strpos($rule, 'year=') && !(
241
  strpos($rule, 'p=') ||
242
  strpos($rule, 'name=') ||
243
  strpos($rule, 'page=') ||
244
  strpos($rule, 'cpage=') );
245
 
246
  if ($is_archive) {
247
+ foreach ($listlanguages as $language) {
248
+ $slug = $options['default_lang'] == $language->slug && $options['hide_default'] ? '' : $base.$language->slug . '/';
249
+ $newrules[$slug.$key] = str_replace('?', '?lang='.$language->slug.'&', $rule);
250
+ }
251
  unset($rules[$key]); // now useless
252
  }
253
  }
 
254
  return $newrules + $rules;
255
  }
256
 
257
  // filters categories and post tags by language when needed (both in admin panels and frontend)
258
  function terms_clauses($clauses, $taxonomies, $args) {
259
+ // does nothing except on taxonomies which have show_ui set to 1 (includes category and post_tags)
260
+ foreach ($taxonomies as $tax) {
261
+ if(!get_taxonomy($tax)->show_ui)
262
+ return $clauses;
263
+ }
264
 
265
  if (is_admin()) {
266
+ $screen = get_current_screen(); // since WP 3.1 // FIXME breaks a user's admin -> use pagenow instead ?
267
 
268
  // NOTE: $screen is not defined in the tag cloud of the Edit Post panel ($pagenow set to admin-ajax.php)
269
  if (isset($screen))
270
+ // does nothing in the Categories, Post tags, Languages and Posts* admin panels
271
  if ($screen->base == 'edit-tags' || $screen->base == 'toplevel_page_mlang' || $screen->base == 'edit')
272
  return $clauses;
273
 
346
  if (isset($post_ID))
347
  $lang = $this->get_post_language($post_ID);
348
 
349
+ if (isset($_POST['action']) && $_POST['action'] == 'get-tagcloud') {
350
+ // to get the language in the Post Tags metabox in the Edit Post screen (as $post_ID not defined)
351
+ $qvars = $this->get_referer_vars();
352
+ if (isset($qvars['new_lang']))
353
+ $lang= $this->get_language($qvars['new_lang']); // post has been created with 'add new' (translation)
354
+ elseif (isset($qvars['post']))
355
+ $lang = $this->get_post_language($qvars['post']); // edit post
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  }
357
+
358
+ // the post is created with the 'add new' (translation) link
359
+ if (isset($_GET['new_lang']))
360
+ $lang = $this->get_language($_GET['new_lang']);
361
  }
362
+ elseif ($var = get_query_var('lang'))
363
+ $lang = $this->get_language($var);
364
+
365
+ elseif (is_single() || is_page() && $var = get_queried_object_id())
366
+ $lang = $this->get_post_language($var);
367
+
368
+ elseif ($var = get_query_var('cat'))
369
+ $lang = $this->get_term_language($var);
370
+
371
+ elseif ($var = get_query_var('tag_id'))
372
+ $lang = $this->get_term_language($var);
373
 
374
  return (isset($lang)) ? $lang : NULL;
375
  }
382
  }
383
 
384
  // saves all text domains in a table for later usage
385
+ function mofile($bool, $domain, $mofile) {
386
  $this->list_textdomains[] = array ('mo' => $mofile, 'domain' => $domain);
387
  return true; // prevents WP loading text domains as we will load them all later
388
  }
389
 
390
  // NOTE: I believe there are two ways for a plugin to force the WP language
391
+ // as done by xili_language and here: load text domains and reinitialize wp_locale with the action 'wp'
392
+ // as done by qtranslate: define the locale with the action 'plugins_loaded', but in this case, the language must be specified in the url.
393
  function load_textdomains() {
394
  // sets the current language and set a cookie to remember it
395
  if ($this->curlang = $this->get_current_language())
409
 
410
  // filters posts according to the language
411
  function pre_get_posts($query) {
412
+ $options = get_option('polylang');
413
+ $qvars = $query->query_vars;
414
+
415
+ // detect our exclude pages query and returns to avoid conflicts
416
+ // this test should be sufficient
417
+ if (isset($qvars['tax_query'][0]) && isset($qvars['tax_query'][0]['taxonomy']) && isset($qvars['tax_query'][0]['operator']))
418
+ return;
419
 
420
  if (empty($query->query)) {
421
+ if ( $options['hide_default'] && isset($_COOKIE['wordpress_polylang']) )
422
+ $this->curlang = $this->get_language($options['default_lang']);
423
+ else
424
+ $this->curlang = $this->get_preferred_language(); // sets the language according to browser preference or default language
425
 
426
+ if ($options['default_lang'] == $this->curlang->slug && $options['hide_default']) {
427
+ if (($post_id = get_option('page_on_front')) && $link_id = $this->get_post($post_id, $this->curlang))
428
+ $query->set('page_id', $link_id);
429
+ else
430
+ $query->set('lang', $this->curlang->slug);
 
 
 
 
 
 
 
 
 
 
 
 
 
431
  }
432
+ else {
433
+ if (($post_id = get_option('page_on_front')) && $link_id = $this->get_post($post_id, $this->curlang))
434
+ $url = _get_page_link($link_id);
435
+ else
436
+ $url = home_url('?lang='.$this->curlang->slug);
437
+
438
+ wp_redirect($url);
439
+ exit;
440
+ }
441
  }
442
+
443
+ // FIXME to generalize as I probably forget things
444
+ // sets the language in case we hide the default language
445
+ if ( $options['hide_default'] && !isset($qvars['lang']) && (
446
+ (count($query->query) == 1 && isset($qvars['paged']) && $qvars['paged']) ||
447
+ isset($qvars['m']) && $qvars['m'] ||
448
+ isset($qvars['feed']) && $qvars['feed'] ||
449
+ isset($qvars['author']) && $qvars['author']))
450
+ $query->set('lang', $options['default_lang']);
451
 
452
  // filters recent posts to the current language
453
  // FIXME if $qvars['post_type'] == 'nav_menu_item', setting lang breaks custom menus.
462
 
463
  // unset the is_archive flag for language pages to prevent loading the archive template
464
  // keep archive flag for comment feed otherwise the language filter does not work
465
+ if (isset($qvars['lang']) && $qvars['lang'] && !is_post_type_archive() && !is_date() && !is_author() && !is_category() && !is_tag() && !is_comment_feed())
466
  $query->is_archive = false;
467
 
468
  // unset the is_tax flag for authors pages
469
  // FIXME Probably I should do this for other cases
470
+ if (isset($qvars['lang']) && $qvars['lang'] && is_author())
471
  $query->is_tax = false;
 
472
  }
473
 
474
  function wp_head() {
485
  }
486
 
487
  // outputs references to translated pages (if exists) in the html head section
488
+ foreach ($this->get_languages_list() as $language) {
489
+ if ($language->slug != $this->curlang->slug && $url = $this->get_translation_url($language))
490
+ printf("<link hreflang='%s' href='%s' rel='alternate' />\n", esc_attr($language->slug), $url);
 
 
 
 
 
491
  }
492
  }
493
 
501
  // adds some javascript workaround knowing it's not perfect...
502
  function wp_print_footer_scripts() {
503
  if ($this->curlang) {
504
+ $js = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
 
506
  // modifies the search form since filtering get_search_form won't work if the template uses searchform.php
507
  // don't use directly e[0] just in case there is somewhere else an element named 's'
520
  }";
521
  }
522
 
523
+ if ($js)
524
+ echo "<script type='text/javascript'>" .$js. "</script>";
525
  }
526
  }
527
 
528
  // adds the language information in the search form
529
+ // does not work if searchform.php is used
530
  function get_search_form($form) {
531
  if ($form) {
532
  $this->search_form_filter = true;
535
  return $form;
536
  }
537
 
538
+ // excludes pages which are not in the current language for wp_list_pages
539
+ // useful for the pages widget
540
+ function wp_list_pages_excludes($pages) {
 
 
541
  if (isset($this->curlang)) {
542
+ $q = array(
543
+ 'numberposts'=>-1,
544
+ 'post_type' => 'page',
545
+ 'fields' => 'ids',
546
+ 'tax_query' => array(array(
547
+ 'taxonomy'=>'language',
548
+ 'fields' => 'id',
549
+ 'terms'=>$this->curlang->term_id,
550
+ 'operator'=>'NOT IN'
551
+ ))
552
+ );
553
+ $pages = array_merge($pages, get_posts($q));
554
  }
555
  return $pages;
556
  }
568
  }
569
 
570
  // Modifies the feed link to add the language parameter
 
571
  function feed_link($url, $feed) {
572
  global $wp_rewrite;
573
  $options = get_option('polylang');
574
 
575
  if ($this->curlang) {
576
  if ($wp_rewrite->using_permalinks()) {
577
+ $home = get_option('home');
578
+ $base = $options['rewrite'] ? '/' : '/language/';
579
+ $slug = $options['default_lang'] == $this->curlang->slug && $options['hide_default'] ? '' : $base.$this->curlang->slug;
580
+ $url = esc_url(str_replace($home, $home.$slug, $url));
 
 
 
581
  }
582
+ elseif ($feed)
583
+ $url = esc_url(home_url('?lang='.$this->curlang->slug.'&feed='.$feed));
584
+
585
  }
586
  return $url;
587
  }
604
  return $sql;
605
  }
606
 
607
+ // modifies the author and date links to add the language parameter
608
+ function archive_link($link) {
609
  if ($this->curlang) {
610
  global $wp_rewrite;
611
  $options = get_option('polylang');
612
+ $home = get_option('home');
 
 
 
 
 
 
 
 
 
613
 
 
 
 
 
 
 
614
  if ($wp_rewrite->using_permalinks()) {
615
+ $base = $options['rewrite'] ? '/' : '/language/';
616
+ $slug = $options['default_lang'] == $this->curlang->slug && $options['hide_default'] ? '' : $base.$this->curlang->slug;
617
+ $link = esc_url(str_replace($home, $home.$slug, $link));
618
  }
619
  else
620
  $link = esc_url(str_replace($home.'/?', $home.'/?lang='.$this->curlang->slug.'&amp;', $link));
622
  return $link;
623
  }
624
 
625
+ // modifies the calendar to filter posts by language
626
+ function get_calendar() {
627
+ require_once(INC_DIR.'/calendar.php');
628
+ return $calendar_output;
629
+ }
630
+
631
  // returns the url of the translation (if exists) of the current page
632
  function get_translation_url($language) {
633
+ global $wp_query, $wp_rewrite;
634
+ $qvars = $wp_query->query;
635
+ $options = get_option('polylang');
636
+ $hide = $options['default_lang'] == $language->slug && $options['hide_default'];
637
 
 
638
  // is_single is set to 1 for attachment but no language is set
639
+ if (is_single() && !is_attachment() && $id = $this->get_post(get_the_ID(), $language))
640
+ $url = get_permalink($id);
 
 
 
641
 
642
+ elseif (is_page() && $id = $this->get_post(get_the_ID(), $language))
643
+ $url = $hide && $id == $this->get_post(get_option('page_on_front'), $language) ?
644
+ get_option('home') :
645
+ _get_page_link($id);
 
646
 
647
  elseif ( is_category() || is_tag() ) {
648
  $term = get_queried_object();
649
+ $lang = $this->get_term_language($term->term_id);
650
  $taxonomy = $term->taxonomy;
 
651
 
652
  if ($language->slug == $lang->slug)
653
+ $url = get_term_link($term, $taxonomy); // self link
654
+ elseif ($link_id = $this->get_translated_term($term->term_id, $language))
655
+ $url = get_term_link(get_term($link_id, $taxonomy), $taxonomy);
 
 
 
 
 
656
  }
657
 
658
+ // don't test if there are existing translations before creating the url as it would be very expensive in sql queries
659
+ elseif(is_archive()) {
660
+ if ($wp_rewrite->using_permalinks()) {
661
+ $base = $options['rewrite'] ? '/' : '/language/';
662
+ $base = $hide ? '' : $base.$language->slug;
663
+ $base = get_option('home').$base.'/';
664
+
665
+ if (is_author())
666
+ $url = esc_url($base.'author/'.$qvars['author_name'].'/');
667
 
668
+ if (is_year())
669
+ $url = esc_url($base.$qvars['year'].'/');
670
+
671
+ if (is_month())
672
+ $url = esc_url($base.$qvars['year'].'/'.$qvars['monthnum'].'/');
673
+
674
+ if (is_day())
675
+ $url = esc_url($base.$qvars['year'].'/'.$qvars['monthnum'].'/'.$qvars['day'].'/');
676
+ }
677
+ else
678
+ $url = $hide ? remove_query_arg('lang') : add_query_arg('lang', $language->slug);
679
  }
680
 
681
  elseif (is_home() || is_tax('language') )
682
+ $url = $hide ? get_option('home') : get_term_link($language, 'language');
683
 
684
  return isset($url) ? $url : null;
685
  }
703
  return $instance;
704
  }
705
 
706
+ // filters the home url to get the right language
707
+ function home_url($url) {
708
+ if ( !(did_action('template_redirect') && rtrim($url,'/') == rtrim(get_option('home'),'/') && $this->curlang) )
709
+ return $url;
710
+
711
+ // don't like this but at least for WP_Widget_Categories::widget, it seems to be the only solution
712
+ // FIXME are there other exceptions ?
713
+ foreach (debug_backtrace() as $trace) {
714
+ $exceptions = $trace['function'] == 'get_pagenum_link' ||
715
+ $trace['function'] == 'get_author_posts_url' ||
716
+ ($trace['function'] == 'widget' && $trace['class'] == 'WP_Widget_Categories');
717
+ if ($exceptions)
718
+ return $url;
719
+ }
720
+
721
+ return $this->get_home_url($this->curlang);
722
+ }
723
+
724
  // returns the home url in the right language
725
  function get_home_url($language) {
726
+ $options = get_option('polylang');
727
+ if ($options['default_lang'] == $language->slug && $options['hide_default'])
728
+ return trailingslashit(get_option('home'));
729
+
730
+ // a static page is used as front page
731
+ if (($post_id = get_option('page_on_front')) && $id = $this->get_post($post_id, $language))
732
+ $url = _get_page_link($id);
733
+
734
+ return isset($url) ? $url : get_term_link($language, 'language');
735
  }
736
 
737
  // adds 'lang_url' as possible value to the 'show' parameter of bloginfo to display the home url in the correct language
739
  function bloginfo_url($output, $show) {
740
  if ($show == 'lang_url' && $this->curlang) {
741
  $url = $this->get_home_url($this->curlang);
742
+ $output = isset($url) ? $url : get_option('home');
743
  }
744
  return $output;
745
  }
746
 
747
+ // Template tag: Displays links to the current page in other languages
748
+ // Usage: do_action('the_languages');
749
+ function the_languages($args = '') {
750
+ $defaults = array(
751
+ 'dropdown' => 0, // display as list and not as dropdown
752
+ 'show_names' => 1, // show language names
753
+ 'show_flags' => 0, // don't show flags
754
+ 'hide_if_empty' => 1 // hides languages with no posts (or pages)
755
+ );
756
+
757
+ extract(wp_parse_args($args, $defaults));
758
+
759
+ $listlanguages = $this->get_languages_list($hide_if_empty);
760
+ $output = $dropdown ? '<select name="lang_choice" id="lang_choice">' : "<ul>\n";
761
  foreach ($listlanguages as $language) {
762
  $url = $this->get_translation_url($language);
763
+ $url = isset($url) ? $url : $this->get_home_url($language); // if the page is not translated, link to the home page
764
+
765
+ $class = 'lang-item lang-item-'.esc_attr($language->term_id);
766
+ if ($language->slug == $this->curlang->slug)
767
+ $class .= ' current-lang';
768
+
769
+ $flag = $show_flags &&
770
+ file_exists(POLYLANG_DIR.($file = '/local_flags/'.$language->description.'.png')) ||
771
+ file_exists(POLYLANG_DIR.($file = '/flags/'.$language->description.'.png')) ?
772
+ '<img src="'.WP_PLUGIN_URL.'/polylang'.$file.'" alt="'.$language->name.'" />' : '';
773
+
774
+ $name = $show_names || !$show_flags ? esc_attr($language->name) : '';
775
+
776
+ $output .= $dropdown ?
777
+ sprintf(
778
+ "<option value='%s'%s>%s</option>\n",
779
+ esc_attr($language->slug),
780
+ $language->slug == $this->curlang->slug ? ' selected="selected"' : '',
781
+ $name // FIXME flag does not work for the dropdown list
782
+ ) :
783
+ '<li class="'.$class.'"><a href="'.$url.'">'.($show_flags && $show_names ? $flag.'&nbsp;'.$name : $flag.$name)."</a></li>\n";
784
  }
785
+ $output .= $dropdown ? '</select>' : "</ul>\n";
786
  echo $output;
787
  }
788
 
polylang.pot DELETED
@@ -1,206 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: polylang\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2011-10-19 20:43+0100\n"
6
- "PO-Revision-Date: \n"
7
- "Last-Translator: F. Demarle\n"
8
- "Language-Team: \n"
9
- "Language: \n"
10
- "MIME-Version: 1.0\n"
11
- "Content-Type: text/plain; charset=UTF-8\n"
12
- "Content-Transfer-Encoding: 8bit\n"
13
- "Plural-Forms: nplurals=2: nplural=n>1\n"
14
- "X-Poedit-SourceCharset: utf-8\n"
15
- "X-Poedit-KeywordsList: _e;__;_c\n"
16
- "X-Poedit-Basepath: .\n"
17
- "X-Poedit-SearchPath-0: .\n"
18
-
19
- #: edit-term-form.php:6
20
- #: admin.php:277
21
- #: admin.php:453
22
- #: term-translations.php:16
23
- #: add-term-form.php:3
24
- #: list-table.php:12
25
- #: post-translations.php:5
26
- msgid "Language"
27
- msgstr ""
28
-
29
- #: edit-term-form.php:18
30
- #: add-term-form.php:10
31
- msgid "Sets the language"
32
- msgstr ""
33
-
34
- #: widget.php:5
35
- msgid "Displays a language switcher"
36
- msgstr ""
37
-
38
- #: widget.php:6
39
- msgid "Language Switcher"
40
- msgstr ""
41
-
42
- #: admin.php:86
43
- msgid "Settings"
44
- msgstr ""
45
-
46
- #: admin.php:93
47
- #: admin.php:322
48
- #: admin.php:323
49
- #: list-table.php:13
50
- #: languages-form.php:14
51
- msgid "Languages"
52
- msgstr ""
53
-
54
- #: admin.php:313
55
- msgid "Show all languages"
56
- msgstr ""
57
-
58
- #: admin.php:549
59
- msgid "Theme locations and languages"
60
- msgstr ""
61
-
62
- #: admin.php:554
63
- #, php-format
64
- msgid "Please go to the %slanguages page%s to set theme locations and languages"
65
- msgstr ""
66
-
67
- #: admin.php:567
68
- msgid "The widget is displayed for:"
69
- msgstr ""
70
-
71
- #: admin.php:570
72
- msgid "All languages"
73
- msgstr ""
74
-
75
- #: post-metabox.php:3
76
- msgid "Page's language:"
77
- msgstr ""
78
-
79
- #: post-metabox.php:3
80
- msgid "Post's language:"
81
- msgstr ""
82
-
83
- #: term-translations.php:6
84
- #: term-translations.php:10
85
- msgid "Translations"
86
- msgstr ""
87
-
88
- #: term-translations.php:16
89
- msgid "Translation"
90
- msgstr ""
91
-
92
- #: term-translations.php:16
93
- #: term-translations.php:77
94
- #: list-table.php:32
95
- #: post-translations.php:7
96
- #: post-translations.php:29
97
- msgid "Edit"
98
- msgstr ""
99
-
100
- #: term-translations.php:63
101
- #: post-translations.php:34
102
- msgid "Add new"
103
- msgstr ""
104
-
105
- #: list-table.php:33
106
- msgid "Delete"
107
- msgstr ""
108
-
109
- #: list-table.php:50
110
- #: languages-form.php:46
111
- msgid "Full name"
112
- msgstr ""
113
-
114
- #: list-table.php:51
115
- #: languages-form.php:52
116
- msgid "Locale"
117
- msgstr ""
118
-
119
- #: list-table.php:52
120
- msgid "Code"
121
- msgstr ""
122
-
123
- #: list-table.php:53
124
- msgid "Posts"
125
- msgstr ""
126
-
127
- #: languages-form.php:29
128
- msgid "Edit language"
129
- msgstr ""
130
-
131
- #: languages-form.php:29
132
- #: languages-form.php:66
133
- msgid "Add new language"
134
- msgstr ""
135
-
136
- #: languages-form.php:48
137
- msgid "The name is how it is displayed on your site (for example: English)."
138
- msgstr ""
139
-
140
- #: languages-form.php:54
141
- msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
142
- msgstr ""
143
-
144
- #: languages-form.php:58
145
- msgid "Language code"
146
- msgstr ""
147
-
148
- #: languages-form.php:60
149
- msgid "2-letters ISO 639-1 language code (for example: en)"
150
- msgstr ""
151
-
152
- #: languages-form.php:64
153
- msgid "Update"
154
- msgstr ""
155
-
156
- #: languages-form.php:78
157
- msgid "Menus"
158
- msgstr ""
159
-
160
- #: languages-form.php:86
161
- msgid "Theme location"
162
- msgstr ""
163
-
164
- #: languages-form.php:131
165
- msgid "Options"
166
- msgstr ""
167
-
168
- #: languages-form.php:144
169
- msgid "Keep /language/ in pretty permalinks"
170
- msgstr ""
171
-
172
- #: languages-form.php:155
173
- msgid "Remove /language/ in pretty permalinks"
174
- msgstr ""
175
-
176
- #: languages-form.php:162
177
- msgid "The front page default language is : "
178
- msgstr ""
179
-
180
- #: languages-form.php:167
181
- msgid "set by the browser preference"
182
- msgstr ""
183
-
184
- #: languages-form.php:170
185
- msgid "otherwise: "
186
- msgstr ""
187
-
188
- #: post-translations.php:2
189
- msgid "ID of pages in other languages:"
190
- msgstr ""
191
-
192
- #: post-translations.php:2
193
- msgid "ID of posts in other languages:"
194
- msgstr ""
195
-
196
- #: post-translations.php:6
197
- msgid "Page ID"
198
- msgstr ""
199
-
200
- #: post-translations.php:6
201
- msgid "Post ID"
202
- msgstr ""
203
-
204
- #~ msgid "Title:"
205
- #~ msgstr "Titre :"
206
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Chouby
3
  Tags: bilingual, multilingual, language, i18n, l10n, international, translate, translation, widget
4
  Requires at least: 3.1
5
  Tested up to: 3.2.1
6
- Stable tag: 0.3.2
7
 
8
  Adds multilingual support to WordPress.
9
 
@@ -11,7 +11,7 @@ Adds multilingual support to WordPress.
11
 
12
  Polylang adds multilingual support to WordPress. It acts as a language filter for posts you have written in several languages. It will however not make the translation for you ! If you are looking for automatic translation, look for another plugin. Unlike some other plugins, it does not integrate professionnal translation.
13
 
14
- You write posts, pages and create categories and post tags as usual. You just have to define the language and it will be displayed only if the visitor is browsing this language. Optionaly, you can mark each post, page, category and post tag to be the translation of another one. Thus if, for example, your visitor is reading a post, he can switch (using the simple language switcher widget provided with the plugin) to the same post translated in another language (provided that you translated it !).
15
 
16
  = Features =
17
 
@@ -21,22 +21,24 @@ You write posts, pages and create categories and post tags as usual. You just ha
21
  * Support for Search form (see FAQ)
22
  * Support for pretty permalinks
23
  * Support for static page (in the right language) used as front page
24
- * The following widgets are automatically in the right language : archives, categories, pages, recent comments, recent posts, tag cloud (calendar not supported yet)
25
- * All widgets can be displayed or not, depending on the language
26
- * Simple language switcher provided as a widget
27
- * The plugin backend is currently available in English, French and German
 
 
28
 
29
  = Notes =
30
 
31
  * The tests have been made with WordPress 3.2.1 and with the Twenty Eleven theme (see FAQ). Although I did not test previous versions, I see no reason why it should not work with WordPress 3.1. However the plugin should not work with WordPress 3.0.5 and lower.
32
  * Your server must run PHP5
33
- * Multisite has not been tested.
34
- * You must deactivate other multilingual plugins before activating Polylang. Otherwise, you may get unexpected results !
35
- * Unlike some other plugins, if you deactivate Polylang, your blog will go on working as smoothly as possible. All your posts, pages, category and post tags would be accessible (without language filter of course !).
36
 
37
  = Feedback or ideas =
38
 
39
- You use the plugin or just tested it ? Don't hesitate to [give your feedback](http://wordpress.org/tags/polylang?forum_id=10)
40
 
41
  == Installation ==
42
 
@@ -53,7 +55,7 @@ You use the plugin or just tested it ? Don't hesitate to [give your feedback](ht
53
 
54
  = Why using Polylang and not other well established equivalent plugins ? =
55
 
56
- WPML: I tested only the last non-commercial version with WP 3.0.5. The plugin looks quite complete. It's however very heavy (almost 30000 lines of code !). The fact that it has turned commercial is probably adapted to companies or very active bloggers but not well adapted to small blogs.
57
 
58
  Xili language: I tested the version 2.2.0. It looks too complex. For example you need to install 3 different plugins to manage post tags translation. If managing post translations is quite easy (and inspired Polylang...), the way to manage categories and post tags translations is not enough user friendly in my opinion. As WPML it's very heavy (about 12000 lines of code).
59
 
@@ -68,27 +70,64 @@ Your theme uses the template searchform.php (as Twenty Eleven does) or hardcoded
68
  * Use the 'get_search_form' function and place your custom search form in functions.php as described in the [codex](http://codex.wordpress.org/Function_Reference/get_search_form). The plugin also works well if you use the default search form provided by WordPress.
69
  * Enable javascript (unfortunately you can't control this for your visitors so the first solution is better)
70
 
71
- = The language filter is lost when using the calendar widget =
72
 
73
- The plugin is not compatible with the calendar widget. The calendar displays well but it does not link to posts filtered in the right language. Consider using the Archives widget instead.
74
 
75
- = The homepage link always send to the homepage in the default language =
76
 
77
- Your theme has not been adapted to Polylang and both javascript and cookies are disabled. Unfortunately, it seems impossible (or too complex for me !) to correctly filter home_url (or bloginfo('url') and be sure that all things work. So you have the following alternatives:
78
-
79
- * Use 'bloginfo('lang_url)' in your theme whenever you want to link to the homepage in the right language. Don't use this template tag for the search form action.
80
- * Enable javascript and/or cookies (unfortunately you can't control this for your visitors so the first solution is better)
81
 
82
- = I activated the plugin and my posts are not displayed any more =
83
 
84
- You MUST define a language for all your posts and pages otherwise they will not pass the language filter...
85
 
86
- = I activated the plugin and my categories and post tags are not displayed any more =
 
 
87
 
88
- You MUST define a language for all your categories and post tags otherwise they will not pass the language filter...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
  == Changelog ==
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  = 0.3.2 =
93
 
94
  * Bug correction: authors pages are not filtered by language
3
  Tags: bilingual, multilingual, language, i18n, l10n, international, translate, translation, widget
4
  Requires at least: 3.1
5
  Tested up to: 3.2.1
6
+ Stable tag: 0.4
7
 
8
  Adds multilingual support to WordPress.
9
 
11
 
12
  Polylang adds multilingual support to WordPress. It acts as a language filter for posts you have written in several languages. It will however not make the translation for you ! If you are looking for automatic translation, look for another plugin. Unlike some other plugins, it does not integrate professionnal translation.
13
 
14
+ You write posts, pages and create categories and post tags as usual. You just have to define the language and it will be displayed only if the visitor is browsing this language. Optionaly, you can mark each post, page, category and post tag to be the translation of another one. Thus if, for example, your visitor is reading a post, he can switch (using the language switcher widget provided with the plugin) to the same post translated in another language (provided that you translated it !).
15
 
16
  = Features =
17
 
21
  * Support for Search form (see FAQ)
22
  * Support for pretty permalinks
23
  * Support for static page (in the right language) used as front page
24
+ * All WordPress default widgets are automatically in the right language : archives, categories, pages, recent comments, recent posts, tag cloud and calendar
25
+ * All widgets can be displayed or not, depending on the language (new in 0.3)
26
+ * Language switcher provided as a widget
27
+ * The plugin admin is currently available in English, French and German
28
+ * Each user can set the WordPress admin language in its profile (new in 0.4)
29
+ * Support for custom post types and custom taxonomies (new in 0.4)
30
 
31
  = Notes =
32
 
33
  * The tests have been made with WordPress 3.2.1 and with the Twenty Eleven theme (see FAQ). Although I did not test previous versions, I see no reason why it should not work with WordPress 3.1. However the plugin should not work with WordPress 3.0.5 and lower.
34
  * Your server must run PHP5
35
+ * Multisite is not supported yet.
36
+ * You must deactivate other multilingual plugins before activating Polylang, otherwise, you may get unexpected results !
37
+ * Unlike some other plugins, if you deactivate Polylang, your blog will go on working as smoothly as possible. All your posts, pages, category and post tags would be accessible (without language filter of course...).
38
 
39
  = Feedback or ideas =
40
 
41
+ You use the plugin or just tested it ? Don't hesitate to [give your feedback](http://wordpress.org/tags/polylang?forum_id=10). It will help making the plugin better. Don't hesitate to rate the plugin too.
42
 
43
  == Installation ==
44
 
55
 
56
  = Why using Polylang and not other well established equivalent plugins ? =
57
 
58
+ WPML: I tested only the last non-commercial version (2.0.4.1) with WP 3.0.5. The plugin looks quite complete. It's however very heavy (almost 30000 lines of code !). The fact that it has turned commercial is probably adapted to companies or very active bloggers but not well adapted to small blogs.
59
 
60
  Xili language: I tested the version 2.2.0. It looks too complex. For example you need to install 3 different plugins to manage post tags translation. If managing post translations is quite easy (and inspired Polylang...), the way to manage categories and post tags translations is not enough user friendly in my opinion. As WPML it's very heavy (about 12000 lines of code).
61
 
70
  * Use the 'get_search_form' function and place your custom search form in functions.php as described in the [codex](http://codex.wordpress.org/Function_Reference/get_search_form). The plugin also works well if you use the default search form provided by WordPress.
71
  * Enable javascript (unfortunately you can't control this for your visitors so the first solution is better)
72
 
73
+ = I activated the plugin and my posts are not displayed any more =
74
 
75
+ You MUST define a language for all your posts and pages otherwise they will not pass the language filter...
76
 
77
+ = I activated the plugin and my categories and post tags are not displayed any more =
78
 
79
+ You MUST define a language for all your categories and post tags otherwise they will not pass the language filter...
 
 
 
80
 
81
+ = Is Polylang compatible with multisite ? =
82
 
83
+ Not yet.
84
 
85
+ = Is it possible to display a language switcher without using the widget =
86
+
87
+ It is possible to get a language switcher where you want in your theme without using the widget. For this, you can simply use in your theme the following instruction: `do_action('the_languages');`
88
 
89
+ = Can I use my own flags for the language switcher ? =
90
+
91
+ Yes. You have to use PNG files and name them with the WordPress locale. For example, en_US.png. Then upload these files in the `/polylang/local_flags` directory. Don't use the `/polylang/flags` directory as your files may be overwritten when updating the plugin.
92
+
93
+ = Polylang does not come with a lot flags. Where can I find other flags ? =
94
+
95
+ There are many sources. I included some of the [famfamfam](http://www.famfamfam.com) flags which I renamed.
96
+
97
+ = How to know the current language in the theme ? =
98
+
99
+ WordPress provides at least two functions for the theme or plugin author to know the current language:
100
+ * `get_locale()` returns the WordPress locale in the format `en_US`
101
+ * `get_bloginfo('language')` returns the locale in the format `en-US`
102
+ Note the difference between '_' and '-' in the two functions.
103
+ You can look at the following forum topics:
104
+ [Return the current language as variable for your template](http://wordpress.org/support/topic/plugin-polylang-return-the-current-language-as-variable-for-your-template)
105
+ [How to translate/switch specific contents on templates](http://wordpress.org/support/topic/plugin-polylang-how-to-translateswitch-specific-contents-on-templates.html)
106
 
107
  == Changelog ==
108
 
109
+ = 0.4 =
110
+
111
+ * Add a documentation (in English only)
112
+ * Add the possibility to hide the url language information for the default language
113
+ * Add the possibility to set the admin language in the user profile
114
+ * Add the possibilty to fill existing posts, pages, categories & tags with the default language
115
+ * Add support for custom post types and custom taxonomies
116
+ * Add the possibility to display flags in the language switcher
117
+ * Add CSS classes to customize rendering of the language switcher
118
+ * Add the possibility to display the language switcher as a dropdown list
119
+ * Add support for calendar widget
120
+ * Improve performance: less sql queries
121
+ * Improve data validation when creating or updating languages
122
+ * Bug correction: 'wp_list_pages' page order is ignored when plugin is enabled
123
+ * Bug correction: when using 'edit' or 'add new' (translation) for posts, the categories appear in the wrong language
124
+ * Bug correction: pages are not included in language post count
125
+ * Bug correction: the language switcher does not display languages if there are only pages
126
+ * Bug correction: the widget filter does not allow to come back to 'all languages' once a language has been set
127
+ * Other minor bug corrections
128
+
129
+ release: November 10th, 2011
130
+
131
  = 0.3.2 =
132
 
133
  * Bug correction: authors pages are not filtered by language
uninstall.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  global $wpdb;
4
  $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb
5
- register_taxonomy('language', 'post', array('label' => false, 'query_var'=>'lang')); // temporarily register the language taxonomy
6
 
7
  $languages = get_terms('language', array('hide_empty'=>false));
8
 
@@ -14,7 +14,7 @@ foreach ($languages as $lang) {
14
  delete_post_meta($post->ID, '_lang-'.$lang->slug);
15
  }
16
  // delete references to this language in categories & post tags
17
- $terms = get_terms(array('category', 'post_tag'), 'get=all');
18
  foreach ($terms as $term) {
19
  delete_metadata('term', $term->term_id, '_language');
20
  delete_metadata('term', $term->term_id, '_lang-'.$lang->slug);
2
 
3
  global $wpdb;
4
  $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb
5
+ register_taxonomy('language', get_post_types(array('show_ui' => true)), array('label' => false, 'query_var'=>'lang')); // temporarily register the language taxonomy
6
 
7
  $languages = get_terms('language', array('hide_empty'=>false));
8
 
14
  delete_post_meta($post->ID, '_lang-'.$lang->slug);
15
  }
16
  // delete references to this language in categories & post tags
17
+ $terms = get_terms(get_taxonomies(array('show_ui'=>true)), 'get=all');
18
  foreach ($terms as $term) {
19
  delete_metadata('term', $term->term_id, '_language');
20
  delete_metadata('term', $term->term_id, '_lang-'.$lang->slug);
widget.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- class Polylang_Widget extends WP_Widget {
4
- function __construct() {
5
- $widget_ops = array( 'description' => __( 'Displays a language switcher', 'polylang') );
6
- parent::__construct('polylang', __('Language Switcher', 'polylang'), $widget_ops);
7
- }
8
-
9
- function widget($args, $instance) {
10
- extract( $args );
11
-
12
- echo "$before_widget\n";
13
- do_action('the_languages');
14
- echo "$after_widget\n";
15
- }
16
-
17
- } // Class Polylang_Widget
18
-
19
- ?>