Polylang - Version 0.4.1

Version Description

  • Bug correction: flags shows even when you set doesn't to show
  • Bug correction: custom taxonomies do not work
  • Bug correction: some users get the fatal error: call to undefined function wp_get_current_user() in /wp-includes/user.php on line 227
Download this release

Release Info

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

Code changes from version 0.4 to 0.4.1

include/admin.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  require_once(INC_DIR.'/list-table.php');
4
 
5
  class Polylang_Admin extends Polylang_Base {
@@ -647,7 +649,8 @@ class Polylang_Admin extends Polylang_Base {
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
1
  <?php
2
 
3
+ require_once( ABSPATH . WPINC . '/pluggable.php' ); // to ensure that 'get_current_user_id' is defined
4
+
5
  require_once(INC_DIR.'/list-table.php');
6
 
7
  class Polylang_Admin extends Polylang_Base {
649
 
650
  // returns the locale based on user preference
651
  function get_locale($locale) {
652
+ $loc = get_user_meta(get_current_user_id(), 'user_lang', 'true');
653
+ return $loc ? $loc : $locale;
654
  }
655
 
656
  // updates language user preference
include/base.php CHANGED
@@ -48,8 +48,12 @@ class Polylang_Base {
48
  }
49
 
50
  // returns the language of a term
51
- function get_term_language($term_id) {
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)
48
  }
49
 
50
  // returns the language of a term
51
+ function get_term_language($value, $taxonomy = '') {
52
+ if (is_numeric($value))
53
+ $term_id = $value;
54
+ elseif (is_string($value) && $taxonomy)
55
+ $term_id = get_term_by('slug', $value , $taxonomy)->term_id;
56
+ return $term_id ? $this->get_language(get_metadata('term', $term_id, '_language', true)) : null;
57
  }
58
 
59
  // returns the id of the translation of a term (category, post tag or custom taxonomy)
include/languages-form.php CHANGED
@@ -1,4 +1,5 @@
1
- <?php // displays the Languages admin panel
 
2
 
3
  // I don't use the custom taxonomy form provide by Wordpress because I want to modify the labels below the fields...
4
  // It seems that there is currently (3.2.1) no filter to do this
@@ -7,7 +8,6 @@
7
  // name -> language name (used only for display)
8
  // slug -> language code (ideally 2-letters ISO 639-1 language code but I currently use it only as slug so it doesn't matter)
9
  // description -> WordPress Locale for the language. Here if something wrong is used, the .mo files will not be loaded...
10
-
11
  ?>
12
  <div class="wrap">
13
  <?php screen_icon('options-general'); ?>
@@ -30,9 +30,9 @@ if (isset($_GET['error'])) {?>
30
  <div class="col-wrap">
31
 
32
  <div class="form-wrap">
33
- <h3><?php echo $action=='edit' ? _e('Edit language','polylang') : _e('Add new language','polylang'); ?></h3>
34
 
35
- <?php // displays the add (or edit) language form
36
 
37
  // adds noheader=true in the action url to allow using wp_redirect when processing the form ?>
38
  <form id="add-lang" method="post" action="admin.php?page=mlang&amp;noheader=true" class="validate">
@@ -64,10 +64,7 @@ else { ?>
64
  <p><?php _e('2-letters ISO 639-1 language code (for example: en)', 'polylang');?></p>
65
  </div>
66
 
67
- <?php if ($action=='edit')
68
- submit_button(__('Update'), 'button'); // since WP 3.1
69
- else
70
- submit_button(__('Add new language', 'polylang'), 'button'); // since WP 3.1?>
71
 
72
  </form>
73
  </div> <!-- form-wrap -->
@@ -163,7 +160,7 @@ if (!empty($posts) || !empty($terms) && $options['default_lang']) {
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
1
+ <?php
2
+ // displays the Languages admin panel
3
 
4
  // I don't use the custom taxonomy form provide by Wordpress because I want to modify the labels below the fields...
5
  // It seems that there is currently (3.2.1) no filter to do this
8
  // name -> language name (used only for display)
9
  // slug -> language code (ideally 2-letters ISO 639-1 language code but I currently use it only as slug so it doesn't matter)
10
  // description -> WordPress Locale for the language. Here if something wrong is used, the .mo files will not be loaded...
 
11
  ?>
12
  <div class="wrap">
13
  <?php screen_icon('options-general'); ?>
30
  <div class="col-wrap">
31
 
32
  <div class="form-wrap">
33
+ <h3><?php echo $action=='edit' ? _e('Edit language','polylang') : _e('Add new language','polylang'); ?></h3><?php
34
 
35
+ // displays the add (or edit) language form
36
 
37
  // adds noheader=true in the action url to allow using wp_redirect when processing the form ?>
38
  <form id="add-lang" method="post" action="admin.php?page=mlang&amp;noheader=true" class="validate">
64
  <p><?php _e('2-letters ISO 639-1 language code (for example: en)', 'polylang');?></p>
65
  </div>
66
 
67
+ <?php submit_button( $action == 'edit' ? __('Update') : __('Add new language', 'polylang'), 'button'); // since WP 3.1 ?>
 
 
 
68
 
69
  </form>
70
  </div> <!-- form-wrap -->
160
  if (!empty($terms))
161
  echo '<input type="hidden" name="terms" value="'.esc_attr($terms).'" />';?>
162
 
163
+ <tr><?php
164
  <th></th>
165
  <td>
166
  <label style="color: red"><?php
include/personal-options.php CHANGED
@@ -1,6 +1,6 @@
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
1
  <?php // allows each user to choose the admin language ?>
2
  <tr>
3
+ <th><label for='user_lang'><?php _e('Admin language', 'polylang');?></label></th>
4
  <td>
5
  <select name="user_lang" id="user_lang">
6
  <option value="0"></option><?php
include/widget.php CHANGED
@@ -11,7 +11,11 @@ class Polylang_Widget extends WP_Widget {
11
  extract($args);
12
  extract($instance);
13
 
 
 
14
  echo "$before_widget\n";
 
 
15
  do_action('the_languages', $instance);
16
  echo "$after_widget\n";
17
 
@@ -32,6 +36,8 @@ class Polylang_Widget extends WP_Widget {
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;
@@ -41,27 +47,33 @@ class Polylang_Widget extends WP_Widget {
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
11
  extract($args);
12
  extract($instance);
13
 
14
+ $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
15
+
16
  echo "$before_widget\n";
17
+ if ($title)
18
+ echo $before_title . $title . $after_title;
19
  do_action('the_languages', $instance);
20
  echo "$after_widget\n";
21
 
36
  // updates the widget options
37
  function update( $new_instance, $old_instance ) {
38
  $instance = $old_instance;
39
+ $new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'show_names' => 1, 'show_flags' => 0, 'dropdown' => 0) ); // default values
40
+ $instance['title'] = strip_tags($new_instance['title']);
41
  $instance['show_names'] = !empty($new_instance['show_names']) ? 1 : 0;
42
  $instance['show_flags'] = !empty($new_instance['show_flags']) ? 1 : 0;
43
  $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
47
 
48
  // displays the widget form
49
  function form($instance) {
50
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'show_names' => 1, 'show_flags' => 0, 'dropdown' => 0) ); // default values
51
+
52
+ // title
53
+ $id = $this->get_field_id('title');
54
+ $name = $this->get_field_name('title');
55
+ $title = sprintf('<p><label for="%s">%s</label><input class="widefat" id="%s" name="%s" type="text" value="%s" /></p>',
56
+ $id, __('Title:'), $id, $name, esc_attr($instance['title']));
57
 
58
  // language names checkbox
59
  $id = $this->get_field_id('show_names');
60
  $name = $this->get_field_name('show_names');
61
+ $fields = sprintf('<input type="checkbox" class="checkbox" id="%s" name="%s"%s /> <label for="%s">%s</label><br />',
62
  $id, $name, $instance['show_names'] ? 'checked="checked"' : '', $id, __('Display language names', 'polylang'));
63
 
64
  // flags checkbox
65
  $id = $this->get_field_id('show_flags');
66
  $name = $this->get_field_name('show_flags');
67
+ $fields .= sprintf('<input type="checkbox" class="checkbox" id="%s" name="%s"%s /> <label for="%s">%s</label><br />',
68
  $id, $name, $instance['show_flags'] ? 'checked="checked"' : '', $id, __('Display flags', 'polylang'));
69
 
70
  // dropdown checkbox
71
  $id = $this->get_field_id('dropdown');
72
  $name = $this->get_field_name('dropdown');
73
+ $fields .= sprintf('<input type="checkbox" class="checkbox" id="%s" name="%s"%s /> <label for="%s">%s</label><br />',
74
  $id, $name, $instance['dropdown'] ? 'checked="checked"' : '', $id, __('Display as dropdown', 'polylang'));
75
 
76
+ echo $title.'<p>'.$fields.'</p>';
77
  }
78
 
79
  } // Class Polylang_Widget
languages/polylang-de_DE.mo CHANGED
Binary file
languages/polylang-de_DE.po CHANGED
@@ -2,7 +2,7 @@ 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"
@@ -18,13 +18,12 @@ msgstr ""
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
 
@@ -41,64 +40,64 @@ msgstr "Zeigen die Sprachenliste"
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
 
@@ -110,25 +109,25 @@ msgstr "Sprache für die Seite :"
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
 
@@ -229,22 +228,29 @@ msgstr "/language/ in Permalinks entfernen. Zum Beispiel :"
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 :"
@@ -252,6 +258,4 @@ msgstr "ID für die Artikel"
252
  #~ msgstr "durch den Browser Einstellung definiert"
253
  #~ msgid "otherwise: "
254
  #~ msgstr "sonst :"
255
- #~ msgid "Title:"
256
- #~ msgstr "Titre :"
257
 
2
  msgstr ""
3
  "Project-Id-Version: polylang\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-11-14 21:57+0100\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: F. Demarle\n"
8
  "Language-Team: \n"
18
  "X-Poedit-SearchPath-1: ../include\n"
19
 
20
  #: ../include/edit-term-form.php:6
21
+ #: ../include/admin.php:348
22
+ #: ../include/admin.php:502
23
+ #: ../include/term-translations.php:14
24
  #: ../include/add-term-form.php:3
25
  #: ../include/list-table.php:12
26
+ #: ../include/post-translations.php:4
 
27
  msgid "Language"
28
  msgstr "Sprache"
29
 
40
  msgid "Language Switcher"
41
  msgstr "Sprachenliste"
42
 
43
+ #: ../include/widget.php:50
44
  msgid "Display language names"
45
  msgstr "Zeigen die Sprachen Namen"
46
 
47
+ #: ../include/widget.php:56
48
  msgid "Display flags"
49
  msgstr "Zeigen Flaggen"
50
 
51
+ #: ../include/widget.php:62
52
  msgid "Display as dropdown"
53
  msgstr "Als Auswahlbox darstellen"
54
 
55
+ #: ../include/admin.php:90
56
  msgid "Settings"
57
  msgstr "Einstellungen"
58
 
59
+ #: ../include/admin.php:97
60
+ #: ../include/admin.php:392
61
  #: ../include/list-table.php:13
62
  #: ../include/languages-form.php:14
63
  msgid "Languages"
64
  msgstr "Sprachen"
65
 
66
+ #: ../include/admin.php:309
67
  #, fuzzy
68
  msgid "Enter a valid WorPress locale"
69
  msgstr "Das WordPress Locale ist ungültig"
70
 
71
+ #: ../include/admin.php:310
72
  msgid "The language code must be 2 characters long"
73
  msgstr "Der Sprachcode muss 2 Buchstaben lang sein"
74
 
75
+ #: ../include/admin.php:311
76
  msgid "The language code must be unique"
77
  msgstr "Eine andere Sprache hat dem selben Sprachcode"
78
 
79
+ #: ../include/admin.php:312
80
  msgid "The language must have a name"
81
  msgstr "Die Sprache muss einen Namen haben"
82
 
83
+ #: ../include/admin.php:380
84
  msgid "Show all languages"
85
  msgstr "Zeigen alle Sprachen"
86
 
87
+ #: ../include/admin.php:607
88
  msgid "Theme locations and languages"
89
  msgstr "Anordnung im Theme und Sprachen"
90
 
91
+ #: ../include/admin.php:612
92
  #, php-format
93
  msgid "Please go to the %slanguages page%s to set theme locations and languages"
94
  msgstr "Du solltest zu der %sSprachen Seite%s gehen, um Anordnung im Theme und Sprachen zu definieren."
95
 
96
+ #: ../include/admin.php:624
97
  msgid "The widget is displayed for:"
98
  msgstr "Zeigen das Widget für :"
99
 
100
+ #: ../include/admin.php:627
101
  msgid "All languages"
102
  msgstr "Alle Sprachen"
103
 
109
  msgid "Post's language:"
110
  msgstr "Sprache für die Artikel :"
111
 
112
+ #: ../include/term-translations.php:5
113
+ #: ../include/term-translations.php:9
114
  msgid "Translations"
115
  msgstr "Übersetzungen"
116
 
117
+ #: ../include/term-translations.php:14
118
  msgid "Translation"
119
  msgstr "Übersetzung"
120
 
121
+ #: ../include/term-translations.php:14
122
+ #: ../include/term-translations.php:75
123
  #: ../include/list-table.php:32
124
+ #: ../include/post-translations.php:6
125
+ #: ../include/post-translations.php:28
126
  msgid "Edit"
127
  msgstr "Bearbeiten"
128
 
129
+ #: ../include/term-translations.php:61
130
+ #: ../include/post-translations.php:33
131
  msgid "Add new"
132
  msgstr "Hinzufügen"
133
 
228
  msgid "Hide URL language information for default language"
229
  msgstr "URL Informationen für die Standardsprache verstecken"
230
 
231
+ #: ../include/post-translations.php:1
232
  msgid "ID of pages in other languages:"
233
  msgstr "ID für die Seiten in andere Sprache :"
234
 
235
+ #: ../include/post-translations.php:1
236
  msgid "ID of posts in other languages:"
237
  msgstr "ID für die Artikel in andere Sprache :"
238
 
239
+ #: ../include/post-translations.php:5
240
  msgid "Page ID"
241
  msgstr "ID für die Seite"
242
 
243
+ #: ../include/post-translations.php:5
244
  msgid "Post ID"
245
  msgstr "ID für die Artikel"
246
 
247
+ #: ../include/personal-options.php:3
248
+ msgid "Admin language"
249
+ msgstr "Adminsprache"
250
+
251
+ #~ msgid "Title:"
252
+ #~ msgstr "Titre :"
253
+
254
  #, fuzzy
255
  #~ msgid "The front page default language is : "
256
  #~ msgstr "Die Sprache für die Startseite ist :"
258
  #~ msgstr "durch den Browser Einstellung definiert"
259
  #~ msgid "otherwise: "
260
  #~ msgstr "sonst :"
 
 
261
 
languages/polylang-fr_FR.mo CHANGED
Binary file
languages/polylang-fr_FR.po CHANGED
@@ -2,7 +2,7 @@ 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"
@@ -18,13 +18,12 @@ msgstr ""
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
 
@@ -41,63 +40,63 @@ msgstr "Affiche la liste des langues "
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
 
@@ -109,25 +108,25 @@ msgstr "Langue de la page"
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
 
@@ -226,28 +225,32 @@ msgstr "Supprime /language/ dans les permaliens. Exemple :"
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
 
2
  msgstr ""
3
  "Project-Id-Version: polylang\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-11-14 21:57+0100\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: F. Demarle\n"
8
  "Language-Team: \n"
18
  "X-Poedit-SearchPath-1: ../include\n"
19
 
20
  #: ../include/edit-term-form.php:6
21
+ #: ../include/admin.php:348
22
+ #: ../include/admin.php:502
23
+ #: ../include/term-translations.php:14
24
  #: ../include/add-term-form.php:3
25
  #: ../include/list-table.php:12
26
+ #: ../include/post-translations.php:4
 
27
  msgid "Language"
28
  msgstr "Langue"
29
 
40
  msgid "Language Switcher"
41
  msgstr "Liste des langues"
42
 
43
+ #: ../include/widget.php:50
44
  msgid "Display language names"
45
  msgstr "Afficher le nom des langues "
46
 
47
+ #: ../include/widget.php:56
48
  msgid "Display flags"
49
  msgstr "Afficher les drapeaux"
50
 
51
+ #: ../include/widget.php:62
52
  msgid "Display as dropdown"
53
  msgstr "Afficher comme liste déroulante"
54
 
55
+ #: ../include/admin.php:90
56
  msgid "Settings"
57
  msgstr "Réglages"
58
 
59
+ #: ../include/admin.php:97
60
+ #: ../include/admin.php:392
61
  #: ../include/list-table.php:13
62
  #: ../include/languages-form.php:14
63
  msgid "Languages"
64
  msgstr "Langues"
65
 
66
+ #: ../include/admin.php:309
67
  msgid "Enter a valid WorPress locale"
68
  msgstr "Entrez un code local WordPress valide"
69
 
70
+ #: ../include/admin.php:310
71
  msgid "The language code must be 2 characters long"
72
  msgstr "Le code de la langue doit avoir 2 lettres"
73
 
74
+ #: ../include/admin.php:311
75
  msgid "The language code must be unique"
76
  msgstr "Le code de la langue doit être unique"
77
 
78
+ #: ../include/admin.php:312
79
  msgid "The language must have a name"
80
  msgstr "La langue doit avoir un nom"
81
 
82
+ #: ../include/admin.php:380
83
  msgid "Show all languages"
84
  msgstr "Afficher toutes les langues"
85
 
86
+ #: ../include/admin.php:607
87
  msgid "Theme locations and languages"
88
  msgstr "Emplacements du thème et langues"
89
 
90
+ #: ../include/admin.php:612
91
  #, php-format
92
  msgid "Please go to the %slanguages page%s to set theme locations and languages"
93
  msgstr "Aller à la %spage langues%s pour définir les emplacements du thème et les langues "
94
 
95
+ #: ../include/admin.php:624
96
  msgid "The widget is displayed for:"
97
  msgstr "Afficher le widget pour :"
98
 
99
+ #: ../include/admin.php:627
100
  msgid "All languages"
101
  msgstr "Toutes les langues"
102
 
108
  msgid "Post's language:"
109
  msgstr "Langue de l'article"
110
 
111
+ #: ../include/term-translations.php:5
112
+ #: ../include/term-translations.php:9
113
  msgid "Translations"
114
  msgstr "Traductions"
115
 
116
+ #: ../include/term-translations.php:14
117
  msgid "Translation"
118
  msgstr "Traduction"
119
 
120
+ #: ../include/term-translations.php:14
121
+ #: ../include/term-translations.php:75
122
  #: ../include/list-table.php:32
123
+ #: ../include/post-translations.php:6
124
+ #: ../include/post-translations.php:28
125
  msgid "Edit"
126
  msgstr "Modifier"
127
 
128
+ #: ../include/term-translations.php:61
129
+ #: ../include/post-translations.php:33
130
  msgid "Add new"
131
  msgstr "Ajouter"
132
 
225
  msgid "Hide URL language information for default language"
226
  msgstr "Cacher l'information de langue dans l'URL pour la langue par défaut"
227
 
228
+ #: ../include/post-translations.php:1
229
  msgid "ID of pages in other languages:"
230
  msgstr "ID des pages dans les autres langues"
231
 
232
+ #: ../include/post-translations.php:1
233
  msgid "ID of posts in other languages:"
234
  msgstr "ID des articles dans les autres langues"
235
 
236
+ #: ../include/post-translations.php:5
237
  msgid "Page ID"
238
  msgstr "ID de la page"
239
 
240
+ #: ../include/post-translations.php:5
241
  msgid "Post ID"
242
  msgstr "ID de l'article"
243
 
244
+ #: ../include/personal-options.php:3
245
+ msgid "Admin language"
246
+ msgstr "Langue pour l'interface d'administration"
247
+
248
+ #~ msgid "Title:"
249
+ #~ msgstr "Titre :"
250
  #~ msgid "The front page default language is : "
251
  #~ msgstr "La langue par défaut de la page d'accueil est :"
252
  #~ msgid "set by the browser preference"
253
  #~ msgstr "définie par les préférences du navigateur"
254
  #~ msgid "otherwise: "
255
  #~ msgstr "sinon :"
 
 
256
 
languages/polylang.pot CHANGED
@@ -2,7 +2,7 @@ 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"
@@ -18,13 +18,12 @@ msgstr ""
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
 
@@ -41,63 +40,63 @@ msgstr ""
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
 
@@ -109,25 +108,25 @@ msgstr ""
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
 
@@ -226,22 +225,26 @@ msgstr ""
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
 
2
  msgstr ""
3
  "Project-Id-Version: polylang\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-11-14 21:57+0100\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: F. Demarle\n"
8
  "Language-Team: \n"
18
  "X-Poedit-SearchPath-1: ../include\n"
19
 
20
  #: ../include/edit-term-form.php:6
21
+ #: ../include/admin.php:348
22
+ #: ../include/admin.php:502
23
+ #: ../include/term-translations.php:14
24
  #: ../include/add-term-form.php:3
25
  #: ../include/list-table.php:12
26
+ #: ../include/post-translations.php:4
 
27
  msgid "Language"
28
  msgstr ""
29
 
40
  msgid "Language Switcher"
41
  msgstr ""
42
 
43
+ #: ../include/widget.php:50
44
  msgid "Display language names"
45
  msgstr ""
46
 
47
+ #: ../include/widget.php:56
48
  msgid "Display flags"
49
  msgstr ""
50
 
51
+ #: ../include/widget.php:62
52
  msgid "Display as dropdown"
53
  msgstr ""
54
 
55
+ #: ../include/admin.php:90
56
  msgid "Settings"
57
  msgstr ""
58
 
59
+ #: ../include/admin.php:97
60
+ #: ../include/admin.php:392
61
  #: ../include/list-table.php:13
62
  #: ../include/languages-form.php:14
63
  msgid "Languages"
64
  msgstr ""
65
 
66
+ #: ../include/admin.php:309
67
  msgid "Enter a valid WorPress locale"
68
  msgstr ""
69
 
70
+ #: ../include/admin.php:310
71
  msgid "The language code must be 2 characters long"
72
  msgstr ""
73
 
74
+ #: ../include/admin.php:311
75
  msgid "The language code must be unique"
76
  msgstr ""
77
 
78
+ #: ../include/admin.php:312
79
  msgid "The language must have a name"
80
  msgstr ""
81
 
82
+ #: ../include/admin.php:380
83
  msgid "Show all languages"
84
  msgstr ""
85
 
86
+ #: ../include/admin.php:607
87
  msgid "Theme locations and languages"
88
  msgstr ""
89
 
90
+ #: ../include/admin.php:612
91
  #, php-format
92
  msgid "Please go to the %slanguages page%s to set theme locations and languages"
93
  msgstr ""
94
 
95
+ #: ../include/admin.php:624
96
  msgid "The widget is displayed for:"
97
  msgstr ""
98
 
99
+ #: ../include/admin.php:627
100
  msgid "All languages"
101
  msgstr ""
102
 
108
  msgid "Post's language:"
109
  msgstr ""
110
 
111
+ #: ../include/term-translations.php:5
112
+ #: ../include/term-translations.php:9
113
  msgid "Translations"
114
  msgstr ""
115
 
116
+ #: ../include/term-translations.php:14
117
  msgid "Translation"
118
  msgstr ""
119
 
120
+ #: ../include/term-translations.php:14
121
+ #: ../include/term-translations.php:75
122
  #: ../include/list-table.php:32
123
+ #: ../include/post-translations.php:6
124
+ #: ../include/post-translations.php:28
125
  msgid "Edit"
126
  msgstr ""
127
 
128
+ #: ../include/term-translations.php:61
129
+ #: ../include/post-translations.php:33
130
  msgid "Add new"
131
  msgstr ""
132
 
225
  msgid "Hide URL language information for default language"
226
  msgstr ""
227
 
228
+ #: ../include/post-translations.php:1
229
  msgid "ID of pages in other languages:"
230
  msgstr ""
231
 
232
+ #: ../include/post-translations.php:1
233
  msgid "ID of posts in other languages:"
234
  msgstr ""
235
 
236
+ #: ../include/post-translations.php:5
237
  msgid "Page ID"
238
  msgstr ""
239
 
240
+ #: ../include/post-translations.php:5
241
  msgid "Post ID"
242
  msgstr ""
243
 
244
+ #: ../include/personal-options.php:3
245
+ msgid "Admin language"
246
+ msgstr ""
247
+
248
  #~ msgid "Title:"
249
  #~ msgstr "Titre :"
250
 
polylang.php CHANGED
@@ -2,7 +2,7 @@
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
  */
@@ -28,6 +28,8 @@ define('POLYLANG_VERSION', '0.4');
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');
@@ -263,7 +265,7 @@ class Polylang extends Polylang_Base {
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))
@@ -364,12 +366,13 @@ class Polylang extends Polylang_Base {
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
  }
@@ -395,7 +398,7 @@ class Polylang extends Polylang_Base {
395
  if ($this->curlang = $this->get_current_language())
396
  setcookie('wordpress_polylang', $this->curlang->slug, time() + 31536000 /* 1 year */, COOKIEPATH, COOKIE_DOMAIN);
397
 
398
- // our override_load_textdomain has done its job. let's remove it before calling load_textdomain
399
  remove_filter('override_load_textdomain', array(&$this, 'mofile'));
400
 
401
  // now we can load text domains with the right language
@@ -487,7 +490,7 @@ class Polylang extends Polylang_Base {
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
 
@@ -644,7 +647,7 @@ class Polylang extends Polylang_Base {
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;
@@ -652,7 +655,7 @@ class Polylang extends Polylang_Base {
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
@@ -753,35 +756,38 @@ class Polylang extends Polylang_Base {
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
  }
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://wordpress.org/extend/plugins/polylang/
5
+ Version: 0.4.1
6
  Author: F. Demarle
7
  Description: Adds multilingual capability to Wordpress
8
  */
28
  define('POLYLANG_DIR', dirname(__FILE__));
29
  define('INC_DIR', POLYLANG_DIR.'/include');
30
 
31
+ require_once(ABSPATH . 'wp-admin/includes/template.php'); // to ensure that 'get_current_screen' is defined
32
+
33
  require_once(INC_DIR.'/base.php');
34
  require_once(INC_DIR.'/admin.php');
35
  require_once(INC_DIR.'/widget.php');
265
  }
266
 
267
  if (is_admin()) {
268
+ $screen = get_current_screen(); // since WP 3.1
269
 
270
  // NOTE: $screen is not defined in the tag cloud of the Edit Post panel ($pagenow set to admin-ajax.php)
271
  if (isset($screen))
366
 
367
  elseif (is_single() || is_page() && $var = get_queried_object_id())
368
  $lang = $this->get_post_language($var);
 
 
 
369
 
370
+ else {
371
+ foreach (get_taxonomies(array('show_ui'=>true)) as $taxonomy) {
372
+ if ($var = get_query_var(get_taxonomy($taxonomy)->query_var))
373
+ $lang = $this->get_term_language($var, $taxonomy);
374
+ }
375
+ }
376
 
377
  return (isset($lang)) ? $lang : NULL;
378
  }
398
  if ($this->curlang = $this->get_current_language())
399
  setcookie('wordpress_polylang', $this->curlang->slug, time() + 31536000 /* 1 year */, COOKIEPATH, COOKIE_DOMAIN);
400
 
401
+ // our override_load_textdomain filter has done its job. let's remove it before calling load_textdomain
402
  remove_filter('override_load_textdomain', array(&$this, 'mofile'));
403
 
404
  // now we can load text domains with the right language
490
  // outputs references to translated pages (if exists) in the html head section
491
  foreach ($this->get_languages_list() as $language) {
492
  if ($language->slug != $this->curlang->slug && $url = $this->get_translation_url($language))
493
+ printf("<link hreflang='%s' href='%s' rel='alternate' />\n", esc_attr($language->slug), esc_url($url));
494
  }
495
  }
496
 
647
  get_option('home') :
648
  _get_page_link($id);
649
 
650
+ elseif ( !is_tax ('language') && (is_category() || is_tag() || is_tax () ) ) {
651
  $term = get_queried_object();
652
  $lang = $this->get_term_language($term->term_id);
653
  $taxonomy = $term->taxonomy;
655
  if ($language->slug == $lang->slug)
656
  $url = get_term_link($term, $taxonomy); // self link
657
  elseif ($link_id = $this->get_translated_term($term->term_id, $language))
658
+ $url = get_term_link(get_term($link_id, $taxonomy), $taxonomy);
659
  }
660
 
661
  // don't test if there are existing translations before creating the url as it would be very expensive in sql queries
756
  'show_flags' => 0, // don't show flags
757
  'hide_if_empty' => 1 // hides languages with no posts (or pages)
758
  );
 
759
  extract(wp_parse_args($args, $defaults));
760
 
761
  $listlanguages = $this->get_languages_list($hide_if_empty);
762
  $output = $dropdown ? '<select name="lang_choice" id="lang_choice">' : "<ul>\n";
763
+
764
  foreach ($listlanguages as $language) {
765
+ if ($dropdown) {
766
+ $output .= sprintf(
767
+ "<option value='%s'%s>%s</option>\n",
768
+ esc_attr($language->slug),
769
+ $language->slug == $this->curlang->slug ? ' selected="selected"' : '',
770
+ esc_attr($language->name) // FIXME flag does not work for the dropdown list
771
+ );
772
+ }
773
+ else {
774
+ $url = $this->get_translation_url($language);
775
+ $url = isset($url) ? $url : $this->get_home_url($language); // if the page is not translated, link to the home page
776
 
777
+ $class = 'lang-item lang-item-'.esc_attr($language->term_id);
778
+ $class .= $language->slug == $this->curlang->slug ? ' current-lang' : '';
 
779
 
780
+ $flag = $show_flags && (
781
+ file_exists(POLYLANG_DIR.($file = '/local_flags/'.$language->description.'.png')) ||
782
+ file_exists(POLYLANG_DIR.($file = '/flags/'.$language->description.'.png')) ) ?
783
+ '<img src="'.esc_url(WP_PLUGIN_URL.'/polylang'.$file).'" alt="'.esc_attr($language->name).'" />' : '';
784
 
785
+ $name = $show_names || !$show_flags ? esc_attr($language->name) : '';
786
+
787
+ $output .= '<li class="'.$class.'"><a href="'.esc_url($url).'">'.($show_flags && $show_names ? $flag.'&nbsp;'.$name : $flag.$name)."</a></li>\n";
788
+ }
789
+ }
790
 
 
 
 
 
 
 
 
 
 
791
  $output .= $dropdown ? '</select>' : "</ul>\n";
792
  echo $output;
793
  }
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.4
7
 
8
  Adds multilingual support to WordPress.
9
 
@@ -106,7 +106,13 @@ You can look at the following forum topics:
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
@@ -126,9 +132,7 @@ You can look at the following forum topics:
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
134
  * Bug correction: language pages use the archive template
@@ -136,26 +140,20 @@ release: November 10th, 2011
136
  * Bug correction: "Add new" translation for pages creates a post instead of a page
137
  * Bug correction: the search query does not look into pages
138
 
139
- release: October 20th, 2011
140
-
141
- = 0.3.1 =
142
 
143
  * Bug correction: the widget settings cannot be saved when activating Polylang
144
  * Bug correction: the archives widget does not display any links
145
  * Bug correction: ajax form for translations not working in the 'Categories' and 'Post tags' admin panels
146
 
147
- release: October 16th, 2011
148
-
149
- = 0.3 =
150
 
151
  * Add language filter for widgets
152
  * Improved performance for filtering pages by language
153
  * Improved security
154
  * Minor bug correction with versions management
155
 
156
- release: October 7th, 2011
157
-
158
- = 0.2 =
159
 
160
  * Add language filter for nav menus
161
  * Add German translation
@@ -165,9 +163,5 @@ release: October 7th, 2011
165
  * Improved performance for filtering terms by language
166
  * Bugs correction
167
 
168
- release: October 5th, 2011
169
-
170
- = 0.1 =
171
  * Initial release
172
-
173
- release: September 22nd, 2011
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.1
7
 
8
  Adds multilingual support to WordPress.
9
 
106
 
107
  == Changelog ==
108
 
109
+ = 0.4.1 =
110
+
111
+ * Bug correction: flags shows even when you set doesn't to show
112
+ * Bug correction: custom taxonomies do not work
113
+ * Bug correction: some users get the fatal error: call to undefined function wp_get_current_user() in /wp-includes/user.php on line 227
114
+
115
+ = 0.4 (2011-11-10) =
116
 
117
  * Add a documentation (in English only)
118
  * Add the possibility to hide the url language information for the default language
132
  * Bug correction: the widget filter does not allow to come back to 'all languages' once a language has been set
133
  * Other minor bug corrections
134
 
135
+ = 0.3.2 (2011-10-20) =
 
 
136
 
137
  * Bug correction: authors pages are not filtered by language
138
  * Bug correction: language pages use the archive template
140
  * Bug correction: "Add new" translation for pages creates a post instead of a page
141
  * Bug correction: the search query does not look into pages
142
 
143
+ = 0.3.1 (2011-10-16) =
 
 
144
 
145
  * Bug correction: the widget settings cannot be saved when activating Polylang
146
  * Bug correction: the archives widget does not display any links
147
  * Bug correction: ajax form for translations not working in the 'Categories' and 'Post tags' admin panels
148
 
149
+ = 0.3 (2011-10-07) =
 
 
150
 
151
  * Add language filter for widgets
152
  * Improved performance for filtering pages by language
153
  * Improved security
154
  * Minor bug correction with versions management
155
 
156
+ = 0.2 (2011-10-05) =
 
 
157
 
158
  * Add language filter for nav menus
159
  * Add German translation
163
  * Improved performance for filtering terms by language
164
  * Bugs correction
165
 
166
+ = 0.1 (2011-09-22) =
 
 
167
  * Initial release