Polylang - Version 0.5

Version Description

(2011-12-07) =

  • Add multisite support
  • Rework the Polylang admin panel. There is now a set of predefined languages
  • Improve categories and tags language filter in the edit post panel
  • Categories and tags created in the edit post panel are now created with the same language as the post
  • The language switcher can now force the link to the front page instead of the translated page
  • The nav menus can now display a language switcher
  • Improved performance
  • Optimized the calendar widget (less code and sql queries executed)
  • Added the possibility to display posts and terms with no language set (see the documentation to know how to enable this functionnality)
  • Started the creation of a small API for theme and plugin programmers
  • Bug correction: When using a static front page, the page for posts does not work when using the default permalink settings
  • Bug correction: The search form does not work if a static front page is used
  • Bug correction: Quick edit breaks translations
  • Bug correction: Categories and post tags translations don't work for more than 2 languages
  • Bug correction: The output of wp_page_menu is not correct for non default languages
Download this release

Release Info

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

Code changes from version 0.4.4 to 0.5

Files changed (70) hide show
  1. doc/documentation-en.odt +0 -0
  2. doc/documentation-en.pdf +0 -0
  3. flags/ar.png +0 -0
  4. flags/bg_BG.png +0 -0
  5. flags/bs_BA.png +0 -0
  6. flags/ca.png +0 -0
  7. flags/cz_CZ.png +0 -0
  8. flags/da_DK.png +0 -0
  9. flags/el.png +0 -0
  10. flags/en_US.png +0 -0
  11. flags/eo.png +0 -0
  12. flags/es_ES.png +0 -0
  13. flags/et.png +0 -0
  14. flags/fa_IR.png +0 -0
  15. flags/fi.png +0 -0
  16. flags/fy.png +0 -0
  17. flags/gl_ES.png +0 -0
  18. flags/he_IL.png +0 -0
  19. flags/hr.png +0 -0
  20. flags/hu_HU.png +0 -0
  21. flags/id_ID.png +0 -0
  22. flags/it_IT.png +0 -0
  23. flags/ja.png +0 -0
  24. flags/ko_KR.png +0 -0
  25. flags/lv.png +0 -0
  26. flags/mk_MK.png +0 -0
  27. flags/my_MM.png +0 -0
  28. flags/nb_NO.png +0 -0
  29. flags/nl_NL.png +0 -0
  30. flags/pl_PL.png +0 -0
  31. flags/pt_PT.png +0 -0
  32. flags/si_LK.png +0 -0
  33. flags/sk_SK.png +0 -0
  34. flags/sl_SI.png +0 -0
  35. flags/sq.png +0 -0
  36. flags/sr_RS.png +0 -0
  37. flags/sv_SE.png +0 -0
  38. flags/th.png +0 -0
  39. flags/tr_TR.png +0 -0
  40. flags/ug_CN.png +0 -0
  41. flags/uk.png +0 -0
  42. flags/zh_CN.png +0 -0
  43. include/add-term-form.php +8 -7
  44. include/admin-filters.php +451 -0
  45. include/admin.php +133 -484
  46. include/api.php +27 -0
  47. include/base.php +66 -13
  48. include/calendar.php +221 -175
  49. include/core.php +707 -0
  50. include/edit-term-form.php +6 -5
  51. include/languages-form.php +214 -202
  52. include/languages.php +47 -0
  53. include/list-table.php +4 -1
  54. include/personal-options.php +4 -2
  55. include/post-metabox.php +10 -10
  56. include/post-translations.php +7 -8
  57. include/term-translations.php +20 -16
  58. include/widget.php +24 -34
  59. js/admin.js +105 -24
  60. languages/polylang-de_DE.mo +0 -0
  61. languages/polylang-de_DE.po +201 -183
  62. languages/polylang-fr_FR.mo +0 -0
  63. languages/polylang-fr_FR.po +202 -184
  64. languages/polylang-ru_RU.mo +0 -0
  65. languages/polylang-ru_RU.po +200 -179
  66. languages/polylang.pot +111 -95
  67. polylang.php +106 -639
  68. readme.txt +46 -24
  69. screenshot-1.png +0 -0
  70. uninstall.php +61 -32
doc/documentation-en.odt CHANGED
Binary file
doc/documentation-en.pdf CHANGED
Binary file
flags/ar.png ADDED
Binary file
flags/bg_BG.png ADDED
Binary file
flags/bs_BA.png ADDED
Binary file
flags/ca.png ADDED
Binary file
flags/cz_CZ.png ADDED
Binary file
flags/da_DK.png ADDED
Binary file
flags/el.png ADDED
Binary file
flags/en_US.png CHANGED
Binary file
flags/eo.png ADDED
Binary file
flags/es_ES.png ADDED
Binary file
flags/et.png ADDED
Binary file
flags/fa_IR.png ADDED
Binary file
flags/fi.png ADDED
Binary file
flags/fy.png ADDED
Binary file
flags/gl_ES.png ADDED
Binary file
flags/he_IL.png ADDED
Binary file
flags/hr.png ADDED
Binary file
flags/hu_HU.png ADDED
Binary file
flags/id_ID.png ADDED
Binary file
flags/it_IT.png ADDED
Binary file
flags/ja.png ADDED
Binary file
flags/ko_KR.png ADDED
Binary file
flags/lv.png ADDED
Binary file
flags/mk_MK.png ADDED
Binary file
flags/my_MM.png ADDED
Binary file
flags/nb_NO.png ADDED
Binary file
flags/nl_NL.png ADDED
Binary file
flags/pl_PL.png ADDED
Binary file
flags/pt_PT.png ADDED
Binary file
flags/si_LK.png ADDED
Binary file
flags/sk_SK.png ADDED
Binary file
flags/sl_SI.png ADDED
Binary file
flags/sq.png ADDED
Binary file
flags/sr_RS.png ADDED
Binary file
flags/sv_SE.png ADDED
Binary file
flags/th.png ADDED
Binary file
flags/tr_TR.png ADDED
Binary file
flags/ug_CN.png ADDED
Binary file
flags/uk.png ADDED
Binary file
flags/zh_CN.png ADDED
Binary file
include/add-term-form.php CHANGED
@@ -1,16 +1,17 @@
1
- <?php // adds a language select list in the Categories and Post tags admin panels ?>
 
 
2
  <div class="form-field">
3
  <label for="term_lang_choice"><?php _e('Language', 'polylang');?></label>
4
- <select name="term_lang_choice" id="term_lang_choice">
5
- <option value="0"></option><?php
 
6
  foreach ($listlanguages as $language) {
7
- printf("<option value='%s'%s>%s</option>\n", esc_attr($language->term_id), $language == $lang ? ' selected="selected"' : '', esc_attr($language->name));
8
  } ?>
9
  </select>
10
  <p><?php _e('Sets the language', 'polylang');?></p>
11
  </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>
1
+ <?php
2
+ // adds a language select list in the Categories and Post tags admin panels
3
+ ?>
4
  <div class="form-field">
5
  <label for="term_lang_choice"><?php _e('Language', 'polylang');?></label>
6
+ <select name="term_lang_choice" id="term_lang_choice"><?php
7
+ if (PLL_DISPLAY_ALL) // for those who want undefined language
8
+ echo '<option value="0"></option>';
9
  foreach ($listlanguages as $language) {
10
+ printf("<option value='%d'%s>%s</option>\n", esc_attr($language->term_id), $language == $lang ? ' selected="selected"' : '', esc_html($language->name));
11
  } ?>
12
  </select>
13
  <p><?php _e('Sets the language', 'polylang');?></p>
14
  </div>
15
  <div id="term-translations" class="form-field"><?php
16
+ include(PLL_INC.'/term-translations.php'); // adds translation fields ?>
 
 
17
  </div>
include/admin-filters.php ADDED
@@ -0,0 +1,451 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // all modifications of the WordPress admin ui
4
+ class Polylang_Admin_Filters extends Polylang_Base {
5
+ function __construct() {
6
+ // additionnal filters and actions
7
+ add_action('admin_init', array(&$this, 'admin_init'));
8
+
9
+ // setup js scripts andd css styles
10
+ add_action('admin_print_scripts', array(&$this,'admin_js'));
11
+ add_action('admin_print_styles', array(&$this,'admin_css'));
12
+
13
+ // add the language column (as well as a filter by language) in 'All Posts' an 'All Pages' panels
14
+ add_filter('manage_posts_columns', array(&$this, 'add_post_column'), 10, 2);
15
+ add_filter('manage_pages_columns', array(&$this, 'add_post_column'));
16
+ add_action('manage_posts_custom_column', array(&$this, 'post_column'), 10, 2);
17
+ add_action('manage_pages_custom_column', array(&$this, 'post_column'), 10, 2);
18
+ add_filter('parse_query',array(&$this,'parse_query'));
19
+ add_action('restrict_manage_posts', array(&$this, 'restrict_manage_posts'));
20
+
21
+ // adds the Languages box in the 'Edit Post' and 'Edit Page' panels
22
+ add_action('add_meta_boxes', array(&$this, 'add_meta_boxes'));
23
+
24
+ // ajax response for changing the language in the post metabox
25
+ add_action('wp_ajax_post_lang_choice', array(&$this,'post_lang_choice'));
26
+
27
+ // adds actions related to languages when saving or deleting posts and pages
28
+ add_action('save_post', array(&$this, 'save_post'));
29
+ add_action('before_delete_post', array(&$this, 'delete_post'));
30
+
31
+ // filters categories and post tags by language
32
+ add_filter('terms_clauses', array(&$this, 'terms_clauses'), 10, 3);
33
+
34
+ // ajax response for edit term form
35
+ add_action('wp_ajax_term_lang_choice', array(&$this,'term_lang_choice'));
36
+
37
+ // modifies the theme location nav menu metabox
38
+ add_filter('admin_head-nav-menus.php', array(&$this, 'nav_menu_theme_locations'));
39
+
40
+ // widgets languages filter
41
+ add_action('in_widget_form', array(&$this, 'in_widget_form'));
42
+ add_filter('widget_update_callback', array(&$this, 'widget_update_callback'), 10, 4);
43
+
44
+ // language management for users
45
+ add_filter('locale', array(&$this, 'get_locale'));
46
+ add_action('personal_options_update', array(&$this, 'personal_options_update'));
47
+ add_action('personal_options', array(&$this, 'personal_options'));
48
+
49
+ // refresh rewrite rules if the 'page_on_front' option is modified
50
+ add_action('update_option', array(&$this, 'update_option'));
51
+ }
52
+
53
+ // add these actions and filters here and not in the constructor to be sure that all taxonomies are registered
54
+ function admin_init() {
55
+ foreach (get_taxonomies(array('show_ui'=>true)) as $tax) {
56
+ // adds the language field in the 'Categories' and 'Post Tags' panels
57
+ add_action($tax.'_add_form_fields', array(&$this, 'add_term_form'));
58
+
59
+ // adds the language field and translations tables in the 'Edit Category' and 'Edit Tag' panels
60
+ add_action($tax.'_edit_form_fields', array(&$this, 'edit_term_form'));
61
+
62
+ // adds the language column in the 'Categories' and 'Post Tags' tables
63
+ add_filter('manage_edit-'.$tax.'_columns', array(&$this, 'add_term_column'));
64
+ add_action('manage_'.$tax.'_custom_column', array(&$this, 'term_column'), 10, 3);
65
+
66
+ // adds actions related to languages when saving or deleting categories and post tags
67
+ add_action('created_'.$tax, array(&$this, 'save_term'));
68
+ add_action('edited_'.$tax, array(&$this, 'save_term'));
69
+ add_action('delete_'.$tax, array(&$this, 'delete_term'));
70
+ }
71
+ }
72
+
73
+ // setup js scripts
74
+ function admin_js() {
75
+ wp_enqueue_script('polylang_admin', WP_PLUGIN_URL .'/polylang/js/admin.js');
76
+ }
77
+
78
+ // setup css styles
79
+ function admin_css() {
80
+ wp_enqueue_style('polylang_admin', WP_PLUGIN_URL .'/polylang/css/admin.css');
81
+ }
82
+
83
+ // adds the language column (before the date column) in the posts and pages list table
84
+ function add_post_column($columns, $post_type ='') {
85
+ if ($post_type == '' || get_post_type_object($post_type)->show_ui) {
86
+ foreach (array( 'date', 'comments' ) as $k) {
87
+ if (array_key_exists($k, $columns))
88
+ $end[$k] = array_pop($columns);
89
+ }
90
+
91
+ $columns['language'] = __('Language', 'polylang');
92
+
93
+ if (isset($end))
94
+ $columns = array_merge($columns, $end);
95
+ }
96
+ return $columns;
97
+ }
98
+
99
+ // fills the language column in the posts table
100
+ function post_column($column, $post_id) {
101
+ if ($column == 'language' && $lang = $this->get_post_language($post_id))
102
+ echo esc_html($lang->name);
103
+ }
104
+
105
+ // converts language term_id to slug in $query
106
+ // needed to filter the posts by language with wp_dropdown_categories in restrict_manage_posts
107
+ function parse_query($query) {
108
+ global $pagenow;
109
+ $qvars = &$query->query_vars;
110
+ if ($pagenow=='edit.php' && isset($qvars['lang']) && $qvars['lang'] && is_numeric($qvars['lang']) && $lang = $this->get_language($qvars['lang']))
111
+ $qvars['lang'] = $lang->slug;
112
+ }
113
+
114
+ // adds a filter for languages in the Posts and Pages panels
115
+ function restrict_manage_posts() {
116
+ global $wp_query;
117
+ $screen = get_current_screen(); // since WP 3.1
118
+ $languages = $this->get_languages_list();
119
+
120
+ if (!empty($languages) && $screen->base == 'edit') {
121
+ $qvars = $wp_query->query;
122
+ wp_dropdown_categories(array(
123
+ 'show_option_all' => __('Show all languages', 'polylang'),
124
+ 'name' => 'lang',
125
+ 'selected' => isset($qvars['lang']) ? $qvars['lang'] : 0,
126
+ 'taxonomy' => 'language',
127
+ 'hide_empty' => 0
128
+ ));
129
+ }
130
+ }
131
+
132
+ // adds the Languages box in the 'Edit Post' and 'Edit Page' panels (as well as in custom post types panels
133
+ function add_meta_boxes() {
134
+ foreach(get_post_types( array( 'show_ui' => true ) ) as $ptype)
135
+ add_meta_box('ml_box', __('Languages','polylang'), array(&$this,'post_language'), $ptype, 'side','high');
136
+ }
137
+
138
+ // the Languages metabox in the 'Edit Post' and 'Edit Page' panels
139
+ function post_language() {
140
+ global $post_ID;
141
+ $post_type = get_post_type($post_ID);
142
+
143
+ $lang = $this->get_post_language($post_ID);
144
+ if (isset($_GET['new_lang']))
145
+ $lang = $this->get_language($_GET['new_lang']);
146
+
147
+ if (!isset($lang)) {
148
+ $options = get_option('polylang');
149
+ $lang = $this->get_language($options['default_lang']);
150
+ }
151
+
152
+ $listlanguages = $this->get_languages_list();
153
+
154
+ include(PLL_INC.'/post-metabox.php');
155
+ }
156
+
157
+ // ajax response for changing the language in the post metabox
158
+ function post_lang_choice() {
159
+ global $post_ID; // obliged to use the global variable for wp_popular_terms_checklist
160
+ $post_ID = $_POST['post_id'];
161
+ $post_type = get_post_type($post_ID);
162
+ $listlanguages = $this->get_languages_list();
163
+ $lang = $this->get_language($_POST['lang']);
164
+
165
+ ob_start();
166
+ if ($lang && !is_wp_error($lang))
167
+ include(PLL_INC.'/post-translations.php');
168
+ $x = new WP_Ajax_Response(array('what' => 'translations', 'data' => ob_get_contents()));
169
+ ob_end_clean();
170
+
171
+ if (isset($_POST['taxonomies'])) {
172
+ // not set for pages
173
+ foreach ($_POST['taxonomies'] as $taxname) {
174
+ $taxonomy = get_taxonomy($taxname);
175
+
176
+ ob_start();
177
+ $popular_ids = wp_popular_terms_checklist($taxonomy->name);
178
+ $supplemental['populars'] = ob_get_contents();
179
+ ob_end_clean();
180
+
181
+ ob_start();
182
+ // use $post_ID to remember ckecked terms in case we come back to the original language
183
+ wp_terms_checklist( $post_ID, array( 'taxonomy' => $taxonomy->name, 'popular_cats' => $popular_ids ));
184
+ $supplemental['all'] = ob_get_contents();
185
+ ob_end_clean();
186
+
187
+ ob_start();
188
+ wp_dropdown_categories( array(
189
+ 'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name',
190
+ 'hierarchical' => 1, 'show_option_none' => '&mdash; '.$taxonomy->labels->parent_item.' &mdash;'
191
+ ) );
192
+ $supplemental['dropdown'] = ob_get_contents();
193
+ ob_end_clean();
194
+
195
+ $x->Add(array('what' => 'taxonomy', 'data' => $taxonomy->name, 'supplemental' => $supplemental));
196
+ }
197
+ }
198
+
199
+ $x->send();
200
+ }
201
+
202
+ // saves translations for posts or terms
203
+ // the underscore in '_lang' hides the post meta in the Custom Fields metabox in the Edit Post screen
204
+ function save_translations($type, $id) {
205
+ $lang = call_user_func(array(&$this, 'get_'.$type.'_language'), $id);
206
+ if (!$lang)
207
+ return;
208
+
209
+ if (isset($_POST['tr_lang']) && is_array($_POST['tr_lang'])) {
210
+ $tr = serialize(array_merge(array($lang->slug => $id), $_POST['tr_lang']));
211
+ update_metadata($type, $id, '_translations', $tr);
212
+
213
+ foreach($_POST['tr_lang'] as $key=>$p)
214
+ update_metadata($type, $p, '_translations', $tr);
215
+ }
216
+ }
217
+
218
+ // called when a post (or page) is saved, published or updated
219
+ function save_post($post_id) {
220
+ // avoids breaking translations when using inline or bulk edit
221
+ if(isset($_POST['_inline_edit']) || isset($_GET['bulk_edit']))
222
+ return;
223
+
224
+ if ($id = wp_is_post_revision($post_id))
225
+ $post_id = $id;
226
+
227
+ if (isset($_POST['post_lang_choice']))
228
+ wp_set_post_terms($post_id, $_POST['post_lang_choice'], 'language' );
229
+
230
+ $this->save_translations('post', $post_id);
231
+ }
232
+
233
+ // called when a post (or page) is deleted
234
+ function delete_post($post_id) {
235
+ if ($id = wp_is_post_revision($post_id))
236
+ $post_id = $id;
237
+
238
+ $this->delete_translation('post', $post_id);
239
+ }
240
+
241
+ // filters categories and post tags by language when needed
242
+ function terms_clauses($clauses, $taxonomies, $args) {
243
+ // does nothing except on taxonomies which have show_ui set to 1 (includes category and post_tags)
244
+ foreach ($taxonomies as $tax) {
245
+ if(!get_taxonomy($tax)->show_ui)
246
+ return $clauses;
247
+ }
248
+
249
+ if (function_exists('get_current_screen'))
250
+ $screen = get_current_screen(); // since WP 3.1, may not be available the first time(s) get_terms is called
251
+
252
+ // does nothing in the Categories, Post tags, Languages and Posts* admin panels
253
+ // I test $_POST['action'] for ajax since $screen not defined in this case
254
+ // FIXME Can I improve the way I do that ?
255
+ if (!isset($_POST['action']) && (!isset($screen) || $screen->base == 'edit-tags' || $screen->base == 'toplevel_page_mlang' || $screen->base == 'edit'))
256
+ return $clauses;
257
+
258
+ // *FIXME I want all categories in the dropdown list and only the ones in the right language in the inline edit
259
+ // It seems that I need javascript to get the post_id as inline edit data are manipulated in inline-edit-post.js
260
+
261
+ global $post_ID;
262
+ $options = get_option('polylang');
263
+
264
+ // ajax response for changing the language in the post metabox
265
+ if (isset($_POST['lang']))
266
+ $lang = $this->get_language($_POST['lang']);
267
+
268
+ // the post is created with the 'add new' (translation) link
269
+ elseif (isset($_GET['new_lang']))
270
+ $lang = $this->get_language($_GET['new_lang']);
271
+
272
+ elseif (isset($_GET['post']))
273
+ $lang = $this->get_post_language($_GET['post']);
274
+
275
+ // when a new category is created in the edit post panel
276
+ elseif (isset($_POST['term_lang_choice']))
277
+ $lang = $this->get_language($_POST['term_lang_choice']);
278
+
279
+ // for a new post
280
+ elseif ($screen->base == 'post' && !PLL_DISPLAY_ALL)
281
+ $lang = $this->get_language($options['default_lang']);
282
+
283
+ // adds our clauses to filter by current language
284
+ return isset($lang) ? $this->_terms_clauses($clauses, $lang) : $clauses;
285
+ }
286
+
287
+ // adds the language field in the 'Categories' and 'Post Tags' panels
288
+ function add_term_form() {
289
+ $taxonomy = $_GET['taxonomy'];
290
+
291
+ if (isset($_GET['new_lang']))
292
+ $lang = $this->get_language($_GET['new_lang']);
293
+ else {
294
+ $options = get_option('polylang');
295
+ $lang = $this->get_language($options['default_lang']);
296
+ }
297
+
298
+ $listlanguages = $this->get_languages_list();
299
+
300
+ // displays the language field
301
+ include(PLL_INC.'/add-term-form.php');
302
+ }
303
+
304
+ // adds the language field and translations tables in the 'Edit Category' and 'Edit Tag' panels
305
+ function edit_term_form($tag) {
306
+ $term_id = $tag->term_id;
307
+ $lang = $this->get_term_language($term_id);
308
+ $taxonomy = $tag->taxonomy;
309
+ $listlanguages = $this->get_languages_list();
310
+
311
+ include(PLL_INC.'/edit-term-form.php');
312
+ }
313
+
314
+ // adds the language column (before the posts column) in the 'Categories' or Post Tags table
315
+ function add_term_column($columns) {
316
+ if (array_key_exists('posts', $columns))
317
+ $end = array_pop($columns);
318
+
319
+ $columns['language'] = __('Language', 'polylang');
320
+
321
+ if (isset($end))
322
+ $columns['posts'] = $end;
323
+
324
+ return $columns;
325
+ }
326
+
327
+ // fills the language column in the 'Categories' or Post Tags table
328
+ function term_column($empty, $column, $term_id) {
329
+ if ($column == 'language' && $lang = $this->get_term_language($term_id))
330
+ echo esc_html($lang->name);
331
+ }
332
+
333
+ // called when a category or post tag is created or edited
334
+ function save_term($term_id) {
335
+ // avoids breaking translations when using inline edit
336
+ if(isset($_POST['_inline_edit']))
337
+ return;
338
+
339
+ if (isset($_POST['term_lang_choice']) && $_POST['term_lang_choice'])
340
+ $this->update_term_language($term_id, $_POST['term_lang_choice']);
341
+ else
342
+ $this->delete_term_language($term_id);
343
+
344
+ $this->save_translations('term', $term_id);
345
+ }
346
+
347
+ // called when a category or post tag is deleted
348
+ function delete_term($term_id) {
349
+ $this->delete_term_language($term_id);
350
+ $this->delete_translation('term', $term_id);
351
+ }
352
+
353
+ // returns all terms in the $taxonomy in the $term_language which have no translation in the $translation_language
354
+ function get_terms_not_translated($taxonomy, $term_language, $translation_language) {
355
+ $new_terms = array();
356
+ foreach (get_terms($taxonomy, 'hide_empty=0') as $term) {
357
+ $lang = $this->get_term_language($term->term_id);
358
+ if ($lang && $lang->name == $term_language->name && !$this->get_translation('term', $term->term_id, $translation_language))
359
+ $new_terms[] = $term;
360
+ }
361
+ return $new_terms;
362
+ }
363
+
364
+ // ajax response for edit term form
365
+ function term_lang_choice()
366
+ {
367
+ if ($_POST['lang']) {
368
+ $lang = $this->get_language($_POST['lang']);
369
+ $term_id = isset($_POST['term_id']) ? $_POST['term_id'] : null;
370
+ $taxonomy = $_POST['taxonomy'];
371
+
372
+ $listlanguages = $this->get_languages_list();
373
+
374
+ include(PLL_INC.'/term-translations.php');
375
+ }
376
+ die();
377
+ }
378
+
379
+ // modifies the theme location nav menu metabox
380
+ // thanks to: http://wordpress.stackexchange.com/questions/2770/how-to-add-a-custom-metabox-to-the-menu-management-admin-screen
381
+ function nav_menu_theme_locations() {
382
+ // only if the theme supports nav menus and a nav menu exists
383
+ if ( ! current_theme_supports( 'menus' ) || ! $metabox = &$GLOBALS['wp_meta_boxes']['nav-menus']['side']['default']['nav-menu-theme-locations'] )
384
+ return;
385
+
386
+ $metabox['callback'] = array(&$this,'nav_menu_language');
387
+ $metabox['title'] = __('Theme locations and languages', 'polylang');
388
+ }
389
+
390
+ // displays a message to redirect to the languages options page
391
+ function nav_menu_language() {
392
+ echo '<p class="howto">' . sprintf (__('Please go to the %slanguages page%s to set theme locations and languages', 'polylang'),
393
+ '<a href="' . esc_url(admin_url('options-general.php?page=mlang&tab=menus')) . '">', '</a>') . '</p>';
394
+ }
395
+
396
+ // modifies the widgets forms to add our language dropdwown list
397
+ function in_widget_form($widget) {
398
+ $widget_lang = get_option('polylang_widgets');
399
+
400
+ printf(
401
+ '<p><label for="%1$s">%2$s<select name="%1$s" id="%1$s" class="tags-input"><option value="0">%3$s</option>',
402
+ esc_attr($widget->id.'_lang_choice'),
403
+ __('The widget is displayed for:', 'polylang'),
404
+ __('All languages', 'polylang')
405
+ );
406
+ foreach ($this->get_languages_list() as $language) {
407
+ printf(
408
+ "<option value='%s'%s>%s</option>\n",
409
+ esc_attr($language->slug),
410
+ isset($widget_lang[$widget->id]) && $language->slug == $widget_lang[$widget->id] ? ' selected="selected"' : '',
411
+ esc_html($language->name)
412
+ );
413
+ }
414
+ echo '</select></label></p>';
415
+ }
416
+
417
+ // called when widget options are saved
418
+ function widget_update_callback($instance, $new_instance, $old_instance, $widget) {
419
+ $widget_lang = get_option('polylang_widgets');
420
+ $widget_lang[$widget->id] = $_POST[$widget->id.'_lang_choice'];
421
+ update_option('polylang_widgets', $widget_lang);
422
+ return $instance;
423
+ }
424
+
425
+ // returns the locale based on user preference
426
+ function get_locale($locale) {
427
+ // get_current_user_id uses wp_get_current_user which may not be available the first time(s) get_locale is called
428
+ if (function_exists('wp_get_current_user'))
429
+ $loc = get_user_meta(get_current_user_id(), 'user_lang', 'true');
430
+ return isset($loc) && $loc ? $loc : $locale;
431
+ }
432
+
433
+ // updates language user preference
434
+ function personal_options_update($user_id) {
435
+ update_user_meta($user_id, 'user_lang', $_POST['user_lang']);
436
+ }
437
+
438
+ // form for language user preference
439
+ function personal_options($profileuser) {
440
+ include(PLL_INC.'/personal-options.php');
441
+ }
442
+
443
+ // refresh rewrite rules if the 'page_on_front' option is modified
444
+ function update_option($option) {
445
+ global $wp_rewrite;
446
+ if ($option == 'page_on_front')
447
+ $wp_rewrite->flush_rules();
448
+ }
449
+ }
450
+
451
+ ?>
include/admin.php CHANGED
@@ -1,10 +1,12 @@
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';
@@ -12,77 +14,6 @@ class Polylang_Admin extends Polylang_Base {
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'));
30
-
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
-
44
- // widgets languages filter
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 that 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 (version_compare($options['version'], POLYLANG_VERSION, '<')) {
79
-
80
- if(version_compare($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
 
88
  // adds a 'settings' link in the plugins table
@@ -94,17 +25,32 @@ class Polylang_Admin extends Polylang_Base {
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
@@ -149,33 +95,22 @@ class Polylang_Admin extends Polylang_Base {
149
  $lang = $this->get_language($lang_id);
150
  $lang_slug = $lang->slug;
151
 
152
- // delete all translations in posts in this language
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);
164
- foreach ($posts as $post) {
165
- delete_post_meta($post->ID, '_lang-'.$lang_slug);
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
176
- }
177
- delete_metadata('term', $term->term_id, '_lang-'.$lang_slug); // deletes references to this term in translated term
178
  }
 
179
 
180
  // delete the language itself
181
  wp_delete_term($lang_id, 'language');
@@ -201,7 +136,7 @@ class Polylang_Admin extends Polylang_Base {
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
 
@@ -211,22 +146,27 @@ class Polylang_Admin extends Polylang_Base {
211
 
212
  if ($old_slug != $_POST['slug']) {
213
  // update the language slug in posts meta
214
- $args = array('numberposts'=>-1, 'meta_key'=>'_lang-'.$old_slug, 'post_type'=>'any', 'post_status'=>'any');
215
- $posts = get_posts($args);
216
- foreach ($posts as $post) {
217
- $post_id = get_post_meta($post->ID, '_lang-'.$old_slug, true);
218
- delete_post_meta($post->ID, '_lang-'.$old_slug);
219
- update_post_meta($post->ID, '_lang-'.$_POST['slug'], $post_id);
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
@@ -242,6 +182,10 @@ class Polylang_Admin extends Polylang_Base {
242
  check_admin_referer( 'nav-menus-lang', '_wpnonce_nav-menus-lang' );
243
 
244
  $menu_lang = $_POST['menu-lang'];
 
 
 
 
245
  update_option('polylang_nav_menus', $menu_lang);
246
  break;
247
 
@@ -266,54 +210,90 @@ class Polylang_Admin extends Polylang_Base {
266
  }
267
  }
268
  if(isset($_POST['terms'])) {
269
- $lang_id = $this->get_language($options['default_lang'])->term_id; // slug is stored in the option and I want the id for the meta
270
  foreach(explode(',', $_POST['terms']) as $term_id) {
271
- update_metadata('term', $term_id, '_language', $lang_id );
272
  }
273
  }
274
  }
275
  break;
276
 
277
  default:
 
278
  }
279
 
280
- // prepare the list table of languages
281
- $data = array();
282
- foreach ($listlanguages as $lang)
283
- $data[] = (array) $lang;
284
-
285
- $list_table->prepare_items($data);
286
-
287
-
288
- // detects posts & pages without language set
289
- $q = array(
290
- 'numberposts'=>-1,
291
- 'post_type' => 'any',
292
- 'post_status'=>'any',
293
- 'fields' => 'ids',
294
- 'tax_query' => array(array(
295
- 'taxonomy'=> 'language',
296
- 'terms'=> get_terms('language', array('fields'=>'ids')),
297
- 'operator'=>'NOT IN'
298
- ))
299
  );
300
- $posts = implode(',', get_posts($q));
 
301
 
302
- // detects categories & post tags without language set
303
- $terms = get_terms(get_taxonomies(array('show_ui'=>true)), array('get'=>'all', 'fields'=>'ids'));
304
- foreach ($terms as $key => $term_id) {
305
- if (get_metadata('term', $term_id, '_language'))
306
- unset($terms[$key]);
307
- }
308
- $terms = implode(',', $terms);
 
 
 
 
 
 
 
 
 
309
 
310
- $errors[1] = __('Enter a valid WorPress locale', 'polylang');
311
- $errors[2] = __('The language code must be 2 characters long', 'polylang');
312
- $errors[3] = __('The language code must be unique', 'polylang');
313
- $errors[4] = __('The language must have a name', 'polylang');
 
 
 
 
 
314
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  // displays the page
316
- include(INC_DIR.'/languages-form.php');
317
  }
318
 
319
  // validates data entered when creating or updating a language
@@ -338,337 +318,6 @@ class Polylang_Admin extends Polylang_Base {
338
  return isset($error) ? $error : 0;
339
  }
340
 
341
- // adds the language column (before the date column) in the posts and pages list table
342
- function add_post_column($columns, $post_type ='') {
343
- if ($post_type == '' || get_post_type_object($post_type)->show_ui) {
344
- foreach (array( 'date', 'comments' ) as $k) {
345
- if (array_key_exists($k, $columns))
346
- $end[$k] = array_pop($columns);
347
- }
348
-
349
- $columns['language'] = __('Language', 'polylang');
350
-
351
- if (isset($end))
352
- $columns = array_merge($columns, $end);
353
- }
354
- return $columns;
355
- }
356
-
357
- // fills the language column in the posts table
358
- function post_column($column, $post_id) {
359
- if ($column == 'language' && $lang = $this->get_post_language($post_id))
360
- echo esc_attr($lang->name);
361
- }
362
-
363
- // converts language term_id to slug in $query
364
- // needed to filter the posts by language with wp_dropdown_categories in restrict_manage_posts
365
- function parse_query($query) {
366
- global $pagenow;
367
- $qvars = &$query->query_vars;
368
- if ($pagenow=='edit.php' && isset($qvars['lang']) && $qvars['lang'] && is_numeric($qvars['lang']) && $lang = $this->get_language($qvars['lang']))
369
- $qvars['lang'] = $lang->slug;
370
- }
371
-
372
- // adds a filter for languages in the Posts and Pages panels
373
- function restrict_manage_posts() {
374
- global $wp_query;
375
- $screen = get_current_screen(); // since WP 3.1
376
- $languages = $this->get_languages_list();
377
-
378
- if (!empty($languages) && $screen->base == 'edit') {
379
- $qvars = $wp_query->query;
380
- wp_dropdown_categories(array(
381
- 'show_option_all' => __('Show all languages', 'polylang'),
382
- 'name' => 'lang',
383
- 'selected' => isset($qvars['lang']) ? $qvars['lang'] : 0,
384
- 'taxonomy' => 'language',
385
- 'hide_empty' => 0
386
- ));
387
- }
388
- }
389
-
390
- // adds the Languages box in the 'Edit Post' and 'Edit Page' panels (as well as in custom post types panels
391
- function add_meta_boxes() {
392
- foreach(get_post_types( array( 'show_ui' => true ) ) as $ptype)
393
- add_meta_box('ml_box', __('Languages','polylang'), array(&$this,'post_language'), $ptype, 'side','high');
394
- }
395
-
396
- // the Languages metabox in the 'Edit Post' and 'Edit Page' panels
397
- function post_language() {
398
- global $post_ID;
399
- $post_type = get_post_type($post_ID);
400
-
401
- $lang = $this->get_post_language($post_ID);
402
- if (isset($_GET['new_lang']))
403
- $lang = $this->get_language($_GET['new_lang']);
404
-
405
- $listlanguages = $this->get_languages_list();
406
-
407
- include(INC_DIR.'/post-metabox.php');
408
- }
409
-
410
- // ajax response for post metabox
411
- function post_lang_choice() {
412
- $listlanguages = $this->get_languages_list();
413
-
414
- $lang = $this->get_language($_POST['lang']);
415
- $post_ID = $_POST['post_id'];
416
- $post_type = get_post_type($post_ID);
417
-
418
- if ($lang && !is_wp_error($lang))
419
- include(INC_DIR.'/post-translations.php');
420
-
421
- die();
422
- }
423
-
424
- // called when a post (or page) is saved, published or updated
425
- // the underscore in '_lang' hides the post meta in the Custom Fields metabox in the Edit Post screen
426
- function save_post($post_id) {
427
- if ($id = wp_is_post_revision($post_id))
428
- $post_id = $id;
429
-
430
- if (isset($_POST['post_lang_choice']))
431
- wp_set_post_terms($post_id, $_POST['post_lang_choice'], 'language' );
432
-
433
- $lang = $this->get_post_language($post_id);
434
- $listlanguages = $this->get_languages_list();
435
-
436
- foreach ($listlanguages as $language) {
437
-
438
- if (isset($_POST[$language->slug]) && $_POST[$language->slug]) {
439
- // FIXME I don't check that the translated post is in the right language !
440
- update_post_meta($post_id, '_lang-'.$language->slug, $_POST[$language->slug]); // saves the links to translated posts
441
- if ($lang)
442
- update_post_meta($this->get_translated_post($post_id, $language), '_lang-'.$lang->slug, $post_id); // tells the translated to link to this post
443
- }
444
- else {
445
- // deletes the translation in case there was previously one
446
- if ($lang)
447
- delete_post_meta($this->get_translated_post($post_id, $language), '_lang-'.$lang->slug); // in the translated post
448
-
449
- delete_post_meta($post_id, '_lang-'.$language->slug); // in this post
450
- }
451
- }
452
-
453
- // propagates translations between them
454
- foreach ($listlanguages as $language) {
455
- foreach ($listlanguages as $lg) {
456
- if ($lg != $lang && $lg != $language && $id = $this->get_translated_post($post_id, $lg))
457
- update_post_meta($this->get_translated_post($post_id, $language), '_lang-'.$lg->slug, $id);
458
- }
459
- }
460
- }
461
-
462
- // called when a post (or page) is deleted
463
- function delete_post($post_id) {
464
- if ($id = wp_is_post_revision($post_id))
465
- $post_id = $id;
466
-
467
- if($lang = $this->get_post_language($post_id)) {
468
- foreach ($this->get_languages_list() as $language) {
469
- delete_post_meta($this->get_translated_post($post_id, $language), '_lang-'.$lang->slug); // delete links to this post
470
- // WP deletes post metas linked to this post so it is useless to do it before
471
- }
472
- }
473
- }
474
-
475
- // adds the language field in the 'Categories' and 'Post Tags' panels
476
- function add_term_form() {
477
- $taxonomy = $_GET['taxonomy'];
478
- $lang = null;
479
- if (isset($_GET['new_lang']))
480
- $lang = $this->get_language($_GET['new_lang']);
481
-
482
- $listlanguages = $this->get_languages_list();
483
-
484
- // displays the language field
485
- include(INC_DIR.'/add-term-form.php');
486
- }
487
-
488
- // adds the language field and translations tables in the 'Edit Category' and 'Edit Tag' panels
489
- function edit_term_form($tag) {
490
- $term_id = $tag->term_id;
491
- $lang = $this->get_term_language($term_id);
492
- $taxonomy = $tag->taxonomy;
493
- $listlanguages = $this->get_languages_list();
494
-
495
- include(INC_DIR.'/edit-term-form.php');
496
- }
497
-
498
- // adds the language column (before the posts column) in the 'Categories' or Post Tags table
499
- function add_term_column($columns) {
500
- if (array_key_exists('posts', $columns))
501
- $end = array_pop($columns);
502
-
503
- $columns['language'] = __('Language', 'polylang');
504
-
505
- if (isset($end))
506
- $columns['posts'] = $end;
507
-
508
- return $columns;
509
- }
510
-
511
- // fills the language column in the 'Categories' or Post Tags table
512
- function term_column($empty, $column, $term_id) {
513
- if ($column == 'language' && $lang = $this->get_term_language($term_id))
514
- echo esc_attr($lang->name);
515
- }
516
-
517
-
518
- // called when a category or post tag is created or edited
519
- function save_term($term_id) {
520
-
521
- if (isset($_POST['term_lang_choice']) && $_POST['term_lang_choice'])
522
- update_metadata('term', $term_id, '_language', $_POST['term_lang_choice'] );
523
- else
524
- delete_metadata('term', $term_id, '_language');
525
-
526
-
527
- $lang = $this->get_term_language($term_id);
528
- $listlanguages = $this->get_languages_list();
529
-
530
- foreach ($listlanguages as $language) {
531
- $slug = '_lang-'.$language->slug;
532
- if (isset($_POST[$slug]) && $_POST[$slug]) {
533
- // FIXME I don't check that the translated term is in the right language !
534
- update_metadata('term', $term_id, $slug, $_POST[$slug] );
535
- if ($lang)
536
- update_metadata('term', $_POST[$slug], '_lang-'.$lang->slug, $term_id );
537
- }
538
- else {
539
- // deletes the translation in case there was previously one
540
- if ($lang)
541
- delete_metadata('term', $this->get_translated_term($term_id, $language), '_lang-'.$lang->slug); // in the translated term
542
- delete_metadata('term', $term_id, '_lang-'.$language->slug); // in this term
543
- }
544
-
545
- }
546
-
547
- // propagates translations between them
548
- if (isset($lang)) {
549
- foreach ($listlanguages as $language) {
550
- foreach ($listlanguages as $lg) {
551
- if ($lg != $lang && $lg != $language && $id = $this->get_translated_term($term_id, $lg))
552
- update_metadata('term',$this->get_translated_term($term_id, $language), '_lang-'.$lg->slug, $id);
553
- }
554
- }
555
- }
556
-
557
- }
558
-
559
- // called when a category or post tag is deleted
560
- function delete_term($term_id) {
561
- if($lang = $this->get_term_language($term_id)) {
562
- delete_metadata('term', $term_id, '_language' );
563
- $listlanguages = $this->get_languages_list();
564
- foreach ($listlanguages as $language) {
565
- delete_metadata('term', $this->get_translated_term($term_id, $language), '_lang-'.$lang->slug); // delete links to this term
566
- }
567
- foreach ($listlanguages as $language) {
568
- delete_metadata('term', $term_id, '_lang-'.$language->slug);
569
- }
570
- }
571
- }
572
-
573
- // returns all terms in the $taxonomy in the $term_language which have no translation in the $translation_language
574
- function get_terms_not_translated($taxonomy, $term_language, $translation_language) {
575
- $new_terms = array();
576
- foreach (get_terms($taxonomy, 'hide_empty=0') as $term) {
577
- $lang = $this->get_term_language($term->term_id);
578
- if ($lang && $lang->name == $term_language->name && !$this->get_translated_term($term->term_id, $translation_language))
579
- $new_terms[] = $term;
580
- }
581
- return $new_terms;
582
- }
583
-
584
- // ajax response for edit term form
585
- function term_lang_choice()
586
- {
587
- if ($_POST['lang']) {
588
- $lang = $this->get_language($_POST['lang']);
589
- $term_id = isset($_POST['term_id']) ? $_POST['term_id'] : null;
590
- $taxonomy = $_POST['taxonomy'];
591
-
592
- $listlanguages = $this->get_languages_list();
593
-
594
- include(INC_DIR.'/term-translations.php');
595
- }
596
- die();
597
- }
598
-
599
- // modifies the theme location nav menu metabox
600
- // thanks to: http://wordpress.stackexchange.com/questions/2770/how-to-add-a-custom-metabox-to-the-menu-management-admin-screen
601
- function nav_menu_theme_locations() {
602
- // only if the theme supports nav menus and a nav menu exists
603
- if ( ! current_theme_supports( 'menus' ) || ! $metabox = &$GLOBALS['wp_meta_boxes']['nav-menus']['side']['default']['nav-menu-theme-locations'] )
604
- return;
605
-
606
- $metabox['callback'] = array(&$this,'nav_menu_language');
607
- $metabox['title'] = __('Theme locations and languages', 'polylang');
608
- }
609
-
610
- // displays a message to redirect to the languages options page
611
- function nav_menu_language() {
612
- echo '<p class="howto">' . sprintf (__('Please go to the %slanguages page%s to set theme locations and languages', 'polylang'),
613
- '<a href="' . admin_url('options-general.php?page=mlang#menus') . '">', '</a>') . '</p>';
614
- }
615
-
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
- }
637
- echo '</select></label></p>';
638
- }
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
- // get_current_user_id uses wp_get_current_user which may not be available the first time(s) get_locale is called
651
- if (function_exists('wp_get_current_user'))
652
- $loc = get_user_meta(get_current_user_id(), 'user_lang', 'true');
653
- return isset($loc) && $loc ? $loc : $locale;
654
- }
655
-
656
- // updates language user preference
657
- function personal_options_update($user_id) {
658
- update_user_meta($user_id, 'user_lang', $_POST['user_lang']);
659
- }
660
-
661
- // form for language user preference
662
- function personal_options($profileuser) {
663
- include(INC_DIR.'/personal-options.php');
664
- }
665
-
666
- // refresh rewrite rules if the 'page_on_front' option is modified
667
- function update_option($option) {
668
- global $wp_rewrite;
669
- if ($option == 'page_on_front')
670
- $wp_rewrite->flush_rules();
671
- }
672
  } // class Polylang_Admin
673
 
674
  ?>
1
  <?php
2
 
3
+ require_once(PLL_INC.'/list-table.php');
4
+ require_once(PLL_INC.'/admin-filters.php');
5
 
6
+ // setups the Polylang admin panel and calls for other admin related classes
7
  class Polylang_Admin extends Polylang_Base {
8
  function __construct() {
9
+ new Polylang_Admin_Filters();
10
 
11
  // adds a 'settings' link in the plugins table
12
  $plugin_file = basename(POLYLANG_DIR).'/polylang.php';
14
 
15
  // adds the link to the languages panel in the wordpress admin menu
16
  add_action('admin_menu', array(&$this, 'add_menus'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
18
 
19
  // adds a 'settings' link in the plugins table
25
 
26
  // adds the link to the languages panel in the wordpress admin menu
27
  function add_menus() {
28
+ add_submenu_page('options-general.php', __('Languages', 'polylang'), __('Languages', 'polylang'), 'manage_options', 'mlang', array(&$this, 'languages_page'));
29
+ }
30
+
31
+ // used to update the translation when a language slug has been modified
32
+ function update_translations($type, $ids, $old_slug) {
33
+ foreach ($ids as $id) {
34
+ $tr = get_metadata($type, $id, '_translations', true);
35
+ if($tr) {
36
+ $tr = unserialize($tr);
37
+ $tr[$_POST['slug']] = $tr[$old_slug];
38
+ unset($tr[$old_slug]);
39
+ update_metadata($type, $id, '_translations', serialize($tr));
40
+ }
41
+ }
42
  }
43
 
44
+ // used to delete the translation when a language is deleted
45
+ function delete_translations($type, $ids, $old_slug) {
46
+ foreach ($ids as $id) {
47
+ $tr = get_metadata($type, $id, '_translations', true);
48
+ if($tr) {
49
+ $tr = unserialize($tr);
50
+ unset($tr[$old_slug]);
51
+ update_metadata($type, $id, '_translations', serialize($tr));
52
+ }
53
+ }
54
  }
55
 
56
  // the languages panel
95
  $lang = $this->get_language($lang_id);
96
  $lang_slug = $lang->slug;
97
 
98
+ // update the language slug in posts meta
99
+ $posts = get_posts(array('numberposts'=>-1, 'fields' => 'ids', 'meta_key'=>'_translations', 'post_type'=>'any', 'post_status'=>'any'));
100
+ $this->delete_translations('post', $posts, $lang_slug);
 
 
 
 
 
101
 
102
+ // update the language slug in categories & post tags meta
103
+ $terms= get_terms(get_taxonomies(array('show_ui'=>true)), array('get'=>'all', 'fields'=>'ids'));
104
+ $this->delete_translations('term', $terms, $lang_slug);
105
+
106
+ foreach ($terms as $id)
107
+ $this->delete_term_language($id); // delete language of this term
108
 
109
+ // delete menus locations
110
+ foreach ($locations as $location => $description) {
111
+ unset($menu_lang[$location][$lang_slug]);
 
 
 
 
 
 
 
112
  }
113
+ update_option('polylang_nav_menus', $menu_lang);
114
 
115
  // delete the language itself
116
  wp_delete_term($lang_id, 'language');
136
 
137
  case 'update':
138
  check_admin_referer( 'add-lang', '_wpnonce_add-lang' );
139
+ $lang_id = (int) $_POST['lang_id'];
140
  $lang = $this->get_language($lang_id);
141
  $error = $this->validate_lang($lang);
142
 
146
 
147
  if ($old_slug != $_POST['slug']) {
148
  // update the language slug in posts meta
149
+ $posts = get_posts(array('numberposts'=>-1, 'fields' => 'ids', 'meta_key'=>'_translations', 'post_type'=>'any', 'post_status'=>'any'));
150
+ $this->update_translations('post', $posts, $old_slug);
 
 
 
 
 
151
 
152
  // update the language slug in categories & post tags meta
153
+ $terms = get_terms(get_taxonomies(array('show_ui'=>true)), array('get'=>'all', 'fields'=>'ids'));
154
+ $this->update_translations('term', $terms, $old_slug);
155
+
156
+ // update menus locations
157
+ foreach ($locations as $location => $description) {
158
+ if (isset($menu_lang[$location][$old_slug])) {
159
+ $menu_lang[$location][$_POST['slug']] = $menu_lang[$location][$old_slug];
160
+ unset($menu_lang[$location][$old_slug]);
161
  }
162
  }
163
+ update_option('polylang_nav_menus', $menu_lang);
164
+
165
+ // update the default language option if necessary
166
+ if ($options['default_lang'] == $old_slug) {
167
+ $options['default_lang'] = $_POST['slug'];
168
+ update_option('polylang', $options);
169
+ }
170
  }
171
 
172
  // and finally update the language itself
182
  check_admin_referer( 'nav-menus-lang', '_wpnonce_nav-menus-lang' );
183
 
184
  $menu_lang = $_POST['menu-lang'];
185
+ foreach ($locations as $location => $description)
186
+ foreach (array('switcher', 'show_names', 'show_flags', 'force_home') as $key)
187
+ $menu_lang[$location][$key] = isset($menu_lang[$location][$key]) ? 1 : 0;
188
+
189
  update_option('polylang_nav_menus', $menu_lang);
190
  break;
191
 
210
  }
211
  }
212
  if(isset($_POST['terms'])) {
 
213
  foreach(explode(',', $_POST['terms']) as $term_id) {
214
+ $this->update_term_language($term_id, $this->get_language($options['default_lang']));
215
  }
216
  }
217
  }
218
  break;
219
 
220
  default:
221
+ break;
222
  }
223
 
224
+ // prepare the list of tabs
225
+ $tabs = array(
226
+ 'lang' => __('Languages','polylang'),
227
+ 'menus' => __('Menus','polylang'),
228
+ 'settings' => __('Settings', 'polylang')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  );
230
+ if (!current_theme_supports( 'menus' ))
231
+ unset($tabs['menus']); // don't display the menu tab if the active them does not support nav menus
232
 
233
+ $active_tab = isset($_GET['tab']) && $_GET['tab'] ? $_GET['tab'] : 'lang';
234
+
235
+ switch($active_tab) {
236
+ case 'lang':
237
+ // prepare the list table of languages
238
+ $data = array();
239
+ foreach ($listlanguages as $lang)
240
+ $data[] = array_merge( (array) $lang, array('flag' => $this->get_flag($lang)) ) ;
241
+
242
+ $list_table->prepare_items($data);
243
+
244
+ $errors[1] = __('Enter a valid WorPress locale', 'polylang');
245
+ $errors[2] = __('The language code must be 2 characters long', 'polylang');
246
+ $errors[3] = __('The language code must be unique', 'polylang');
247
+ $errors[4] = __('The language must have a name', 'polylang');
248
+ break;
249
 
250
+ case 'menus':
251
+ // prepare the list of options for the language switcher
252
+ // FIXME do not include the dropdown yet as I need to create a better script (only available for the widget now)
253
+ $menu_options = array(
254
+ 'switcher' => __('Displays a language switcher at the end of the menu', 'polylang'),
255
+ 'show_names' => __('Displays language names', 'polylang'),
256
+ 'show_flags' => __('Displays flags', 'polylang'),
257
+ 'force_home' => __('Forces link to front page', 'polylang')
258
+ );
259
 
260
+ // default values
261
+ foreach ($locations as $key=>$location)
262
+ $menu_lang[$key] = wp_parse_args($menu_lang[$key], array('switcher'=> 0, 'show_names'=>1, 'show_flags'=>0, 'force_home'=>0));
263
+
264
+ break;
265
+
266
+ case 'settings':
267
+ //FIXME rework this as it would not be efficient in case of thousands posts or terms !
268
+ // detects posts & pages without language set
269
+ $q = array(
270
+ 'numberposts'=>-1,
271
+ 'post_type' => 'any',
272
+ 'post_status'=>'any',
273
+ 'fields' => 'ids',
274
+ 'tax_query' => array(array(
275
+ 'taxonomy'=> 'language',
276
+ 'terms'=> get_terms('language', array('fields'=>'ids')),
277
+ 'operator'=>'NOT IN'
278
+ ))
279
+ );
280
+ $posts = implode(',', get_posts($q));
281
+
282
+ // detects categories & post tags without language set
283
+ $terms = get_terms(get_taxonomies(array('show_ui'=>true)), array('get'=>'all', 'fields'=>'ids'));
284
+
285
+ foreach ($terms as $key => $term_id) {
286
+ if ($this->get_term_language($term_id))
287
+ unset($terms[$key]);
288
+ }
289
+ $terms = implode(',', $terms);
290
+ break;
291
+
292
+ default:
293
+ break;
294
+ }
295
  // displays the page
296
+ include(PLL_INC.'/languages-form.php');
297
  }
298
 
299
  // validates data entered when creating or updating a language
318
  return isset($error) ? $error : 0;
319
  }
320
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  } // class Polylang_Admin
322
 
323
  ?>
include/api.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // template tag: displays the language switcher
4
+ function pll_the_languages($args = '') {
5
+ global $polylang;
6
+ return $polylang->the_languages($args);
7
+ }
8
+
9
+ // among the post and its translations, returns the id of the post which is in the language represented by $slug
10
+ function pll_get_post($post_id, $slug) {
11
+ global $polylang;
12
+ return $polylang->get_post($post_id, $slug);
13
+ }
14
+
15
+ // among the term and its translations, returns the id of the term which is in the language represented by $slug
16
+ function pll_get_term($term_id, $slug) {
17
+ global $polylang;
18
+ return $polylang->get_term($term_id, $slug);
19
+ }
20
+
21
+ // acts as is_front_page but knows about translated front page
22
+ function pll_is_front_page() {
23
+ global $polylang;
24
+ return $polylang->is_front_page();
25
+ }
26
+
27
+ ?>
include/base.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
 
3
- class Polylang_Base {
 
4
 
5
  // returns the query variables of the referer
6
  function get_referer_vars() {
@@ -21,30 +22,60 @@ class Polylang_Base {
21
  }
22
 
23
  // returns the language by its id or its slug
24
- // Note ist seems that the first option is better for performance (3.2.1)
25
  function get_language($value) {
26
  if (is_numeric($value))
27
  return get_term($value, 'language');
28
  elseif (is_string($value))
29
- return get_term_by('slug', $value , 'language');
30
  return null;
31
  }
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  // returns the language of a post
34
  function get_post_language($post_id) {
35
  $lang = get_the_terms($post_id, 'language' );
36
  return ($lang) ? reset($lang) : null; // there's only one language per post : first element of the array returned
37
  }
38
 
39
- // returns the id of the translation of a post
40
- function get_translated_post($post_id, $language) {
41
- return get_post_meta($post_id, '_lang-'.$language->slug, true);
 
42
  }
43
 
44
- // among the post and its translations, returns the id of the post which is in $language
45
- function get_post($post_id, $language) {
46
- $lang = $this->get_post_language($post_id);
47
- return $lang->slug == $language->slug ? $post_id : $this->get_translated_post($post_id, $language);
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
  // returns the language of a term
@@ -56,9 +87,31 @@ class Polylang_Base {
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)
60
- function get_translated_term($term_id, $language) {
61
- return get_metadata('term', $term_id, '_lang-'.$language->slug, true); // since WP 2.9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
63
 
64
  } //class Polylang_Base
1
  <?php
2
 
3
+ // setups basic functions
4
+ abstract class Polylang_Base {
5
 
6
  // returns the query variables of the referer
7
  function get_referer_vars() {
22
  }
23
 
24
  // returns the language by its id or its slug
25
+ // Note: it seems that the first option is better for performance (3.2.1)
26
  function get_language($value) {
27
  if (is_numeric($value))
28
  return get_term($value, 'language');
29
  elseif (is_string($value))
30
+ return get_term_by('slug', $value , 'language'); // seems it is not cached in 3.2.1
31
  return null;
32
  }
33
 
34
+ // deletes a translation of a post or term
35
+ function delete_translation($type, $id) {
36
+ $translations = unserialize(get_metadata($type, $id, '_translations', true));
37
+ if (is_array($translations)) {
38
+ $slug = array_search($id, $translations);
39
+ unset($translations[$slug]);
40
+ $tr = serialize($translations);
41
+ foreach($translations as $key=>$p)
42
+ update_metadata($type, $p, '_translations', $tr);
43
+ delete_metadata($type, $id, '_translations');
44
+ }
45
+ }
46
+
47
+ // returns the id of the translation of a post or term
48
+ function get_translation($type, $id, $lang) {
49
+ $translations = unserialize(get_metadata($type, $id, '_translations', true));
50
+ $slug = is_string($lang) ? $lang : $lang->slug;
51
+ return isset($translations[$slug]) ? $translations[$slug] : '';
52
+ }
53
+
54
  // returns the language of a post
55
  function get_post_language($post_id) {
56
  $lang = get_the_terms($post_id, 'language' );
57
  return ($lang) ? reset($lang) : null; // there's only one language per post : first element of the array returned
58
  }
59
 
60
+ // among the post and its translations, returns the id of the post which is in $lang
61
+ function get_post($post_id, $lang) {
62
+ $slug = is_string($lang) ? $lang : $lang->slug;
63
+ return $this->get_post_language($post_id)->slug == $slug ? $post_id : $this->get_translation('post', $post_id, $lang);
64
  }
65
 
66
+ function update_term_language($term_id, $lang) {
67
+ if (is_numeric($lang))
68
+ $lang_id = $lang;
69
+ elseif(is_string($lang))
70
+ $lang_id = $this->get_language($lang)->term_id;
71
+ else
72
+ $lang_id = $lang->term_id;
73
+
74
+ update_metadata('term', $term_id, '_language', $lang_id );
75
+ }
76
+
77
+ function delete_term_language($term_id) {
78
+ delete_metadata('term', $term_id, '_language');
79
  }
80
 
81
  // returns the language of a term
87
  return $term_id ? $this->get_language(get_metadata('term', $term_id, '_language', true)) : null;
88
  }
89
 
90
+ // among the term and its translations, returns the id of the term which is in $lang
91
+ function get_term($term_id, $lang) {
92
+ $slug = is_string($lang) ? $lang : $lang->slug;
93
+ return $this->get_term_language($term_id)->slug == $slug ? $term_id : $this->get_translation('term', $term_id, $lang);
94
+ }
95
+
96
+ // returns the html link to the flag if exists
97
+ function get_flag($lang) {
98
+ return ( !is_admin() && ( // never use local flags on admin side
99
+ file_exists(POLYLANG_DIR.($file = '/local_flags/'.$lang->description.'.png')) ||
100
+ file_exists(POLYLANG_DIR.($file = '/local_flags/'.$lang->description.'.jpg')) )) ||
101
+ file_exists(POLYLANG_DIR.($file = '/flags/'.$lang->description.'.png')) ?
102
+ '<img src="'.esc_url(WP_PLUGIN_URL.'/polylang'.$file).'" alt="'.esc_attr($lang->name).'" />' : '';
103
+ }
104
+
105
+ // adds terms clauses to get_terms - used in both frontend and admin
106
+ function _terms_clauses($clauses, $lang, $display_all = false) {
107
+ global $wpdb;
108
+ if (isset($lang) && !is_wp_error($lang)) {
109
+ $clauses['join'] .= " LEFT JOIN $wpdb->termmeta AS tm ON t.term_id = tm.term_id";
110
+ $where_lang = $wpdb->prepare("tm.meta_key = '_language' AND tm.meta_value = %d", $lang->term_id); // add terms in the right language
111
+ $where_all = "t.term_id NOT IN (SELECT term_id FROM $wpdb->termmeta WHERE meta_key IN ('_language'))"; // add terms with no language set
112
+ $clauses['where'] .= $display_all ? " AND (($where_lang) OR ($where_all))" : " AND $where_lang";
113
+ }
114
+ return $clauses;
115
  }
116
 
117
  } //class Polylang_Base
include/calendar.php CHANGED
@@ -1,187 +1,233 @@
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
  ?>
1
  <?php
 
2
  // obliged to rewrite the whole WordPress function as there is no filter on sql queries and only a filter on final output
3
+ // a request for making a filter on sql queries exists: http://core.trac.wordpress.org/ticket/15202
4
+ // method used in 0.4.x: use of the get_calendar filter and overwrite the output of get_calendar function -> not very efficient (add 4 to 5 sql queries)
5
+ // since 0.5: remove the WP widget and replace it by our own -> our language filter will not work if get_calendar is called directly by a theme
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
+ if(!class_exists('WP_Widget_Calendar')){
8
+ require_once( ABSPATH . '/wp-includes/default-widgets.php' );
 
 
9
  }
10
 
11
+ class Polylang_Widget_Calendar extends WP_Widget_Calendar {
12
+
13
+ function widget( $args, $instance ) {
14
+ extract($args);
15
+ $title = apply_filters('widget_title', empty($instance['title']) ? '&nbsp;' : $instance['title'], $instance, $this->id_base);
16
+ echo $before_widget;
17
+ if ( $title )
18
+ echo $before_title . $title . $after_title;
19
+ echo '<div id="calendar_wrap">';
20
+ $this->get_calendar(); #modified#
21
+ echo '</div>';
22
+ echo $after_widget;
 
 
 
 
 
 
23
  }
 
 
 
24
 
25
+ // modified version of WP get_calendar function to filter the query
26
+ function get_calendar($initial = true, $echo = true) {
27
+ global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
28
+ global $polylang; #added#
29
+ $lang = $polylang->get_current_language()->term_taxonomy_id; #added#
30
+
31
+ $cache = array();
32
+ $key = md5( $lang . $m . $monthnum . $year ); #modified#
33
+ if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
34
+ if ( is_array($cache) && isset( $cache[ $key ] ) ) {
35
+ if ( $echo ) {
36
+ echo apply_filters( 'get_calendar', $cache[$key] );
37
+ return;
38
+ } else {
39
+ return apply_filters( 'get_calendar', $cache[$key] );
40
+ }
41
+ }
42
+ }
43
+
44
+ if ( !is_array($cache) )
45
+ $cache = array();
46
+
47
+ // Quick check. If we have no posts at all, abort!
48
+ if ( !$posts ) {
49
+ $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
50
+ if ( !$gotsome ) {
51
+ $cache[ $key ] = '';
52
+ wp_cache_set( 'get_calendar', $cache, 'calendar' );
53
+ return;
54
+ }
55
+ }
56
+
57
+ if ( isset($_GET['w']) )
58
+ $w = ''.intval($_GET['w']);
59
+
60
+ // week_begins = 0 stands for Sunday
61
+ $week_begins = intval(get_option('start_of_week'));
62
+
63
+ // Let's figure out when we are
64
+ if ( !empty($monthnum) && !empty($year) ) {
65
+ $thismonth = ''.zeroise(intval($monthnum), 2);
66
+ $thisyear = ''.intval($year);
67
+ } elseif ( !empty($w) ) {
68
+ // We need to get the month from MySQL
69
+ $thisyear = ''.intval(substr($m, 0, 4));
70
+ $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
71
+ $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
72
+ } elseif ( !empty($m) ) {
73
+ $thisyear = ''.intval(substr($m, 0, 4));
74
+ if ( strlen($m) < 6 )
75
+ $thismonth = '01';
76
+ else
77
+ $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
78
+ } else {
79
+ $thisyear = gmdate('Y', current_time('timestamp'));
80
+ $thismonth = gmdate('m', current_time('timestamp'));
81
+ }
82
+
83
+ $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
84
+ $last_day = date('t', $unixmonth);
85
+
86
+ // Get the next and previous month and year with at least one post
87
+ $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
88
+ FROM $wpdb->posts
89
+ INNER JOIN $wpdb->term_relationships AS tr ON tr.object_id = ID
90
+ WHERE post_date < '$thisyear-$thismonth-01'
91
+ AND post_type = 'post' AND post_status = 'publish' AND tr.term_taxonomy_id = $lang
92
+ ORDER BY post_date DESC
93
+ LIMIT 1"); #modified#
94
+ $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
95
+ FROM $wpdb->posts
96
+ INNER JOIN $wpdb->term_relationships AS tr ON tr.object_id = ID
97
+ WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
98
+ AND post_type = 'post' AND post_status = 'publish' AND tr.term_taxonomy_id = $lang
99
+ ORDER BY post_date ASC
100
+ LIMIT 1"); #modified#
101
+
102
+ /* translators: Calendar caption: 1: month name, 2: 4-digit year */
103
+ $calendar_caption = _x('%1$s %2$s', 'calendar caption');
104
+ $calendar_output = '<table id="wp-calendar">
105
+ <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
106
+ <thead>
107
+ <tr>';
108
+
109
+ $myweek = array();
110
+
111
+ for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
112
+ $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
113
+ }
114
+
115
+ foreach ( $myweek as $wd ) {
116
+ $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
117
+ $wd = esc_attr($wd);
118
+ $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
119
+ }
120
+
121
+ $calendar_output .= '
122
+ </tr>
123
+ </thead>
124
+
125
+ <tfoot>
126
+ <tr>';
127
+
128
+ if ( $previous ) {
129
+ $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>';
130
+ } else {
131
+ $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
132
+ }
133
+
134
+ $calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
135
+
136
+ if ( $next ) {
137
+ $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>';
138
+ } else {
139
+ $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
140
+ }
141
+
142
+ $calendar_output .= '
143
+ </tr>
144
+ </tfoot>
145
+
146
+ <tbody>
147
+ <tr>';
148
+
149
+ // Get days with posts
150
+ $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
151
+ FROM $wpdb->posts
152
+ INNER JOIN $wpdb->term_relationships AS tr ON tr.object_id = ID
153
+ WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
154
+ AND post_type = 'post' AND post_status = 'publish' AND tr.term_taxonomy_id = $lang
155
+ AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N); #modified#
156
+ if ( $dayswithposts ) {
157
+ foreach ( (array) $dayswithposts as $daywith ) {
158
+ $daywithpost[] = $daywith[0];
159
+ }
160
+ } else {
161
+ $daywithpost = array();
162
+ }
163
+
164
+ if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
165
+ $ak_title_separator = "\n";
166
  else
167
+ $ak_title_separator = ', ';
168
+
169
+ $ak_titles_for_day = array();
170
+ $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
171
+ ."FROM $wpdb->posts "
172
+ ."INNER JOIN $wpdb->term_relationships AS tr ON tr.object_id = ID "
173
+ ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
174
+ ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
175
+ ."AND post_type = 'post' AND post_status = 'publish' AND tr.term_taxonomy_id = $lang"
176
+ ); #modified#
177
+ if ( $ak_post_titles ) {
178
+ foreach ( (array) $ak_post_titles as $ak_post_title ) {
179
+
180
+ $post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
181
+
182
+ if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
183
+ $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
184
+ if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
185
+ $ak_titles_for_day["$ak_post_title->dom"] = $post_title;
186
+ else
187
+ $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
188
+ }
189
+ }
190
+
191
+ // See how much we should pad in the beginning
192
+ $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
193
+ if ( 0 != $pad )
194
+ $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad">&nbsp;</td>';
195
+
196
+ $daysinmonth = intval(date('t', $unixmonth));
197
+ for ( $day = 1; $day <= $daysinmonth; ++$day ) {
198
+ if ( isset($newrow) && $newrow )
199
+ $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
200
+ $newrow = false;
201
+
202
+ if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
203
+ $calendar_output .= '<td id="today">';
204
+ else
205
+ $calendar_output .= '<td>';
206
+
207
+ if ( in_array($day, $daywithpost) ) // any posts today?
208
+ $calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
209
+ else
210
+ $calendar_output .= $day;
211
+ $calendar_output .= '</td>';
212
+
213
+ if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
214
+ $newrow = true;
215
+ }
216
+
217
+ $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
218
+ if ( $pad != 0 && $pad != 7 )
219
+ $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'">&nbsp;</td>';
220
+
221
+ $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
222
+
223
+ $cache[ $key ] = $calendar_output;
224
+ wp_cache_set( 'get_calendar', $cache, 'calendar' );
225
+
226
+ if ( $echo )
227
+ echo apply_filters( 'get_calendar', $calendar_output );
228
+ else
229
+ return apply_filters( 'get_calendar', $calendar_output );
230
  }
231
  }
232
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  ?>
include/core.php ADDED
@@ -0,0 +1,707 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // filters posts and terms by language, rewrites links to include the language, etc...
3
+ class Polylang_Core extends Polylang_base {
4
+ private $curlang; // current language
5
+ private $default_locale;
6
+ private $list_textdomains = array(); // all text domains
7
+ private $search_form_filter = false; // did we pass our get_search_form filter ?
8
+
9
+ // options often needed
10
+ private $home;
11
+ private $options;
12
+ private $page_for_posts;
13
+ private $page_on_front;
14
+
15
+ function __construct() {
16
+
17
+ // options often needed
18
+ $this->options = get_option('polylang');
19
+ $this->home = get_option('home');
20
+ $this->page_for_posts = get_option('page_for_posts');
21
+ $this->page_on_front = get_option('page_on_front');
22
+
23
+ // text domain management
24
+ add_action('init', array(&$this, 'init'));
25
+ add_filter('locale', array(&$this, 'get_locale'));
26
+ add_filter('override_load_textdomain', array(&$this, 'mofile'), 10, 3);
27
+ add_action('wp', array(&$this, 'load_textdomains'));
28
+
29
+ // filters posts according to the language
30
+ add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
31
+
32
+ // filters categories and post tags by language
33
+ add_filter('terms_clauses', array(&$this, 'terms_clauses'), 10, 3);
34
+
35
+ // meta in the html head section
36
+ remove_action('wp_head', 'rel_canonical');
37
+ add_action('wp_head', array(&$this, 'wp_head'));
38
+
39
+ // prevents redirection of the homepage
40
+ add_filter('redirect_canonical', array(&$this, 'redirect_canonical'), 10, 2);
41
+
42
+ // adds javascript at the end of the document
43
+ add_action('wp_print_footer_scripts', array(&$this, 'wp_print_footer_scripts'));
44
+
45
+ // adds the language information in the search form
46
+ // low priority in case the search form is created using the same filter as described in http://codex.wordpress.org/Function_Reference/get_search_form
47
+ add_filter('get_search_form', array(&$this, 'get_search_form'), 99);
48
+
49
+ // filters the pages according to the current language in wp_list_pages
50
+ add_filter('wp_list_pages_excludes', array(&$this, 'wp_list_pages_excludes'));
51
+
52
+ // filters the comments according to the current language
53
+ add_filter('comments_clauses', array(&$this, 'comments_clauses'), 10, 2);
54
+
55
+ // rewrites feed links to filter them by language
56
+ add_filter('feed_link', array(&$this, 'feed_link'), 10, 2);
57
+
58
+ // rewrites archives links to filter them by language
59
+ add_filter('getarchives_join', array(&$this, 'posts_join'));
60
+ add_filter('getarchives_where', array(&$this, 'posts_where'));
61
+
62
+ // rewrites author and date links to filter them by language
63
+ add_filter('author_link', array(&$this, 'archive_link'));
64
+ add_filter('year_link', array(&$this, 'archive_link'));
65
+ add_filter('month_link', array(&$this, 'archive_link'));
66
+ add_filter('day_link', array(&$this, 'archive_link'));
67
+
68
+ // rewrites next and previous post links to filter them by language
69
+ add_filter('get_previous_post_join', array(&$this, 'posts_join'));
70
+ add_filter('get_next_post_join', array(&$this, 'posts_join'));
71
+ add_filter('get_previous_post_where', array(&$this, 'posts_where'));
72
+ add_filter('get_next_post_where', array(&$this, 'posts_where'));
73
+
74
+ // filters the nav menus according to the current language
75
+ add_filter('wp_nav_menu_args', array(&$this, 'wp_nav_menu_args'));
76
+ add_filter('wp_nav_menu_items', array(&$this, 'wp_nav_menu_items'), 10, 2);
77
+ add_filter('wp_nav_menu_objects', array(&$this, 'wp_nav_menu_objects'), 10, 2);
78
+ add_filter('wp_page_menu', array(&$this, 'wp_page_menu'), 10, 2);
79
+
80
+ // filters the widgets according to the current language
81
+ add_filter('widget_display_callback', array(&$this, 'widget_display_callback'), 10, 3);
82
+
83
+ // modifies the home url
84
+ add_filter('home_url', array(&$this, 'home_url'));
85
+
86
+ // allows a new value for the 'show' parameter to display the homepage url according to the current language
87
+ // FIXME Backward compatibily for versions < 0.5 -> replaced by a filter on home_url
88
+ add_filter('bloginfo_url', array(&$this, 'bloginfo_url'), 10, 2);
89
+
90
+ // Template tag: displays the language switcher
91
+ // FIXME Backward compatibily for versions < 0.5 -> replaced by pll_the_languages
92
+ add_action('the_languages', array(&$this, 'the_languages'));
93
+ }
94
+
95
+ // returns the language according to browser preference or the default language
96
+ function get_preferred_language() {
97
+ // check first is the user was already browsing this site
98
+ if (isset($_COOKIE['wordpress_polylang']))
99
+ return $this->get_language($_COOKIE['wordpress_polylang']);
100
+
101
+ // sets the browsing language according to the browser preferences
102
+ // code adapted from http://www.thefutureoftheweb.com/blog/use-accept-language-header
103
+ if ($this->options['browser']) {
104
+ $accept_langs = array();
105
+
106
+ if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
107
+ // break up string into pieces (languages and q factors)
108
+ preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
109
+
110
+ if (count($lang_parse[1])) {
111
+ // NOTE: array_combine => PHP5
112
+ $accept_langs = array_combine($lang_parse[1], $lang_parse[4]); // create a list like "en" => 0.8
113
+ // set default to 1 for any without q factor
114
+ foreach ($accept_langs as $accept_lang => $val) {
115
+ if ($val === '') $accept_langs[$accept_lang] = 1;
116
+ }
117
+ arsort($accept_langs, SORT_NUMERIC); // sort list based on value
118
+ }
119
+ }
120
+
121
+ // looks through sorted list and use first one that matches our language list
122
+ $listlanguages = $this->get_languages_list(true); // hides languages with no post
123
+ foreach ($accept_langs as $accept_lang => $val) {
124
+ foreach ($listlanguages as $language) {
125
+ if (strpos($accept_lang, $language->slug) === 0 && !isset($pref_lang)) {
126
+ $pref_lang = $language;
127
+ }
128
+ }
129
+ }
130
+ } // options['browser']
131
+
132
+ // either there is no preference in the browser or preferences does not match our language list or it is requested not to use the browser preference
133
+ if (!isset($pref_lang))
134
+ $pref_lang = $this->get_language($this->options['default_lang']);
135
+
136
+ return $pref_lang;
137
+ }
138
+
139
+ // returns the current language
140
+ function get_current_language() {
141
+ if($this->curlang)
142
+ return $this->curlang;
143
+
144
+ // no language set for 404 and attachment
145
+ if (is_404() || is_attachment())
146
+ return $this->get_preferred_language();
147
+
148
+ if ($var = get_query_var('lang'))
149
+ $lang = $this->get_language($var);
150
+
151
+ elseif (is_single() || is_page() && $var = get_queried_object_id())
152
+ $lang = $this->get_post_language($var);
153
+
154
+ else {
155
+ foreach (get_taxonomies(array('show_ui'=>true)) as $taxonomy) {
156
+ if ($var = get_query_var(get_taxonomy($taxonomy)->query_var))
157
+ $lang = $this->get_term_language($var, $taxonomy);
158
+ }
159
+ }
160
+
161
+ return (isset($lang)) ? $lang : NULL;
162
+ }
163
+
164
+ // save the default locale before we start any language manipulation
165
+ function init() {
166
+ $this->default_locale = get_locale();
167
+ }
168
+
169
+ // returns the locale based on current language
170
+ function get_locale($locale) {
171
+ if ($this->curlang)
172
+ $locale = $this->curlang->description;
173
+ return $locale;
174
+ }
175
+
176
+ // saves all text domains in a table for later usage
177
+ function mofile($bool, $domain, $mofile) {
178
+ $this->list_textdomains[] = array ('mo' => $mofile, 'domain' => $domain);
179
+ return true; // prevents WP loading text domains as we will load them all later
180
+ }
181
+
182
+ // NOTE: I believe there are two ways for a plugin to force the WP language
183
+ // as done by xili_language and here: load text domains and reinitialize wp_locale with the action 'wp'
184
+ // as done by qtranslate: define the locale with the action 'plugins_loaded', but in this case, the language must be specified in the url.
185
+ function load_textdomains() {
186
+ // sets the current language and set a cookie to remember it
187
+ if ($this->curlang = $this->get_current_language())
188
+ setcookie('wordpress_polylang', $this->curlang->slug, time() + 31536000 /* 1 year */, COOKIEPATH, COOKIE_DOMAIN);
189
+
190
+ // our override_load_textdomain filter has done its job. let's remove it before calling load_textdomain
191
+ remove_filter('override_load_textdomain', array(&$this, 'mofile'));
192
+
193
+ // now we can load text domains with the right language
194
+ $new_locale = get_locale();
195
+ foreach ($this->list_textdomains as $textdomain)
196
+ load_textdomain( $textdomain['domain'], str_replace($this->default_locale, $new_locale, $textdomain['mo']));
197
+
198
+ global $wp_locale;
199
+ $wp_locale->init(); // reinitializes wp_locale for weekdays and months
200
+ }
201
+
202
+ // filters posts according to the language
203
+ function pre_get_posts($query) {
204
+ global $wp_rewrite;
205
+ $qvars = $query->query_vars;
206
+
207
+ // detect our exclude pages query and returns to avoid conflicts
208
+ // this test should be sufficient
209
+ if (isset($qvars['tax_query'][0]) && isset($qvars['tax_query'][0]['taxonomy']) && isset($qvars['tax_query'][0]['operator']))
210
+ return;
211
+
212
+ if (empty($query->query)) {
213
+ if ( $this->options['hide_default'] && isset($_COOKIE['wordpress_polylang']) )
214
+ $this->curlang = $this->get_language($this->options['default_lang']);
215
+ else
216
+ $this->curlang = $this->get_preferred_language(); // sets the language according to browser preference or default language
217
+
218
+ if ($this->options['default_lang'] == $this->curlang->slug && $this->options['hide_default']) {
219
+ if ($this->page_on_front && $link_id = $this->get_post($this->page_on_front, $this->curlang))
220
+ $query->set('page_id', $link_id);
221
+ else
222
+ $query->set('lang', $this->curlang->slug);
223
+ }
224
+ else {
225
+ if ($this->page_on_front && $link_id = $this->get_post($this->page_on_front, $this->curlang))
226
+ $url = _get_page_link($link_id);
227
+ else
228
+ $url = home_url('?lang='.$this->curlang->slug);
229
+
230
+ wp_redirect($url);
231
+ exit;
232
+ }
233
+ }
234
+
235
+ // sets the language for posts page in case the front page displays a static page
236
+ if ($this->page_for_posts) {
237
+ // If permalinks are used, WordPress does set and use $query->queried_object_id and sets $query->query_vars['page_id'] to 0
238
+ // and does set and use $query->query_vars['page_id'] if permalinks are not used :(
239
+ if (isset($query->queried_object_id))
240
+ $page_id = $query->queried_object_id;
241
+ elseif (isset($qvars['page_id']))
242
+ $page_id = $qvars['page_id'];
243
+
244
+ if (isset($page_id) && $page_id && $this->get_post($page_id, $this->get_post_language($this->page_for_posts)) == $this->page_for_posts) {
245
+ $query->set('lang',$this->get_post_language($page_id)->slug);
246
+ $query->queried_object_id = $this->page_for_posts;
247
+ $query->query_vars['page_id'] = $this->page_for_posts; // FIXME the trick works but breaks .current-menu-item and .current_page_item
248
+ $query->is_page = false;
249
+ $query->is_home = true;
250
+ $query->is_posts_page = true;
251
+ $query->is_singular = false;
252
+ }
253
+ }
254
+
255
+ // FIXME to generalize as I probably forget things
256
+ // sets the language in case we hide the default language
257
+ if ( $this->options['hide_default'] && !isset($qvars['lang']) && (
258
+ (count($query->query) == 1 && isset($qvars['paged']) && $qvars['paged']) ||
259
+ isset($qvars['m']) && $qvars['m'] ||
260
+ isset($qvars['feed']) && $qvars['feed'] ||
261
+ isset($qvars['author']) && $qvars['author']))
262
+ $query->set('lang', $this->options['default_lang']);
263
+
264
+ // filters recent posts to the current language
265
+ // FIXME if $qvars['post_type'] == 'nav_menu_item', setting lang breaks custom menus.
266
+ // since to get nav_menu_items, get_post is used and no language is linked to nav_menu_items
267
+ if ($query->is_home && $this->curlang && !isset($qvars['post_type']))
268
+ $query->set('lang', $this->curlang->slug);
269
+
270
+ // remove pages query when the language is set unless we do a search
271
+ // FIXME is only search broken by this ?
272
+ if (isset($qvars['lang']) && $qvars['lang'] && !isset($qvars['post_type']) && !is_search())
273
+ $query->set('post_type', 'post');
274
+
275
+ // unset the is_archive flag for language pages to prevent loading the archive template
276
+ // keep archive flag for comment feed otherwise the language filter does not work
277
+ if (isset($qvars['lang']) && $qvars['lang'] && !is_post_type_archive() && !is_date() && !is_author() && !is_category() && !is_tag() && !is_comment_feed())
278
+ $query->is_archive = false;
279
+
280
+ // unset the is_tax flag for authors pages
281
+ // FIXME Probably I should do this for other cases
282
+ if (isset($qvars['lang']) && $qvars['lang'] && is_author())
283
+ $query->is_tax = false;
284
+
285
+ // sets a language for theme preview
286
+ if (isset($_GET['preview']))
287
+ $query->set('lang', $this->options['default_lang']);
288
+
289
+ if (PLL_DISPLAY_ALL) {
290
+ // add posts with no language set
291
+ $query->query_vars['tax_query'] = array(
292
+ 'relation' => 'OR', array(
293
+ 'taxonomy'=> 'language',
294
+ 'terms'=> get_terms('language', array('fields'=>'ids')),
295
+ 'operator'=>'NOT IN'));
296
+ }
297
+ }
298
+
299
+ // filters categories and post tags by language when needed
300
+ function terms_clauses($clauses, $taxonomies, $args) {
301
+ // does nothing except on taxonomies which have show_ui set to 1 (includes category and post_tags)
302
+ foreach ($taxonomies as $tax) {
303
+ if(!get_taxonomy($tax)->show_ui)
304
+ return $clauses;
305
+ }
306
+
307
+ // adds our clauses to filter by current language
308
+ return isset($this->curlang) ? $this->_terms_clauses($clauses, $this->curlang, PLL_DISPLAY_ALL) : $clauses;
309
+ }
310
+
311
+ // meta in the html head section
312
+ function wp_head() {
313
+ // modifies the canonical link to the homepage
314
+ if (is_singular()) {
315
+ global $wp_the_query;
316
+ if ($id = $wp_the_query->get_queried_object_id()) {
317
+ if (is_page())
318
+ $link = _get_page_link($id); // ignores page_on_front unlike get_permalink
319
+ else
320
+ $link = get_permalink ($id);
321
+ echo "<link rel='canonical' href='$link' />\n";
322
+ }
323
+ }
324
+
325
+ // outputs references to translated pages (if exists) in the html head section
326
+ foreach ($this->get_languages_list() as $language) {
327
+ if ($language->slug != $this->curlang->slug && $url = $this->get_translation_url($language))
328
+ printf("<link hreflang='%s' href='%s' rel='alternate' />\n", esc_attr($language->slug), esc_url($url));
329
+ }
330
+ }
331
+
332
+ // prevents redirection of the homepage
333
+ function redirect_canonical($redirect_url, $requested_url) {
334
+ if($requested_url == _get_page_link($this->page_on_front))
335
+ return false;
336
+ return $redirect_url;
337
+ }
338
+
339
+ // adds some javascript workaround knowing it's not perfect...
340
+ function wp_print_footer_scripts() {
341
+ if ($this->curlang) {
342
+ $js = '';
343
+
344
+ // modifies the search form since filtering get_search_form won't work if the template uses searchform.php
345
+ // don't use directly e[0] just in case there is somewhere else an element named 's'
346
+ // check before if the hidden input has not already been introduced by get_search_form
347
+ if (!$this->search_form_filter) {
348
+ $lang = esc_js($this->curlang->slug);
349
+ $js .= "e = document.getElementsByName('s');
350
+ for (i = 0; i < e.length; i++) {
351
+ if (e[i] == '[object HTMLInputElement]') {
352
+ var ih = document.createElement('input');
353
+ ih.type = 'hidden';
354
+ ih.name = 'lang';
355
+ ih.value = '$lang';
356
+ e[i].parentNode.appendChild(ih);
357
+ }
358
+ }";
359
+ }
360
+
361
+ if ($js)
362
+ echo "<script type='text/javascript'>" .$js. "</script>";
363
+ }
364
+ }
365
+
366
+ // adds the language information in the search form
367
+ // does not work if searchform.php is used
368
+ function get_search_form($form) {
369
+ if ($form) {
370
+ $this->search_form_filter = true;
371
+ $form = str_replace('</form>', '<input type="hidden" name="lang" value="'.esc_attr($this->curlang->slug).'" /></form>', $form);
372
+ }
373
+ return $form;
374
+ }
375
+
376
+ // excludes pages which are not in the current language for wp_list_pages
377
+ // useful for the pages widget
378
+ function wp_list_pages_excludes($pages) {
379
+ if (isset($this->curlang)) {
380
+ $q = array(
381
+ 'numberposts'=>-1,
382
+ 'post_type' => 'page',
383
+ 'fields' => 'ids',
384
+ 'tax_query' => array(array(
385
+ 'taxonomy'=>'language',
386
+ 'fields' => 'id',
387
+ 'terms'=>$this->curlang->term_id,
388
+ 'operator'=>'NOT IN'
389
+ ))
390
+ );
391
+ $pages = array_merge($pages, get_posts($q));
392
+ }
393
+ return $pages;
394
+ }
395
+
396
+ // filters the comments according to the current language mainly for the recent comments widget
397
+ function comments_clauses($clauses, $comment_query) {
398
+ // first test if wp_posts.ID already available in the query
399
+ if ($this->curlang && strpos($clauses['join'], '.ID')) {
400
+ global $wpdb;
401
+ $clauses['join'] .= " INNER JOIN $wpdb->term_relationships AS tr ON tr.object_id = ID";
402
+ $clauses['where'] .= $wpdb->prepare(" AND tr.term_taxonomy_id = %d", $this->curlang->term_taxonomy_id);
403
+ }
404
+ return $clauses;
405
+ }
406
+
407
+ // Modifies the feed link to add the language parameter
408
+ function feed_link($url, $feed) {
409
+ global $wp_rewrite;
410
+
411
+ if ($this->curlang) {
412
+ if ($wp_rewrite->using_permalinks()) {
413
+ $base = $this->options['rewrite'] ? '/' : '/language/';
414
+ $slug = $this->options['default_lang'] == $this->curlang->slug && $this->options['hide_default'] ? '' : $base.$this->curlang->slug;
415
+ $url = esc_url(str_replace($this->home, $this->home.$slug, $url));
416
+ }
417
+ elseif ($feed)
418
+ $url = esc_url(home_url('?lang='.$this->curlang->slug.'&feed='.$feed));
419
+
420
+ }
421
+ return $url;
422
+ }
423
+
424
+ // modifies the sql request for wp_get_archives an get_adjacent_post to filter by the current language
425
+ function posts_join($sql) {
426
+ if ($this->curlang) {
427
+ global $wpdb;
428
+ $sql .= " INNER JOIN $wpdb->term_relationships ON object_id = ID";
429
+ }
430
+ return $sql;
431
+ }
432
+
433
+ // modifies the sql request for wp_get_archives and get_adjacent_post to filter by the current language
434
+ function posts_where($sql) {
435
+ if ($this->curlang) {
436
+ global $wpdb;
437
+ $sql .= $wpdb->prepare(" AND term_taxonomy_id = %d", $this->curlang->term_taxonomy_id);
438
+ }
439
+ return $sql;
440
+ }
441
+
442
+ // modifies the author and date links to add the language parameter
443
+ function archive_link($link) {
444
+ if ($this->curlang) {
445
+ global $wp_rewrite;
446
+
447
+ if ($wp_rewrite->using_permalinks()) {
448
+ $base = $this->options['rewrite'] ? '/' : '/language/';
449
+ $slug = $this->options['default_lang'] == $this->curlang->slug && $this->options['hide_default'] ? '' : $base.$this->curlang->slug;
450
+ $link = esc_url(str_replace($this->home, $this->home.$slug, $link));
451
+ }
452
+ else
453
+ $link = esc_url(str_replace($this->home.'/?', $this->home.'/?lang='.$this->curlang->slug.'&amp;', $link));
454
+ }
455
+ return $link;
456
+ }
457
+
458
+ // returns the url of the translation (if exists) of the current page
459
+ function get_translation_url($language) {
460
+ global $wp_query, $wp_rewrite;
461
+ $qvars = $wp_query->query;
462
+ $hide = $this->options['default_lang'] == $language->slug && $this->options['hide_default'];
463
+
464
+ // is_single is set to 1 for attachment but no language is set
465
+ if (is_single() && !is_attachment() && $id = $this->get_post(get_the_ID(), $language))
466
+ $url = get_permalink($id);
467
+
468
+ // page for posts
469
+ elseif (get_option('show_on_front') == 'page' && // necessary for twentyeleven
470
+ isset($wp_query->queried_object_id) &&
471
+ $wp_query->queried_object_id == $this->page_for_posts
472
+ )
473
+ $url = get_permalink($this->get_post($this->page_for_posts, $language));
474
+
475
+ elseif (is_page() && $id = $this->get_post(get_the_ID(), $language))
476
+ $url = $hide && $id == $this->get_post($this->page_on_front, $language) ?
477
+ $this->home :
478
+ _get_page_link($id);
479
+
480
+ elseif ( !is_tax ('language') && (is_category() || is_tag() || is_tax () ) ) {
481
+ $term = get_queried_object();
482
+ $lang = $this->get_term_language($term->term_id);
483
+ $taxonomy = $term->taxonomy;
484
+
485
+ if ($language->slug == $lang->slug)
486
+ $url = get_term_link($term, $taxonomy); // self link
487
+ elseif ($link_id = $this->get_translation('term', $term->term_id, $language))
488
+ $url = get_term_link(get_term($link_id, $taxonomy), $taxonomy);
489
+ }
490
+
491
+ // don't test if there are existing translations before creating the url as it would be very expensive in sql queries
492
+ elseif(is_archive()) {
493
+ if ($wp_rewrite->using_permalinks()) {
494
+ $base = $this->options['rewrite'] ? '/' : '/language/';
495
+ $base = $hide ? '' : $base.$language->slug;
496
+ $base = $this->home.$base.'/';
497
+
498
+ if (is_author())
499
+ $url = esc_url($base.'author/'.$qvars['author_name'].'/');
500
+
501
+ if (is_year())
502
+ $url = esc_url($base.$qvars['year'].'/');
503
+
504
+ if (is_month())
505
+ $url = esc_url($base.$qvars['year'].'/'.$qvars['monthnum'].'/');
506
+
507
+ if (is_day())
508
+ $url = esc_url($base.$qvars['year'].'/'.$qvars['monthnum'].'/'.$qvars['day'].'/');
509
+ }
510
+ else
511
+ $url = $hide ? remove_query_arg('lang') : add_query_arg('lang', $language->slug);
512
+ }
513
+
514
+ elseif (is_home() || is_tax('language') )
515
+ $url = $hide ? $this->home : get_term_link($language, 'language');
516
+
517
+ return isset($url) ? $url : null;
518
+ }
519
+
520
+ // filters the nav menus according to the current language
521
+ function wp_nav_menu_args($args) {
522
+ if (!$args['menu'] && $args['theme_location'] && $this->curlang) {
523
+ $menu_lang = get_option('polylang_nav_menus');
524
+ $args['menu'] = $menu_lang[$args['theme_location']][$this->curlang->slug];
525
+ }
526
+ return $args;
527
+ }
528
+
529
+ // filters the widgets according to the current language
530
+ function widget_display_callback($instance, $widget, $args) {
531
+ $widget_lang = get_option('polylang_widgets');
532
+ // don't display if a language filter is set and this is not the current one
533
+ if (isset($this->curlang) && isset($widget_lang[$widget->id]) && $widget_lang[$widget->id] && $widget_lang[$widget->id] != $this->curlang->slug)
534
+ return false;
535
+
536
+ return $instance;
537
+ }
538
+
539
+ // adds the language switcher at the end of the menu
540
+ function wp_nav_menu_items($items, $args) {
541
+ $menu_lang = get_option('polylang_nav_menus');
542
+ return $menu_lang[$args->theme_location]['switcher'] ?
543
+ $items . $this->the_languages(array(
544
+ 'menu' => 1,
545
+ 'show_names' => $menu_lang[$args->theme_location]['show_names'],
546
+ 'show_flags' => $menu_lang[$args->theme_location]['show_flags'],
547
+ 'force_home' => $menu_lang[$args->theme_location]['force_home'],
548
+ 'echo' => 0)) :
549
+ $items;
550
+ }
551
+
552
+ // corrects some issues on front page and post pages nav menus items
553
+ function wp_nav_menu_objects($menu_items, $args) {
554
+ global $wp_query;
555
+
556
+ // corrects classes in the menu for posts page
557
+ // FIXME check for child pages
558
+ if ($wp_query->is_posts_page) {
559
+ $classes = array('current-menu-item', 'current_page_item', 'current_page_parent');
560
+ foreach($menu_items as $item) {
561
+ $item->classes = array_diff($item->classes, $classes);
562
+ if ($item->object_id == $this->get_post($this->page_for_posts, $this->curlang))
563
+ $item->classes = array_merge($item->classes, $classes);
564
+ }
565
+ }
566
+
567
+ foreach($menu_items as $item) {
568
+ if ($item->object == 'page')
569
+ $item->url = _get_page_link($item->object_id); // avoids bad link on translated front page
570
+ }
571
+
572
+ return $menu_items;
573
+ }
574
+
575
+ // corrects the output of the function for translated home
576
+ function wp_page_menu($menu, $args) {
577
+ global $wp_query;
578
+
579
+ // add current_page_item class to posts page
580
+ if ($wp_query->is_posts_page) {
581
+ $id = $this->get_post($this->page_for_posts, $this->curlang);
582
+ $menu = str_replace('<li class="page_item page-item-'.$id.'">', '<li class="page_item page-item-'.$id.' current_page_item">', $menu);
583
+ }
584
+
585
+ // add current_page_item class to home page
586
+ // normally only the homepage has no class. note the space in <li >
587
+ if ($this->is_front_page() && !is_paged())
588
+ $menu = str_replace('<li >', '<li class="current_page_item">', $menu);
589
+
590
+ // remove the 2nd occurrence of homepage (when translated)
591
+ if ($this->page_on_front) {
592
+ $id = $this->get_post($this->page_on_front, $this->curlang);
593
+ $url = _get_page_link($id);
594
+ $title = apply_filters( 'the_title', get_page($id)->post_title);
595
+ $menu = str_replace('<li class="page_item page-item-'.$id.'"><a href="'.$url.'">'.$title.'</a></li>', '', $menu);
596
+ $menu = str_replace('<li class="page_item page-item-'.$id.' current_page_item"><a href="'.$url.'">'.$title.'</a></li>', '', $menu);
597
+ }
598
+ return $menu;
599
+ }
600
+
601
+ // acts as is_front_page but knows about translated front page
602
+ function is_front_page() {
603
+ if ('page' == get_option('show_on_front') &&
604
+ get_option('page_on_front') &&
605
+ is_page($this->get_post(get_option('page_on_front'), $this->get_current_language()))
606
+ )
607
+ return true;
608
+
609
+ elseif(is_tax('language'))
610
+ return true;
611
+
612
+ return is_front_page();
613
+ }
614
+
615
+ // filters the home url to get the right language
616
+ function home_url($url) {
617
+ if ( !(did_action('template_redirect') && rtrim($url,'/') == rtrim($this->home,'/') && $this->curlang) )
618
+ return $url;
619
+
620
+ // don't like this but at least for WP_Widget_Categories::widget, it seems to be the only solution
621
+ // FIXME are there other exceptions ?
622
+ foreach (debug_backtrace() as $trace) {
623
+ $exceptions = $trace['function'] == 'get_pagenum_link' ||
624
+ $trace['function'] == 'get_author_posts_url' ||
625
+ $trace['function'] == 'get_search_form' ||
626
+ (isset($trace['file']) && strpos($trace['file'], 'searchform.php')) ||
627
+ ($trace['function'] == 'widget' && $trace['class'] == 'WP_Widget_Categories');
628
+ if ($exceptions)
629
+ return $url;
630
+ }
631
+ return $this->get_home_url($this->curlang);
632
+ }
633
+
634
+ // returns the home url in the right language
635
+ function get_home_url($language) {
636
+ if ($this->options['default_lang'] == $language->slug && $this->options['hide_default'])
637
+ return trailingslashit($this->home);
638
+
639
+ // a static page is used as front page
640
+ if ($this->page_on_front && $id = $this->get_post($this->page_on_front, $language))
641
+ $url = _get_page_link($id);
642
+
643
+ return isset($url) ? $url : get_term_link($language, 'language');
644
+ }
645
+
646
+ // adds 'lang_url' as possible value to the 'show' parameter of bloginfo to display the home url in the correct language
647
+ // FIXME not tested
648
+ function bloginfo_url($output, $show) {
649
+ if ($show == 'lang_url' && $this->curlang) {
650
+ $url = $this->get_home_url($this->curlang);
651
+ $output = isset($url) ? $url : $this->home;
652
+ }
653
+ return $output;
654
+ }
655
+
656
+ // displays the language switcher
657
+ function the_languages($args = '') {
658
+ $defaults = array(
659
+ 'dropdown' => 0, // display as list and not as dropdown
660
+ 'echo' => 1, // echoes the list
661
+ 'hide_if_empty' => 1, // hides languages with no posts (or pages)
662
+ 'menu' => '0', // not for nav menu
663
+ 'show_flags' => 0, // don't show flags
664
+ 'show_names' => 1, // show language names
665
+ 'force_home' => 0, // tries to find a translation (available only if display != dropdown)
666
+ );
667
+ extract(wp_parse_args($args, $defaults));
668
+
669
+ $output = '';
670
+ $listlanguages = $this->get_languages_list($hide_if_empty);
671
+
672
+ foreach ($listlanguages as $language) {
673
+ if ($dropdown) {
674
+ $output .= sprintf(
675
+ "<option value='%s'%s>%s</option>\n",
676
+ esc_attr($language->slug),
677
+ $language->term_id == $this->curlang->term_id ? ' selected="selected"' : '',
678
+ esc_html($language->name)
679
+ );
680
+ }
681
+ else {
682
+ $url = $force_home ? null : $this->get_translation_url($language);
683
+ $url = isset($url) ? $url : $this->get_home_url($language); // if the page is not translated, link to the home page
684
+
685
+ $class = 'lang-item lang-item-'.esc_attr($language->term_id);
686
+ $class .= $language->term_id == $this->curlang->term_id ? ' current-lang' : '';
687
+ $class .= $menu ? ' menu-item' : '';
688
+
689
+ $flag = $show_flags ? $this->get_flag($language) : '';
690
+ $name = $show_names || !$show_flags ? esc_html($language->name) : '';
691
+
692
+ $output .= '<li class="'.$class.'"><a href="'.esc_url($url).'">'.($show_flags && $show_names ? $flag.'&nbsp;'.$name : $flag.$name)."</a></li>\n";
693
+ }
694
+ }
695
+
696
+ if ($dropdown)
697
+ $output = "<select name='lang_choice' id='lang_choice'>\n" . $output . "</select>\n";
698
+ elseif (!$menu)
699
+ $output = "<ul>\n" . $output . "</ul>\n";
700
+
701
+ if ($echo)
702
+ echo $output;
703
+ else
704
+ return $output;
705
+ }
706
+ }
707
+ ?>
include/edit-term-form.php CHANGED
@@ -4,14 +4,15 @@
4
  ?>
5
  <tr class="form-field">
6
  <th scope="row" valign="top"><label for="term_lang_choice"><?php _e('Language', 'polylang');?></label></th>
7
- <td><select name="term_lang_choice" id="term_lang_choice">
8
- <option value="0"></option><?php
 
9
  foreach ($listlanguages as $language) {
10
  printf(
11
  "<option value='%s'%s>%s</option>\n",
12
  esc_attr($language->term_id),
13
  $language == $lang ? ' selected="selected"' : '',
14
- esc_attr($language->name)
15
  );
16
  } ?>
17
  </select><br />
@@ -19,7 +20,7 @@
19
  </tr>
20
 
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>
4
  ?>
5
  <tr class="form-field">
6
  <th scope="row" valign="top"><label for="term_lang_choice"><?php _e('Language', 'polylang');?></label></th>
7
+ <td><select name="term_lang_choice" id="term_lang_choice"><?php
8
+ if (PLL_DISPLAY_ALL) // for those who want undefined language
9
+ echo '<option value="0"></option>';
10
  foreach ($listlanguages as $language) {
11
  printf(
12
  "<option value='%s'%s>%s</option>\n",
13
  esc_attr($language->term_id),
14
  $language == $lang ? ' selected="selected"' : '',
15
+ esc_html($language->name)
16
  );
17
  } ?>
18
  </select><br />
20
  </tr>
21
 
22
  <tr id="term-translations" class="form-field"><?php
23
+ // do not display translation fields if term language is not set (possible if PLL_DISPLAY_ALL == true)
24
  if ($lang)
25
+ include(PLL_INC.'/term-translations.php');?>
26
  </tr>
include/languages-form.php CHANGED
@@ -1,225 +1,237 @@
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
6
-
7
- // The term fields are used as follows :
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'); ?>
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">
22
- <div class="col-wrap">
23
-
24
- <?php $list_table->display(); // displays the language list in a table ?>
25
-
26
- </div> <!-- col-wrap -->
27
- </div> <!-- col-right -->
28
-
29
- <div id="col-left">
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">
39
- <?php wp_nonce_field('add-lang', '_wpnonce_add-lang');
40
-
41
- if ($action=='edit') {?>
42
- <input type="hidden" name="action" value="update" />
43
- <input type="hidden" name="lang" value="<?php echo esc_attr($edit_lang->term_id);?>" /><?php
44
- }
45
- else { ?>
46
- <input type="hidden" name="action" value="add" /><?php
47
- }?>
48
-
49
- <div class="form-field form-required">
50
- <label for="name"><?php _e('Full name', 'polylang');?></label>
51
- <input name="name" id="name" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->name);?>" size="40" aria-required="true" />
52
- <p><?php _e('The name is how it is displayed on your site (for example: English).', 'polylang');?></p>
53
- </div>
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
-
67
- <?php submit_button( $action == 'edit' ? __('Update') : __('Add new language', 'polylang'), 'button'); // since WP 3.1 ?>
68
-
69
- </form>
70
- </div> <!-- form-wrap -->
71
- </div> <!-- col-wrap -->
72
- </div> <!-- col-left -->
73
- </div> <!-- col-container --> <?php
74
-
75
- // displays the nav menus languages form
76
- if (current_theme_supports( 'menus' )) { ?>
77
 
78
  <div class="form-wrap">
79
- <h3 id="menus"><?php _e('Menus','polylang');?></h3>
80
-
81
- <form id="nav-menus-lang" method="post" action="admin.php?page=mlang" class="validate">
82
- <?php wp_nonce_field('nav-menus-lang', '_wpnonce_nav-menus-lang');?>
83
- <input type="hidden" name="action" value="nav-menus" />
84
-
85
- <table class="wp-list-table widefat fixed tags" cellspacing="0" style="width: auto">
86
- <thead><tr>
87
- <th><?php _e('Theme location','polylang') ?></th><?php
88
- foreach ($listlanguages as $language) {
89
- echo '<th>' . esc_attr($language->name) . '</th>';
90
- } ?>
91
- </tr></thead>
92
-
93
- <tbody>
94
- <?php foreach ( $locations as $location => $description ) { ?>
95
- <tr><td><?php echo esc_attr($description); ?></td><?php
96
- foreach ($listlanguages as $language) { ?>
97
- <td><?php
98
- printf(
99
- '<select name="menu-lang[%s][%s]" id="menu-lang-%s-%s">',
100
- esc_attr($location),
101
- esc_attr($language->slug),
102
- esc_attr($location),
103
- esc_attr($language->slug)
104
- );?>
105
- <option value="0"></option><?php
106
- foreach ( $menus as $menu ) {
107
- printf(
108
- "<option value='%s'%s>%s</option>\n",
109
- esc_attr($menu->term_id),
110
- $menu_lang[$location][$language->slug] == $menu->term_id ? ' selected="selected"' : '',
111
- esc_attr($menu->name)
112
- );
113
- } ?>
114
- </select></td><?php
115
- }?>
116
  </tr><?php
117
- }?>
118
- </tbody>
119
 
120
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
- <?php submit_button(); // since WP 3.1 ?>
123
 
124
- </form>
125
- </div> <!-- form-wrap --> <?php
126
 
127
- } // if (current_theme_supports( 'menus' ))
 
 
128
 
129
- // displays the Polylang options form ?>
130
- <div class="form-wrap">
131
- <h3><?php _e('Options','polylang');?></h3>
132
-
133
- <form id="options-lang" method="post" action="admin.php?page=mlang" class="validate">
134
- <?php wp_nonce_field('options-lang', '_wpnonce_options-lang');?>
135
- <input type="hidden" name="action" value="options" />
136
-
137
- <table class="form-table">
138
-
139
- <tr>
140
- <th><label for='default_lang'><?php _e('Default language', 'polylang');?></label></th>
141
- <td>
142
- <select name="default_lang" id="default_lang"><?php
143
- foreach ($listlanguages as $language) {
144
- printf(
145
- "<option value='%s'%s>%s</option>\n",
146
- esc_attr($language->slug),
147
- $options['default_lang'] == $language->slug ? ' selected="selected"' : '',
148
- esc_attr($language->name)
149
- );
150
- } ?>
151
- </select>
152
- </td>
153
- </tr><?php
154
-
155
- // posts or terms without language set
156
- if (!empty($posts) || !empty($terms) && $options['default_lang']) {
157
-
158
- if (!empty($posts))
159
- echo '<input type="hidden" name="posts" value="'.esc_attr($posts).'" />';
160
- if (!empty($terms))
161
- echo '<input type="hidden" name="terms" value="'.esc_attr($terms).'" />';?>
162
-
163
- <tr>
164
- <th></th>
165
- <td>
166
- <label style="color: red"><?php
167
- printf(
168
- '<input name="fill_languages" type="checkbox" value="1" /> %s',
169
- __('There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?', 'polylang')
170
- );?>
171
- </label>
172
- </td>
173
- </tr><?php
174
  }?>
175
 
176
- <tr>
177
- <th><?php _e('Detect browser language', 'polylang');?></th>
178
- <td>
179
- <label><?php
180
- printf(
181
- '<input name="browser" type="checkbox" value="1" %s /> %s',
182
- $options['browser'] ? 'checked="checked"' :'',
183
- __('When the front page is visited, set the language according to the browser preference', 'polylang')
184
- );?>
185
- </label>
186
- </td>
187
- </tr>
188
-
189
- <tr>
190
- <th><?php _e('URL modifications', 'polylang') ?></th>
191
- <td scope="row">
192
- <label><?php
193
- printf(
194
- '<input name="rewrite" type="radio" value="0" %s /> %s %s',
195
- $options['rewrite'] ? '' : 'checked="checked"',
196
- __('Keep /language/ in pretty permalinks. Example:', 'polylang'),
197
- '<code>'.home_url('language/en/').'</code>'
198
- );?>
199
- </label>
200
- <label><?php
201
- printf(
202
- '<input name="rewrite" type="radio" value="1" %s /> %s %s',
203
- $options['rewrite'] ? 'checked="checked"' : '',
204
- __('Remove /language/ in pretty permalinks. Example:', 'polylang'),
205
- '<code>'.home_url('en/').'</code>'
206
- );?>
207
- </label>
208
- <label><?php
209
- printf(
210
- '<input name="hide_default" type="checkbox" value="1" %s /> %s',
211
- $options['hide_default'] ? 'checked="checked"' :'',
212
- __('Hide URL language information for default language', 'polylang')
213
- );?>
214
- </label>
215
- </td>
216
- </tr>
217
-
218
- </table>
219
-
220
- <?php submit_button(); // since WP 3.1 ?>
221
-
222
- </form>
223
- </div> <!-- form-wrap -->
224
-
225
- </div> <!-- wrap -->
1
  <?php
2
  // displays the Languages admin panel
 
 
 
 
 
 
 
 
3
  ?>
4
  <div class="wrap">
5
  <?php screen_icon('options-general'); ?>
6
+ <h2 class="nav-tab-wrapper"><?php
7
+ // display tabs
8
+ foreach ($tabs as $key=>$name)
9
+ printf('<a href="options-general.php?page=mlang&tab=%s" class="nav-tab %s">%s</a>', $key, $key == $active_tab ? 'nav-tab-active' : '', $name);?>
10
+ </h2><?php
11
+
12
+ switch($active_tab) {
13
+
14
+ // Languages tab
15
+ case 'lang':
16
 
17
  if (isset($_GET['error'])) {?>
18
  <div id="message" class="error fade"><p><?php echo $errors[$_GET['error']]; ?></p></div><?php
19
  }?>
20
 
21
  <div id="col-container">
22
+ <div id="col-right">
23
+ <div class="col-wrap"><?php
24
+ // displays the language list in a table
25
+ $list_table->display(); ?>
26
+ </div><!-- col-wrap -->
27
+ </div><!-- col-right -->
28
+
29
+ <div id="col-left">
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
+ // The term fields are used as follows :
37
+ // name -> language name (used only for display)
38
+ // slug -> language code (ideally 2-letters ISO 639-1 language code but I currently use it only as slug so it doesn't matter)
39
+ // description -> WordPress Locale for the language. Here if something wrong is used, the .mo files will not be loaded...
40
+
41
+ // adds noheader=true in the action url to allow using wp_redirect when processing the form ?>
42
+ <form id="add-lang" method="post" action="admin.php?page=mlang&amp;noheader=true" class="validate">
43
+ <?php wp_nonce_field('add-lang', '_wpnonce_add-lang');
44
+
45
+ if ($action=='edit') {?>
46
+ <input type="hidden" name="action" value="update" />
47
+ <input type="hidden" name="lang_id" value="<?php echo esc_attr($edit_lang->term_id);?>" /><?php
48
+ }
49
+ else { ?>
50
+ <input type="hidden" name="action" value="add" /><?php
51
+ }?>
52
+
53
+ <div class="form-field">
54
+ <label for="lang_list"><?php _e('Choose a language', 'polylang');?></label>
55
+ <select name="lang_list" id="lang_list">
56
+ <option value=""></option>';<?php
57
+ include(PLL_INC.'/languages.php');
58
+ foreach ($languages as $key=>$lang) {
59
+ printf("<option value='%s-%s'>%s</option>\n", esc_attr($key), esc_attr($lang[0]), esc_html($lang[1]));
60
+ } ?>
61
+ </select>
62
+ <p><?php _e('You can choose a language in the list or directly edit it below.', 'polylang');?></p>
63
+ </div>
64
+
65
+ <div class="form-field form-required">
66
+ <label for="name"><?php _e('Full name', 'polylang');?></label>
67
+ <input name="name" id="name" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->name);?>" size="40" aria-required="true" />
68
+ <p><?php _e('The name is how it is displayed on your site (for example: English).', 'polylang');?></p>
69
+ </div>
70
+
71
+ <div class="form-field form-required">
72
+ <label for="description"><?php _e('Locale', 'polylang');?></label><?php
73
+ printf('<input name="description" id="description" type="text" value="%s" size="5" maxlength="5" aria-required="true" />',
74
+ $action=='edit' ? esc_attr($edit_lang->description) : '');?>
75
+ <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>
76
+ </div>
77
+
78
+ <div class="form-field">
79
+ <label for="slug"><?php _e('Language code', 'polylang');?></label>
80
+ <input name="slug" id="slug" type="text" value="<?php if ($action=='edit') echo esc_attr($edit_lang->slug);?>" size="2" maxlength="2"/>
81
+ <p><?php _e('2-letters ISO 639-1 language code (for example: en)', 'polylang');?></p>
82
+ </div>
83
+
84
+ <?php submit_button( $action == 'edit' ? __('Update') : __('Add new language', 'polylang'), 'button'); // since WP 3.1 ?>
85
+
86
+ </form>
87
+ </div><!-- form-wrap -->
88
+ </div><!-- col-wrap -->
89
+ </div><!-- col-left -->
90
+ </div><!-- col-container --><?php
91
+ break;
92
+
93
+ // menu tab
94
+ case 'menus': ?>
95
 
96
  <div class="form-wrap">
97
+ <form id="nav-menus-lang" method="post" action="admin.php?page=mlang&tab=menus" class="validate">
98
+ <?php wp_nonce_field('nav-menus-lang', '_wpnonce_nav-menus-lang');?>
99
+ <input type="hidden" name="action" value="nav-menus" /><?php
100
+
101
+ foreach ( $locations as $location => $description ) {?>
102
+ <h3><?php echo esc_html($description); ?></h3>
103
+ <table class="form-table"><?php
104
+ foreach ($listlanguages as $language) {?>
105
+ <tr><?php printf('<th><label for="menu-lang-%1$s-%2$s">%3$s</label></th>', esc_attr($location), esc_attr($language->slug), esc_html($language->name));?>
106
+ <td><?php printf('<select name="menu-lang[%1$s][%2$s]" id="menu-lang-%1$s-%2$s">', esc_attr($location), esc_attr($language->slug));?>
107
+ <option value="0"></option><?php
108
+ foreach ($menus as $menu) {
109
+ printf(
110
+ "<option value='%d'%s>%s</option>\n",
111
+ esc_attr($menu->term_id),
112
+ isset($menu_lang[$location][$language->slug]) && $menu_lang[$location][$language->slug] == $menu->term_id ? ' selected="selected"' : '',
113
+ esc_html($menu->name)
114
+ );
115
+ } ?>
116
+ </select></td>
117
+ </tr><?php
118
+ }?>
119
+ <tr>
120
+ <th><?php _e('Language switcher', 'polylang') ?></th>
121
+ <td><?php
122
+ foreach ($menu_options as $key => $str)
123
+ printf('<label><input name="menu-lang[%1$s][%2$s]" type="checkbox" value="1" %3$s /> %4$s</label>',
124
+ esc_attr($location), esc_attr($key), $menu_lang[$location][$key] ? 'checked="checked"' :'', esc_html($str));?>
125
+ </td>
126
+ </tr>
127
+ </table><?php
128
+ }
129
+
130
+ submit_button(); // since WP 3.1 ?>
131
+
132
+ </form>
133
+ </div><!-- form-wrap --><?php
134
+ break;
135
+
136
+ // settings tab
137
+ case 'settings': ?>
 
 
 
138
 
139
  <div class="form-wrap">
140
+ <form id="options-lang" method="post" action="admin.php?page=mlang&tab=settings" class="validate">
141
+ <?php wp_nonce_field('options-lang', '_wpnonce_options-lang');?>
142
+ <input type="hidden" name="action" value="options" />
143
+
144
+ <table class="form-table">
145
+
146
+ <tr>
147
+ <th><label for='default_lang'><?php _e('Default language', 'polylang');?></label></th>
148
+ <td>
149
+ <select name="default_lang" id="default_lang"><?php
150
+ foreach ($listlanguages as $language) {
151
+ printf(
152
+ "<option value='%s'%s>%s</option>\n",
153
+ esc_attr($language->slug),
154
+ $options['default_lang'] == $language->slug ? ' selected="selected"' : '',
155
+ esc_html($language->name)
156
+ );
157
+ } ?>
158
+ </select>
159
+ </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  </tr><?php
 
 
161
 
162
+ // posts or terms without language set
163
+ if (!empty($posts) || !empty($terms) && $options['default_lang']) {
164
+
165
+ if (!empty($posts))
166
+ echo '<input type="hidden" name="posts" value="'.esc_attr($posts).'" />';
167
+ if (!empty($terms))
168
+ echo '<input type="hidden" name="terms" value="'.esc_attr($terms).'" />';?>
169
+
170
+ <tr>
171
+ <th></th>
172
+ <td>
173
+ <label style="color: red"><?php
174
+ printf(
175
+ '<input name="fill_languages" type="checkbox" value="1" /> %s',
176
+ __('There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?', 'polylang')
177
+ );?>
178
+ </label>
179
+ </td>
180
+ </tr><?php
181
+ }?>
182
+
183
+ <tr>
184
+ <th><?php _e('Detect browser language', 'polylang');?></th>
185
+ <td>
186
+ <label><?php
187
+ printf(
188
+ '<input name="browser" type="checkbox" value="1" %s /> %s',
189
+ $options['browser'] ? 'checked="checked"' :'',
190
+ __('When the front page is visited, set the language according to the browser preference', 'polylang')
191
+ );?>
192
+ </label>
193
+ </td>
194
+ </tr>
195
+
196
+ <tr>
197
+ <th><?php _e('URL modifications', 'polylang') ?></th>
198
+ <td scope="row">
199
+ <label><?php
200
+ printf(
201
+ '<input name="rewrite" type="radio" value="0" %s /> %s %s',
202
+ $options['rewrite'] ? '' : 'checked="checked"',
203
+ __('Keep /language/ in pretty permalinks. Example:', 'polylang'),
204
+ '<code>'.esc_html(home_url('language/en/')).'</code>'
205
+ );?>
206
+ </label>
207
+ <label><?php
208
+ printf(
209
+ '<input name="rewrite" type="radio" value="1" %s /> %s %s',
210
+ $options['rewrite'] ? 'checked="checked"' : '',
211
+ __('Remove /language/ in pretty permalinks. Example:', 'polylang'),
212
+ '<code>'.esc_html(home_url('en/')).'</code>'
213
+ );?>
214
+ </label>
215
+ <label><?php
216
+ printf(
217
+ '<input name="hide_default" type="checkbox" value="1" %s /> %s',
218
+ $options['hide_default'] ? 'checked="checked"' :'',
219
+ __('Hide URL language information for default language', 'polylang')
220
+ );?>
221
+ </label>
222
+ </td>
223
+ </tr>
224
 
225
+ </table>
226
 
227
+ <?php submit_button(); // since WP 3.1 ?>
 
228
 
229
+ </form>
230
+ </div><!-- form-wrap --><?php
231
+ break;
232
 
233
+ default:
234
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  }?>
236
 
237
+ </div><!-- wrap -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
include/languages.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $languages = array(
3
+ 'ar'=>array('ar','العربية','rtl'),
4
+ 'bg'=>array('bg_BG','български'),
5
+ 'bs'=>array('bs_BA','Bosanski'),
6
+ 'ca'=>array('ca','Català'),
7
+ 'cs'=>array('cs_CZ','Čeština'),
8
+ 'da'=>array('da_DK','Dansk'),
9
+ 'de'=>array('de_DE','Deutsch'),
10
+ 'el'=>array('el','Ελληνικά'),
11
+ 'en'=>array('en_US','English'),
12
+ 'eo'=>array('eo','Esperanto'),
13
+ 'es'=>array('es_ES','Español'),
14
+ 'et'=>array('et','Eesti'),
15
+ 'fa'=>array('fa_IR','فارسی','rtl'),
16
+ 'fi'=>array('fi','Suomi'),
17
+ 'fr'=>array('fr_FR','Français'),
18
+ 'fy'=>array('fy','Frysk'),
19
+ 'gl'=>array('gl_ES','Galego'),
20
+ 'he'=>array('he_IL','עברית','rtl'),
21
+ 'hr'=>array('hr','Hrvatski'),
22
+ 'hu'=>array('hu_HU','Magyar'),
23
+ 'id'=>array('id_ID','Bahasa Indonesia'),
24
+ 'it'=>array('it_IT','Italiano'),
25
+ 'ja'=>array('ja','日本語'),
26
+ 'ko'=>array('ko_KR','한국어'),
27
+ 'lv'=>array('lv','Latviešu valoda'),
28
+ 'mk'=>array('mk_MK','македонски јазик'),
29
+ 'my'=>array('my_MM','ဗမာစာ'),
30
+ 'nb'=>array('nb_NO','Norsk'),
31
+ 'nl'=>array('nl_NL','Nederlands'),
32
+ 'pl'=>array('pl_PL','Polski'),
33
+ 'pt'=>array('pt_PT','Português'),
34
+ 'ru'=>array('ru_RU','Русский'),
35
+ 'si'=>array('si_LK','සිංහල'),
36
+ 'sk'=>array('sk_SK','Slovenčina'),
37
+ 'sl'=>array('sl_SI','Slovenščina'),
38
+ 'sq'=>array('sq','Shqip'),
39
+ 'sr'=>array('sr_RS','Српски језик'),
40
+ 'sv'=>array('sv_SE','Svenska'),
41
+ 'th'=>array('th','ไทย'),
42
+ 'tr'=>array('tr_TR','Türkçe'),
43
+ 'ug'=>array('ug_CN','Uyƣurqə'),
44
+ 'uk'=>array('uk','Українська'),
45
+ 'zh'=>array('zh_CN','中文'),
46
+ );
47
+ ?>
include/list-table.php CHANGED
@@ -19,6 +19,7 @@ class Polylang_List_Table extends WP_List_Table {
19
  switch($column_name){
20
  case 'description':
21
  case 'slug':
 
22
  case 'count':
23
  return $item[$column_name];
24
  default:
@@ -46,10 +47,12 @@ class Polylang_List_Table extends WP_List_Table {
46
 
47
  function get_columns(){
48
  $columns = array(
49
- 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
 
50
  'name' => __('Full name', 'polylang'),
51
  'description' => __('Locale', 'polylang'),
52
  'slug' => __('Code', 'polylang'),
 
53
  'count' => __('Posts', 'polylang')
54
  );
55
  return $columns;
19
  switch($column_name){
20
  case 'description':
21
  case 'slug':
22
+ case 'flag':
23
  case 'count':
24
  return $item[$column_name];
25
  default:
47
 
48
  function get_columns(){
49
  $columns = array(
50
+ // FIXME checkboxes are useles for now
51
+ // 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
52
  'name' => __('Full name', 'polylang'),
53
  'description' => __('Locale', 'polylang'),
54
  'slug' => __('Code', 'polylang'),
55
+ 'flag' => __('Flag', 'polylang'),
56
  'count' => __('Posts', 'polylang')
57
  );
58
  return $columns;
include/personal-options.php CHANGED
@@ -1,4 +1,6 @@
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>
@@ -10,7 +12,7 @@
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>
1
+ <?php
2
+ // allows each user to choose the admin language in the Profile panel
3
+ ?>
4
  <tr>
5
  <th><label for='user_lang'><?php _e('Admin language', 'polylang');?></label></th>
6
  <td>
12
  "<option value='%s'%s>%s</option>\n",
13
  esc_attr($language->description),
14
  get_user_meta($profileuser->ID, 'user_lang', true) == $language->description ? ' selected="selected"' : '',
15
+ esc_html($language->name)
16
  );
17
  } ?>
18
  </select>
include/post-metabox.php CHANGED
@@ -1,22 +1,22 @@
1
- <?php // allowing to choose the post's language
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(
9
  "<option value='%s'%s>%s</option>\n",
10
  esc_attr($language->slug),
11
  $language == $lang ? ' selected="selected"' : '',
12
- esc_attr($language->name)
13
  );
14
  } ?>
15
  </select><br />
16
  </p>
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>
1
+ <?php
2
+ // allowing to choose the post's language
3
+ // NOTE: the class "tags-input" allows to include the field in the autosave $_POST (see autosave.js)
4
+ ?>
5
  <p><em><?php $post_type == 'page' ? _e('Page\'s language:', 'polylang') : _e('Post\'s language:', 'polylang');?></em></p>
6
  <p>
7
+ <select name="post_lang_choice" id="post_lang_choice"><?php
8
+ if (PLL_DISPLAY_ALL) // for those who want undefined language
9
+ echo '<option value="0"></option>';
10
  foreach ($listlanguages as $language) {
11
  printf(
12
  "<option value='%s'%s>%s</option>\n",
13
  esc_attr($language->slug),
14
  $language == $lang ? ' selected="selected"' : '',
15
+ esc_html($language->name)
16
  );
17
  } ?>
18
  </select><br />
19
  </p>
20
+ <div id="post-translations"><?php
21
+ include(PLL_INC.'/post-translations.php'); // allowing to determine the linked posts ?>
 
 
 
22
  </div>
include/post-translations.php CHANGED
@@ -9,27 +9,26 @@
9
  <tbody>
10
  <?php foreach ($listlanguages as $language) {
11
  if ($language != $lang) {
12
- $value = $this->get_translated_post($post_ID, $language);
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),
20
  esc_attr($language->slug),
21
  esc_attr($value)
22
  );
23
  if ($lang) {
24
  $link = $value ?
25
  sprintf(
26
- '<a href="%s">%s</a>',
27
- esc_url(admin_url('post.php?action=edit&amp;post=' . $value)),
28
  __('Edit','polylang')
29
  ) :
30
  sprintf(
31
- '<a href="%s">%s</a>',
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
9
  <tbody>
10
  <?php foreach ($listlanguages as $language) {
11
  if ($language != $lang) {
12
+ $value = $this->get_translation('post', $post_ID, $language);
13
  if (isset($_GET['from_post']))
14
  $value = $this->get_post($_GET['from_post'], $language); ?>
15
  <tr>
16
+ <td><?php echo esc_html($language->name);?></td><?php
17
  printf(
18
+ '<td><input name="tr_lang[%1$s]" id="tr_lang_%1$s" class="tags-input" type="text" value="%2$s" size="6"/></td>',
 
19
  esc_attr($language->slug),
20
  esc_attr($value)
21
  );
22
  if ($lang) {
23
  $link = $value ?
24
  sprintf(
25
+ '<a href="%1$s">%2$s</a>',
26
+ esc_url(admin_url('post.php?action=edit&post=' . $value)),
27
  __('Edit','polylang')
28
  ) :
29
  sprintf(
30
+ '<a href="%1$s">%2$s</a>',
31
+ esc_url(admin_url('post-new.php?post_type=' . $post_type . '&from_post=' . $post_ID . '&new_lang=' . $language->slug)),
32
  __('Add new','polylang')
33
  );?>
34
  <td><?php echo $link ?><td><?php
include/term-translations.php CHANGED
@@ -1,14 +1,15 @@
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>
6
  <td><?php
7
  }
8
- else { // add term form?>
 
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)
@@ -20,26 +21,26 @@ else { // add term form?>
20
 
21
  // look for any existing translation in this language
22
  if ($language != $lang) {
23
- if (isset($term_id) && $translation_id = $this->get_translated_term($term_id, $language))
24
  $translation = get_term($translation_id, $taxonomy);
25
  if (isset($_GET['from_tag']) && isset($_GET['from_lang'])) {
26
  if ($_GET['from_lang'] == $language->slug)
27
  $translation = get_term($_GET['from_tag'], $taxonomy);
28
- elseif ($translation_id = $this->get_translated_term($_GET['from_tag'], $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
43
  } ?>
44
  </select>
45
  </td><?php
@@ -52,7 +53,7 @@ else { // add term form?>
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(
55
- 'edit-tags.php?taxonomy=%s&amp;from_tag=%s&amp;from_lang=%s&amp;new_lang=%s',
56
  $taxonomy,
57
  $term_id,
58
  $lang->slug,
@@ -64,11 +65,12 @@ else { // add term form?>
64
  }
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,
73
  $translation->term_id
74
  )));
@@ -79,7 +81,9 @@ else { // add term form?>
79
  } // if (!$value)
80
  } // foreach ?>
81
  </tbody>
82
- </table>
83
- <?php if (isset($term_id)) { // edit term form?>
84
- </td><?php
 
 
85
  }
1
  <?php
2
  // displays the translations fields
3
 
4
+ if (isset($term_id)) {
5
+ // edit term form?>
6
  <th scope="row" valign="top"><?php _e('Translations', 'polylang');?></th>
7
  <td><?php
8
  }
9
+ else {
10
+ // add term form?>
11
  <label><?php _e('Translations', 'polylang');?></label><?php
12
+ }?>
 
13
  <table>
14
  <thead><tr><?php
15
  foreach (array(__('Language', 'polylang'), __('Translation', 'polylang'), __('Edit', 'polylang')) as $title)
21
 
22
  // look for any existing translation in this language
23
  if ($language != $lang) {
24
+ if (isset($term_id) && $translation_id = $this->get_translation('term', $term_id, $language))
25
  $translation = get_term($translation_id, $taxonomy);
26
  if (isset($_GET['from_tag']) && isset($_GET['from_lang'])) {
27
  if ($_GET['from_lang'] == $language->slug)
28
  $translation = get_term($_GET['from_tag'], $taxonomy);
29
+ elseif ($translation_id = $this->get_translation('term', $_GET['from_tag'], $language))
30
  $translation = get_term($translation_id, $taxonomy);
31
  }?>
32
 
33
+ <tr><td><?php echo esc_html($language->name);?></td><?php
34
 
35
  // no translation exits in this language
36
  if (!$translation) {
37
  $translations = $this->get_terms_not_translated($taxonomy, $language, $lang);
38
  if (!empty($translations)) { ?>
39
  <td>
40
+ <select name="tr_lang[<?php echo esc_attr($language->slug);?>]" id="tr_lang_<?php echo esc_attr($language->slug);?>">
41
  <option value="0"></option><?php
42
  foreach ($translations as $translation) { ?>
43
+ <option value="<?php echo esc_attr($translation->term_id);?>"><?php echo esc_html($translation->name);?></option><?php
44
  } ?>
45
  </select>
46
  </td><?php
53
  // do not display the add new link in add term form ($term_id not set !!!)
54
  if (isset($term_id)) {
55
  $link = esc_url(admin_url(sprintf(
56
+ 'edit-tags.php?taxonomy=%1$s&from_tag=%2$d&from_lang=%3$s&new_lang=%4$s',
57
  $taxonomy,
58
  $term_id,
59
  $lang->slug,
65
  }
66
 
67
  // a translation exists
68
+ else {
69
+ printf('<td><input type="hidden" name="tr_lang[%s]" value="%d" />%s</td>',
70
+ esc_attr($language->slug), esc_attr($translation->term_id) ,esc_html($translation->name));?>
71
  <td><?php
72
  $link = esc_url(admin_url(sprintf(
73
+ 'edit-tags.php?action=edit&amp;taxonomy=%1$s&tag_ID=%2$d',
74
  $taxonomy,
75
  $translation->term_id
76
  )));
81
  } // if (!$value)
82
  } // foreach ?>
83
  </tbody>
84
+ </table><?php
85
+
86
+ if (isset($term_id)) {
87
+ // edit term form?>
88
+ </td><?php
89
  }
include/widget.php CHANGED
@@ -1,13 +1,14 @@
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
 
@@ -16,7 +17,7 @@ class Polylang_Widget extends WP_Widget {
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
 
22
  // javascript to switch the language when using a dropdown list
@@ -25,7 +26,7 @@ class Polylang_Widget extends WP_Widget {
25
  $url = home_url('?lang=');
26
  $home_url = get_option('home');
27
  $options = get_option('polylang');
28
- $default = $options['hide_default'] ? $options['default_lang'] : '';
29
 
30
  $js = "
31
  <script type='text/javascript'>
@@ -44,46 +45,35 @@ class Polylang_Widget extends WP_Widget {
44
 
45
  // updates the widget options
46
  function update( $new_instance, $old_instance ) {
47
- $instance = $old_instance;
48
  $instance['title'] = strip_tags($new_instance['title']);
49
- $instance['show_names'] = !empty($new_instance['show_names']) ? 1 : 0;
50
- $instance['show_flags'] = !empty($new_instance['show_flags']) ? 1 : 0;
51
- $instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
52
 
53
  return $instance;
54
  }
55
 
56
  // displays the widget form
57
  function form($instance) {
58
- $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'show_names' => 1, 'show_flags' => 0, 'dropdown' => 0) ); // default values
 
59
 
60
  // title
61
- $id = $this->get_field_id('title');
62
- $name = $this->get_field_name('title');
63
- $title = sprintf('<p><label for="%s">%s</label><input class="widefat" id="%s" name="%s" type="text" value="%s" /></p>',
64
- $id, __('Title:', 'polylang'), $id, $name, esc_attr($instance['title']));
65
-
66
- // language names checkbox
67
- $id = $this->get_field_id('show_names');
68
- $name = $this->get_field_name('show_names');
69
- $fields = sprintf('<input type="checkbox" class="checkbox" id="%s" name="%s"%s /> <label for="%s">%s</label><br />',
70
- $id, $name, $instance['show_names'] ? 'checked="checked"' : '', $id, __('Display language names', 'polylang'));
71
-
72
- // flags checkbox
73
- $id = $this->get_field_id('show_flags');
74
- $name = $this->get_field_name('show_flags');
75
- $fields .= sprintf('<input type="checkbox" class="checkbox" id="%s" name="%s"%s /> <label for="%s">%s</label><br />',
76
- $id, $name, $instance['show_flags'] ? 'checked="checked"' : '', $id, __('Display flags', 'polylang'));
77
-
78
- // dropdown checkbox
79
- $id = $this->get_field_id('dropdown');
80
- $name = $this->get_field_name('dropdown');
81
- $fields .= sprintf('<input type="checkbox" class="checkbox" id="%s" name="%s"%s /> <label for="%s">%s</label><br />',
82
- $id, $name, $instance['dropdown'] ? 'checked="checked"' : '', $id, __('Display as dropdown', 'polylang'));
83
 
84
  echo $title.'<p>'.$fields.'</p>';
85
  }
86
-
87
- } // Class Polylang_Widget
88
-
89
  ?>
1
  <?php
2
 
3
+ // the language switcher widget
4
  class Polylang_Widget extends WP_Widget {
5
  function __construct() {
6
+ parent::__construct('polylang', __('Language Switcher', 'polylang'), array( 'description' => __( 'Displays a language switcher', 'polylang')));
 
7
  }
8
 
9
  // displays the widget
10
  function widget($args, $instance) {
11
+ global $polylang;
12
  extract($args);
13
  extract($instance);
14
 
17
  echo "$before_widget\n";
18
  if ($title)
19
  echo $before_title . $title . $after_title;
20
+ $polylang->the_languages($instance);
21
  echo "$after_widget\n";
22
 
23
  // javascript to switch the language when using a dropdown list
26
  $url = home_url('?lang=');
27
  $home_url = get_option('home');
28
  $options = get_option('polylang');
29
+ $default = $options['hide_default'] ? esc_js($options['default_lang']) : '';
30
 
31
  $js = "
32
  <script type='text/javascript'>
45
 
46
  // updates the widget options
47
  function update( $new_instance, $old_instance ) {
 
48
  $instance['title'] = strip_tags($new_instance['title']);
49
+ foreach ( array('show_names', 'show_flags','dropdown', 'force_home') as $key)
50
+ $instance[$key] = !empty($new_instance[$key]) ? 1 : 0;
 
51
 
52
  return $instance;
53
  }
54
 
55
  // displays the widget form
56
  function form($instance) {
57
+ // default values
58
+ $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'show_names' => 1, 'show_flags' => 0, 'dropdown' => 0, 'force_home' => 0) );
59
 
60
  // title
61
+ $title = sprintf('<p><label for="%1$s">%2$s</label><input class="widefat" id="%1$s" name="%3$s" type="text" value="%4$s" /></p>',
62
+ $this->get_field_id('title'), __('Title:', 'polylang'), $this->get_field_name('title'), esc_attr($instance['title']));
63
+
64
+ $widget_options = array (
65
+ 'show_names' => __('Displays language names', 'polylang'),
66
+ 'show_flags' => __('Displays flags', 'polylang'),
67
+ 'dropdown' => __('Displays as dropdown', 'polylang'),
68
+ 'force_home' => __('Forces link to front page', 'polylang')
69
+ );
70
+
71
+ $fields = '';
72
+ foreach ($widget_options as $key=>$str)
73
+ $fields .= sprintf('<input type="checkbox" class="checkbox" id="%1$s" name="%2$s" %3$s /> <label for="%1$s">%4$s</label><br />',
74
+ $this->get_field_id($key), $this->get_field_name($key), $instance[$key] ? 'checked="checked"' : '', esc_html($str));
 
 
 
 
 
 
 
 
75
 
76
  echo $title.'<p>'.$fields.'</p>';
77
  }
78
+ }
 
 
79
  ?>
js/admin.js CHANGED
@@ -1,30 +1,111 @@
1
  jQuery(document).ready(function($) {
2
 
3
- // ajax for post metabox
4
- jQuery('#post_lang_choice').change( function() {
5
- var data = {
6
- action: 'post_lang_choice',
7
- lang: jQuery(this).attr('value'),
8
- post_id: jQuery('#post_ID').attr('value')
9
- }
10
-
11
- jQuery.post(ajaxurl, data , function(response) {
12
- jQuery("#post-translations").html(response);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  });
14
- })
15
-
16
- // ajax for term edit
17
- jQuery('#term_lang_choice').change( function() {
18
- var data = {
19
- action: 'term_lang_choice',
20
- lang: jQuery(this).attr('value'),
21
- term_id: jQuery("input[name='tag_ID']").attr('value'),
22
- taxonomy: jQuery("input[name='taxonomy']").attr('value')
23
- }
24
-
25
- jQuery.post(ajaxurl, data, function(response) {
26
- jQuery("#term-translations").html(response);
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  });
28
- })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  });
1
  jQuery(document).ready(function($) {
2
 
3
+ // collect taxonomies - code partly copied from WordPress
4
+ var taxonomies = new Array();
5
+ $('.categorydiv').each( function(){
6
+ var this_id = $(this).attr('id'), taxonomyParts, taxonomy;
7
+
8
+ taxonomyParts = this_id.split('-');
9
+ taxonomyParts.shift();
10
+ taxonomy = taxonomyParts.join('-');
11
+ taxonomies.push(taxonomy); // store the taxonomy for future use
12
+
13
+ // add our hidden field in the new category form - for each hierarchical taxonomy
14
+ jQuery('#' + taxonomy + '-add-submit').before($('<input />')
15
+ .attr('type', 'hidden')
16
+ .attr('id', taxonomy + '-lang')
17
+ .attr('name', 'term_lang_choice')
18
+ .attr('value', jQuery('#post_lang_choice').attr('value'))
19
+ );
20
+ });
21
+
22
+ // ajax for post metabox
23
+ jQuery('#post_lang_choice').change( function() {
24
+ var data = {
25
+ action: 'post_lang_choice',
26
+ lang: jQuery(this).attr('value'),
27
+ taxonomies: taxonomies,
28
+ post_id: jQuery('#post_ID').attr('value')
29
+ }
30
+
31
+ jQuery.post(ajaxurl, data , function(response) {
32
+ var res = wpAjax.parseAjaxResponse(response, 'ajax-response');
33
+ $.each(res.responses, function() {
34
+ switch(this.what) {
35
+ case 'translations':
36
+ jQuery('#post-translations').html(this.data); // translations fields
37
+ break;
38
+ case 'taxonomy':
39
+ tax = this.data;
40
+ jQuery('#' + tax + 'checklist').html(this.supplemental.all);
41
+ jQuery('#' + tax + 'checklist-pop').html(this.supplemental.populars);
42
+ jQuery('#new' + tax + '_parent').replaceWith(this.supplemental.dropdown);
43
+ jQuery('#' + tax + '-lang').val(jQuery('#post_lang_choice').attr('value')); // hidden field
44
+ break;
45
+ default:
46
+ break;
47
+ }
48
  });
49
+ });
50
+ });
51
+
52
+ // replace WP class by our own
53
+ jQuery('a.tagcloud-link').addClass('polylang-tagcloud-link');
54
+ jQuery('a.tagcloud-link').removeClass('tagcloud-link');
55
+
56
+ // now copy paste WP code and just add the language in the $_POST variable
57
+ jQuery('.polylang-tagcloud-link').click( function() {
58
+ var id = $(this).attr('id');
59
+ var tax = id.substr(id.indexOf('-')+1);
60
+
61
+ var data = {
62
+ action: 'get-tagcloud',
63
+ lang: jQuery('#post_lang_choice').attr('value'),
64
+ tax: tax
65
+ }
66
+
67
+ $.post(ajaxurl, data, function(r, stat) {
68
+ if ( 0 == r || 'success' != stat )
69
+ r = wpAjax.broken;
70
+
71
+ r = $('<p id="tagcloud-'+tax+'" class="the-tagcloud">'+r+'</p>');
72
+ $('a', r).click(function(){
73
+ tagBox.flushTags( $(this).closest('.inside').children('.tagsdiv'), this);
74
+ return false;
75
  });
76
+
77
+ $('#'+id).after(r);
78
+ });
79
+
80
+ $(this).unbind().click(function(){
81
+ $(this).siblings('.the-tagcloud').toggle();
82
+ return false;
83
+ });
84
+ return false;
85
+ });
86
+
87
+ // ajax for term edit
88
+ jQuery('#term_lang_choice').change(function() {
89
+ var data = {
90
+ action: 'term_lang_choice',
91
+ lang: jQuery(this).attr('value'),
92
+ term_id: jQuery("input[name='tag_ID']").attr('value'),
93
+ taxonomy: jQuery("input[name='taxonomy']").attr('value')
94
+ }
95
+
96
+ jQuery.post(ajaxurl, data, function(response) {
97
+ jQuery("#term-translations").html(response);
98
+ });
99
+ });
100
+
101
+ // languages form
102
+ jQuery('#lang_list').change(function() {
103
+ value = jQuery(this).attr('value');
104
+ slug = value.substr(0, 2);
105
+ locale = value.substr(3, 5);
106
+ jQuery('input[name="slug"]').val(slug);
107
+ jQuery('input[name="description"]').val(locale);
108
+ jQuery('input[name="name"]').val($("select option:selected").text());
109
+ });
110
 
111
  });
languages/polylang-de_DE.mo CHANGED
Binary file
languages/polylang-de_DE.po CHANGED
@@ -2,353 +2,371 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: polylang\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2011-11-22 09:39+0100\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: F. Demarle\n"
8
  "Language-Team: \n"
 
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
- "X-Poedit-Language: \n"
14
- "X-Poedit-Country: \n"
15
  "X-Poedit-SourceCharset: utf-8\n"
16
- "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
17
  "X-Poedit-Basepath: .\n"
18
- "X-Poedit-Bookmarks: \n"
19
  "X-Poedit-SearchPath-0: ..\n"
20
- "X-Textdomain-Support: yes"
21
 
22
- #: polylang.php:194
23
- #@ polylang
24
  msgid "Error: Upgrade directory doesn't exist!"
25
  msgstr ""
26
 
27
- #: polylang.php:195
28
- #@ polylang
29
  msgid "Please create"
30
  msgstr ""
31
 
32
- #: polylang.php:202
33
- #@ polylang
34
  msgid "Error: Backup of local flags failed!"
35
  msgstr ""
36
 
37
- #: polylang.php:203
38
- #@ polylang
39
  msgid "Please backup"
40
  msgstr ""
41
 
42
- #: polylang.php:218
43
- #@ polylang
44
  msgid "Error: Restore of local flags failed!"
45
  msgstr ""
46
 
47
- #: polylang.php:219
48
- #@ polylang
49
  msgid "Please restore your local flags"
50
  msgstr ""
51
 
52
- #: include/add-term-form.php:3
53
- #: include/admin.php:349
54
- #: include/admin.php:503
55
- #: include/edit-term-form.php:6
56
- #: include/list-table.php:12
57
- #: include/post-translations.php:4
58
- #: include/term-translations.php:14
59
- #@ polylang
60
  msgid "Language"
61
  msgstr "Sprache"
62
 
63
- #: include/add-term-form.php:10
64
- #: include/edit-term-form.php:18
65
- #@ polylang
66
  msgid "Sets the language"
67
  msgstr "definiert die Sprache"
68
 
69
- #: include/widget.php:5
70
- #@ polylang
71
- msgid "Displays a language switcher"
72
- msgstr "Zeigen die Sprachenliste"
73
-
74
- #: include/widget.php:6
75
- #@ polylang
76
  msgid "Language Switcher"
77
  msgstr "Sprachenliste"
78
 
79
- #: include/widget.php:64
80
- #@ polylang
 
 
 
 
 
81
  msgid "Title:"
82
  msgstr "Titel :"
83
 
84
- #: include/widget.php:70
85
- #@ polylang
86
- msgid "Display language names"
 
87
  msgstr "Zeigen die Sprachen Namen"
88
 
89
- #: include/widget.php:76
90
- #@ polylang
91
- msgid "Display flags"
 
92
  msgstr "Zeigen Flaggen"
93
 
94
- #: include/widget.php:82
95
- #@ polylang
96
- msgid "Display as dropdown"
97
  msgstr "Als Auswahlbox darstellen"
98
 
99
- #: include/admin.php:90
100
- #@ default
 
 
 
 
 
 
 
 
101
  msgid "Settings"
102
  msgstr "Einstellungen"
103
 
104
- #: include/admin.php:97
105
- #: include/admin.php:393
106
- #: include/languages-form.php:14
107
- #: include/list-table.php:13
108
- #@ polylang
109
  msgid "Languages"
110
  msgstr "Sprachen"
111
 
112
- #: include/admin.php:310
 
 
 
 
 
 
113
  #, fuzzy
114
- #@ polylang
115
  msgid "Enter a valid WorPress locale"
116
  msgstr "Das WordPress Locale ist ungültig"
117
 
118
- #: include/admin.php:311
119
- #@ polylang
120
  msgid "The language code must be 2 characters long"
121
  msgstr "Der Sprachcode muss 2 Buchstaben lang sein"
122
 
123
- #: include/admin.php:312
124
- #@ polylang
125
  msgid "The language code must be unique"
126
  msgstr "Eine andere Sprache hat dem selben Sprachcode"
127
 
128
- #: include/admin.php:313
129
- #@ polylang
130
  msgid "The language must have a name"
131
  msgstr "Die Sprache muss einen Namen haben"
132
 
133
- #: include/admin.php:381
134
- #@ polylang
135
- msgid "Show all languages"
136
- msgstr "Zeigen alle Sprachen"
137
-
138
- #: include/admin.php:607
139
- #@ polylang
140
- msgid "Theme locations and languages"
141
- msgstr "Anordnung im Theme und Sprachen"
142
-
143
- #: include/admin.php:612
144
- #, php-format
145
- #@ polylang
146
- msgid "Please go to the %slanguages page%s to set theme locations and languages"
147
- msgstr "Du solltest zu der %sSprachen Seite%s gehen, um Anordnung im Theme und Sprachen zu definieren."
148
-
149
- #: include/admin.php:624
150
- #@ polylang
151
- msgid "The widget is displayed for:"
152
- msgstr "Zeigen das Widget für :"
153
-
154
- #: include/admin.php:627
155
- #@ polylang
156
- msgid "All languages"
157
- msgstr "Alle Sprachen"
158
 
159
- #: include/post-metabox.php:3
160
- #@ polylang
161
  msgid "Page's language:"
162
  msgstr "Sprache für die Seite :"
163
 
164
- #: include/post-metabox.php:3
165
- #@ polylang
166
  msgid "Post's language:"
167
  msgstr "Sprache für die Artikel :"
168
 
169
- #: include/term-translations.php:5
170
- #: include/term-translations.php:9
171
- #@ polylang
172
  msgid "Translations"
173
  msgstr "Übersetzungen"
174
 
175
- #: include/term-translations.php:14
176
- #@ polylang
177
  msgid "Translation"
178
  msgstr "Übersetzung"
179
 
180
- #: include/list-table.php:32
181
- #: include/post-translations.php:6
182
- #: include/post-translations.php:28
183
- #: include/term-translations.php:14
184
- #: include/term-translations.php:75
185
- #@ polylang
186
  msgid "Edit"
187
  msgstr "Bearbeiten"
188
 
189
- #: include/post-translations.php:33
190
- #: include/term-translations.php:61
191
- #@ polylang
192
  msgid "Add new"
193
  msgstr "Hinzufügen"
194
 
195
- #: include/list-table.php:33
196
- #@ polylang
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  msgid "Delete"
198
  msgstr "Löschen"
199
 
200
- #: include/languages-form.php:50
201
- #: include/list-table.php:50
202
- #@ polylang
203
  msgid "Full name"
204
  msgstr "Name"
205
 
206
- #: include/languages-form.php:56
207
- #: include/list-table.php:51
 
208
  #, fuzzy
209
- #@ polylang
210
  msgid "Locale"
211
  msgstr "Locale"
212
 
213
- #: include/list-table.php:52
214
- #@ polylang
215
  msgid "Code"
216
  msgstr "Code"
217
 
218
- #: include/list-table.php:53
219
- #@ polylang
 
 
 
 
 
220
  msgid "Posts"
221
  msgstr "Artikel"
222
 
223
- #: include/calendar.php:88
224
- #: include/calendar.php:96
 
 
 
 
 
 
 
 
225
  #, php-format
226
- #@ default
227
  msgid "View posts for %1$s %2$s"
228
  msgstr ""
229
 
230
- #: include/languages-form.php:33
231
- #@ polylang
232
  msgid "Edit language"
233
  msgstr "Sprache bearbeiten"
234
 
235
- #: include/languages-form.php:33
236
- #: include/languages-form.php:67
237
- #@ polylang
238
  msgid "Add new language"
239
  msgstr "Neue Sprache hinzufügen"
240
 
241
- #: include/languages-form.php:52
242
- #@ polylang
 
 
 
 
 
 
 
 
 
 
243
  msgid "The name is how it is displayed on your site (for example: English)."
244
  msgstr "Dieser Name wird dann auf der Website angezeigt (beispielweise : Deutsch)"
245
 
246
- #: include/languages-form.php:58
247
- #@ polylang
248
  msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
249
  msgstr "Wordpress Locale für die Sprache (beispielweise : de_DE). Du musst die .mo Datei für diese Sprache installieren."
250
 
251
- #: include/languages-form.php:62
252
- #@ polylang
253
  msgid "Language code"
254
  msgstr "Sprachcode"
255
 
256
- #: include/languages-form.php:64
257
- #@ polylang
258
  msgid "2-letters ISO 639-1 language code (for example: en)"
259
  msgstr "2 Buchstaben ISO 639-1 Sprachcode (beispielweise : de)"
260
 
261
- #: include/languages-form.php:67
262
- #@ default
263
  msgid "Update"
264
  msgstr "Aktualisieren"
265
 
266
- #: include/languages-form.php:79
267
- #@ polylang
268
- msgid "Menus"
269
- msgstr "Menüs"
270
-
271
- #: include/languages-form.php:87
272
- #@ polylang
273
- msgid "Theme location"
274
- msgstr "Anordnung im Theme"
275
-
276
- #: include/languages-form.php:131
277
- #@ polylang
278
- msgid "Options"
279
- msgstr "Einstellungen"
280
 
281
- #: include/languages-form.php:140
282
- #@ polylang
283
  msgid "Default language"
284
  msgstr "Standard Sprache"
285
 
286
- #: include/languages-form.php:169
 
287
  #, fuzzy
288
- #@ polylang
289
  msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
290
  msgstr "Es gibt Artikel, Seite, Kategorien oder Schlagwörter ohne Sprache definiert. Willst du alle zu standard Sprache definieren ?"
291
 
292
- #: include/languages-form.php:177
293
- #@ polylang
294
  msgid "Detect browser language"
295
  msgstr "Browser Spracherkennung"
296
 
297
- #: include/languages-form.php:183
298
- #@ polylang
299
  msgid "When the front page is visited, set the language according to the browser preference"
300
  msgstr "Wenn die Startseite besucht ist, definiert die Sprache durch den Browser Einstellung"
301
 
302
- #: include/languages-form.php:190
303
- #@ polylang
304
  msgid "URL modifications"
305
  msgstr "URL Veränderung"
306
 
307
- #: include/languages-form.php:196
308
- #@ polylang
309
  msgid "Keep /language/ in pretty permalinks. Example:"
310
  msgstr "/language/ in Permalinks behalten. Zum Beispiel :"
311
 
312
- #: include/languages-form.php:204
313
- #@ polylang
314
  msgid "Remove /language/ in pretty permalinks. Example:"
315
  msgstr "/language/ in Permalinks entfernen. Zum Beispiel :"
316
 
317
- #: include/languages-form.php:212
318
- #@ polylang
319
  msgid "Hide URL language information for default language"
320
  msgstr "URL Informationen für die Standardsprache verstecken"
321
 
322
- #: include/post-translations.php:1
323
- #@ polylang
324
  msgid "ID of pages in other languages:"
325
  msgstr "ID für die Seiten in andere Sprache :"
326
 
327
- #: include/post-translations.php:1
328
- #@ polylang
329
  msgid "ID of posts in other languages:"
330
  msgstr "ID für die Artikel in andere Sprache :"
331
 
332
- #: include/post-translations.php:5
333
- #@ polylang
334
  msgid "Page ID"
335
  msgstr "ID für die Seite"
336
 
337
- #: include/post-translations.php:5
338
- #@ polylang
339
  msgid "Post ID"
340
  msgstr "ID für die Artikel"
341
 
342
- #: include/personal-options.php:3
343
- #@ polylang
344
  msgid "Admin language"
345
  msgstr "Adminsprache"
346
 
347
- #. translators: Calendar caption: 1: month name, 2: 4-digit year
348
- #: include/calendar.php:62
349
- #, php-format
350
- #@ default
351
- msgctxt "calendar caption"
352
- msgid "%1$s %2$s"
353
- msgstr ""
354
-
2
  msgstr ""
3
  "Project-Id-Version: polylang\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-12-05 20:53+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; plural=n != 1;\n"
 
 
14
  "X-Poedit-SourceCharset: utf-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
16
  "X-Poedit-Basepath: .\n"
17
+ "X-Textdomain-Support: yes\n"
18
  "X-Poedit-SearchPath-0: ..\n"
 
19
 
20
+ # @ polylang
21
+ #: ../polylang.php:169
22
  msgid "Error: Upgrade directory doesn't exist!"
23
  msgstr ""
24
 
25
+ # @ polylang
26
+ #: ../polylang.php:170
27
  msgid "Please create"
28
  msgstr ""
29
 
30
+ # @ polylang
31
+ #: ../polylang.php:177
32
  msgid "Error: Backup of local flags failed!"
33
  msgstr ""
34
 
35
+ # @ polylang
36
+ #: ../polylang.php:178
37
  msgid "Please backup"
38
  msgstr ""
39
 
40
+ # @ polylang
41
+ #: ../polylang.php:193
42
  msgid "Error: Restore of local flags failed!"
43
  msgstr ""
44
 
45
+ # @ polylang
46
+ #: ../polylang.php:194
47
  msgid "Please restore your local flags"
48
  msgstr ""
49
 
50
+ # @ polylang
51
+ #: ../include/edit-term-form.php:6
52
+ #: ../include/term-translations.php:15
53
+ #: ../include/admin-filters.php:91
54
+ #: ../include/admin-filters.php:327
55
+ #: ../include/add-term-form.php:5
56
+ #: ../include/list-table.php:12
 
57
  msgid "Language"
58
  msgstr "Sprache"
59
 
60
+ # @ polylang
61
+ #: ../include/edit-term-form.php:19
62
+ #: ../include/add-term-form.php:13
63
  msgid "Sets the language"
64
  msgstr "definiert die Sprache"
65
 
66
+ # @ polylang
67
+ #: ../include/widget.php:6
 
 
 
 
 
68
  msgid "Language Switcher"
69
  msgstr "Sprachenliste"
70
 
71
+ # @ polylang
72
+ #: ../include/widget.php:6
73
+ msgid "Displays a language switcher"
74
+ msgstr "Zeigen die Sprachenliste"
75
+
76
+ # @ polylang
77
+ #: ../include/widget.php:62
78
  msgid "Title:"
79
  msgstr "Titel :"
80
 
81
+ # @ polylang
82
+ #: ../include/widget.php:65
83
+ #: ../include/admin.php:236
84
+ msgid "Displays language names"
85
  msgstr "Zeigen die Sprachen Namen"
86
 
87
+ # @ polylang
88
+ #: ../include/widget.php:66
89
+ #: ../include/admin.php:237
90
+ msgid "Displays flags"
91
  msgstr "Zeigen Flaggen"
92
 
93
+ # @ polylang
94
+ #: ../include/widget.php:67
95
+ msgid "Displays as dropdown"
96
  msgstr "Als Auswahlbox darstellen"
97
 
98
+ # @ polylang
99
+ #: ../include/widget.php:68
100
+ #: ../include/admin.php:238
101
+ msgid "Forces link to front page"
102
+ msgstr "Erfordet link zu Startseite"
103
+
104
+ # @ default
105
+ # @ polylang
106
+ #: ../include/admin.php:21
107
+ #: ../include/admin.php:209
108
  msgid "Settings"
109
  msgstr "Einstellungen"
110
 
111
+ # @ polylang
112
+ #: ../include/admin.php:28
113
+ #: ../include/admin.php:207
114
+ #: ../include/admin-filters.php:135
115
+ #: ../include/list-table.php:13
116
  msgid "Languages"
117
  msgstr "Sprachen"
118
 
119
+ # @ polylang
120
+ #: ../include/admin.php:208
121
+ msgid "Menus"
122
+ msgstr "Menüs"
123
+
124
+ # @ polylang
125
+ #: ../include/admin.php:225
126
  #, fuzzy
 
127
  msgid "Enter a valid WorPress locale"
128
  msgstr "Das WordPress Locale ist ungültig"
129
 
130
+ # @ polylang
131
+ #: ../include/admin.php:226
132
  msgid "The language code must be 2 characters long"
133
  msgstr "Der Sprachcode muss 2 Buchstaben lang sein"
134
 
135
+ # @ polylang
136
+ #: ../include/admin.php:227
137
  msgid "The language code must be unique"
138
  msgstr "Eine andere Sprache hat dem selben Sprachcode"
139
 
140
+ # @ polylang
141
+ #: ../include/admin.php:228
142
  msgid "The language must have a name"
143
  msgstr "Die Sprache muss einen Namen haben"
144
 
145
+ # @ polylang
146
+ #: ../include/admin.php:235
147
+ msgid "Displays a language switcher at the end of the menu"
148
+ msgstr "Zeigen die Sprachenliste"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
 
150
+ # @ polylang
151
+ #: ../include/post-metabox.php:5
152
  msgid "Page's language:"
153
  msgstr "Sprache für die Seite :"
154
 
155
+ # @ polylang
156
+ #: ../include/post-metabox.php:5
157
  msgid "Post's language:"
158
  msgstr "Sprache für die Artikel :"
159
 
160
+ # @ polylang
161
+ #: ../include/term-translations.php:6
162
+ #: ../include/term-translations.php:11
163
  msgid "Translations"
164
  msgstr "Übersetzungen"
165
 
166
+ # @ polylang
167
+ #: ../include/term-translations.php:15
168
  msgid "Translation"
169
  msgstr "Übersetzung"
170
 
171
+ # @ polylang
172
+ #: ../include/term-translations.php:15
173
+ #: ../include/term-translations.php:76
174
+ #: ../include/list-table.php:33
 
 
175
  msgid "Edit"
176
  msgstr "Bearbeiten"
177
 
178
+ # @ polylang
179
+ #: ../include/term-translations.php:62
 
180
  msgid "Add new"
181
  msgstr "Hinzufügen"
182
 
183
+ # @ polylang
184
+ #: ../include/admin-filters.php:123
185
+ msgid "Show all languages"
186
+ msgstr "Zeigen alle Sprachen"
187
+
188
+ # @ polylang
189
+ #: ../include/admin-filters.php:400
190
+ msgid "Theme locations and languages"
191
+ msgstr "Anordnung im Theme und Sprachen"
192
+
193
+ # @ polylang
194
+ #: ../include/admin-filters.php:405
195
+ #, php-format
196
+ msgid "Please go to the %slanguages page%s to set theme locations and languages"
197
+ msgstr "Du solltest zu der %sSprachen Seite%s gehen, um Anordnung im Theme und Sprachen zu definieren."
198
+
199
+ # @ polylang
200
+ #: ../include/admin-filters.php:416
201
+ msgid "The widget is displayed for:"
202
+ msgstr "Zeigen das Widget für :"
203
+
204
+ # @ polylang
205
+ #: ../include/admin-filters.php:417
206
+ msgid "All languages"
207
+ msgstr "Alle Sprachen"
208
+
209
+ # @ polylang
210
+ #: ../include/list-table.php:34
211
  msgid "Delete"
212
  msgstr "Löschen"
213
 
214
+ # @ polylang
215
+ #: ../include/list-table.php:52
216
+ #: ../include/languages-form.php:66
217
  msgid "Full name"
218
  msgstr "Name"
219
 
220
+ # @ polylang
221
+ #: ../include/list-table.php:53
222
+ #: ../include/languages-form.php:72
223
  #, fuzzy
 
224
  msgid "Locale"
225
  msgstr "Locale"
226
 
227
+ # @ polylang
228
+ #: ../include/list-table.php:54
229
  msgid "Code"
230
  msgstr "Code"
231
 
232
+ # @ polylang
233
+ #: ../include/list-table.php:55
234
+ msgid "Flag"
235
+ msgstr "Flagge"
236
+
237
+ # @ polylang
238
+ #: ../include/list-table.php:56
239
  msgid "Posts"
240
  msgstr "Artikel"
241
 
242
+ # @ default
243
+ #: ../include/calendar.php:99
244
+ #, php-format
245
+ msgctxt "calendar caption"
246
+ msgid "%1$s %2$s"
247
+ msgstr ""
248
+
249
+ # @ default
250
+ #: ../include/calendar.php:125
251
+ #: ../include/calendar.php:133
252
  #, php-format
 
253
  msgid "View posts for %1$s %2$s"
254
  msgstr ""
255
 
256
+ # @ polylang
257
+ #: ../include/languages-form.php:33
258
  msgid "Edit language"
259
  msgstr "Sprache bearbeiten"
260
 
261
+ # @ polylang
262
+ #: ../include/languages-form.php:33
263
+ #: ../include/languages-form.php:83
264
  msgid "Add new language"
265
  msgstr "Neue Sprache hinzufügen"
266
 
267
+ # @ polylang
268
+ #: ../include/languages-form.php:54
269
+ msgid "Choose a language"
270
+ msgstr "Sprachen Liste"
271
+
272
+ # @ polylang
273
+ #: ../include/languages-form.php:62
274
+ msgid "You can choose a language in the list or directly edit it below."
275
+ msgstr "Du kannst eine Sprache in der Liste auswählen oder sie unten bearbeiten"
276
+
277
+ # @ polylang
278
+ #: ../include/languages-form.php:68
279
  msgid "The name is how it is displayed on your site (for example: English)."
280
  msgstr "Dieser Name wird dann auf der Website angezeigt (beispielweise : Deutsch)"
281
 
282
+ # @ polylang
283
+ #: ../include/languages-form.php:74
284
  msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
285
  msgstr "Wordpress Locale für die Sprache (beispielweise : de_DE). Du musst die .mo Datei für diese Sprache installieren."
286
 
287
+ # @ polylang
288
+ #: ../include/languages-form.php:78
289
  msgid "Language code"
290
  msgstr "Sprachcode"
291
 
292
+ # @ polylang
293
+ #: ../include/languages-form.php:80
294
  msgid "2-letters ISO 639-1 language code (for example: en)"
295
  msgstr "2 Buchstaben ISO 639-1 Sprachcode (beispielweise : de)"
296
 
297
+ # @ default
298
+ #: ../include/languages-form.php:83
299
  msgid "Update"
300
  msgstr "Aktualisieren"
301
 
302
+ # @ polylang
303
+ #: ../include/languages-form.php:131
304
+ msgid "Language switcher"
305
+ msgstr "Sprachenliste"
 
 
 
 
 
 
 
 
 
 
306
 
307
+ # @ polylang
308
+ #: ../include/languages-form.php:158
309
  msgid "Default language"
310
  msgstr "Standard Sprache"
311
 
312
+ # @ polylang
313
+ #: ../include/languages-form.php:187
314
  #, fuzzy
 
315
  msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
316
  msgstr "Es gibt Artikel, Seite, Kategorien oder Schlagwörter ohne Sprache definiert. Willst du alle zu standard Sprache definieren ?"
317
 
318
+ # @ polylang
319
+ #: ../include/languages-form.php:195
320
  msgid "Detect browser language"
321
  msgstr "Browser Spracherkennung"
322
 
323
+ # @ polylang
324
+ #: ../include/languages-form.php:201
325
  msgid "When the front page is visited, set the language according to the browser preference"
326
  msgstr "Wenn die Startseite besucht ist, definiert die Sprache durch den Browser Einstellung"
327
 
328
+ # @ polylang
329
+ #: ../include/languages-form.php:208
330
  msgid "URL modifications"
331
  msgstr "URL Veränderung"
332
 
333
+ # @ polylang
334
+ #: ../include/languages-form.php:214
335
  msgid "Keep /language/ in pretty permalinks. Example:"
336
  msgstr "/language/ in Permalinks behalten. Zum Beispiel :"
337
 
338
+ # @ polylang
339
+ #: ../include/languages-form.php:222
340
  msgid "Remove /language/ in pretty permalinks. Example:"
341
  msgstr "/language/ in Permalinks entfernen. Zum Beispiel :"
342
 
343
+ # @ polylang
344
+ #: ../include/languages-form.php:230
345
  msgid "Hide URL language information for default language"
346
  msgstr "URL Informationen für die Standardsprache verstecken"
347
 
348
+ # @ polylang
349
+ #: ../include/post-translations.php:1
350
  msgid "ID of pages in other languages:"
351
  msgstr "ID für die Seiten in andere Sprache :"
352
 
353
+ # @ polylang
354
+ #: ../include/post-translations.php:1
355
  msgid "ID of posts in other languages:"
356
  msgstr "ID für die Artikel in andere Sprache :"
357
 
358
+ # @ polylang
359
+ #: ../include/post-translations.php:5
360
  msgid "Page ID"
361
  msgstr "ID für die Seite"
362
 
363
+ # @ polylang
364
+ #: ../include/post-translations.php:5
365
  msgid "Post ID"
366
  msgstr "ID für die Artikel"
367
 
368
+ # @ polylang
369
+ #: ../include/personal-options.php:5
370
  msgid "Admin language"
371
  msgstr "Adminsprache"
372
 
 
 
 
 
 
 
 
 
languages/polylang-fr_FR.mo CHANGED
Binary file
languages/polylang-fr_FR.po CHANGED
@@ -2,350 +2,368 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: polylang\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2011-11-22 09:41+0100\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: F. Demarle\n"
8
  "Language-Team: \n"
 
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
- "X-Poedit-Language: \n"
14
- "X-Poedit-Country: \n"
15
  "X-Poedit-SourceCharset: utf-8\n"
16
- "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
17
  "X-Poedit-Basepath: .\n"
18
- "X-Poedit-Bookmarks: \n"
19
  "X-Poedit-SearchPath-0: ..\n"
20
- "X-Textdomain-Support: yes"
21
 
22
- #: polylang.php:194
23
- #@ polylang
24
  msgid "Error: Upgrade directory doesn't exist!"
25
  msgstr "Erreur : Le répertoire de mise à jour n'existe pas"
26
 
27
- #: polylang.php:195
28
- #@ polylang
29
  msgid "Please create"
30
  msgstr "Créez le répertoire"
31
 
32
- #: polylang.php:202
33
- #@ polylang
34
  msgid "Error: Backup of local flags failed!"
35
  msgstr "Erreur : La sauvegarde des drapeaux personnalisés a échoué"
36
 
37
- #: polylang.php:203
38
- #@ polylang
39
  msgid "Please backup"
40
  msgstr "Sauvegardez"
41
 
42
- #: polylang.php:218
43
- #@ polylang
44
  msgid "Error: Restore of local flags failed!"
45
  msgstr "Erreur : La restauration des drapeaux personnalisés a échoué"
46
 
47
- #: polylang.php:219
48
- #@ polylang
49
  msgid "Please restore your local flags"
50
  msgstr "Restaurez vos drapeaux personnalisés"
51
 
52
- #: include/add-term-form.php:3
53
- #: include/admin.php:349
54
- #: include/admin.php:503
55
- #: include/edit-term-form.php:6
56
- #: include/list-table.php:12
57
- #: include/post-translations.php:4
58
- #: include/term-translations.php:14
59
- #@ polylang
60
  msgid "Language"
61
  msgstr "Langue"
62
 
63
- #: include/add-term-form.php:10
64
- #: include/edit-term-form.php:18
65
- #@ polylang
66
  msgid "Sets the language"
67
  msgstr "Définit la langue"
68
 
69
- #: include/widget.php:5
70
- #@ polylang
71
- msgid "Displays a language switcher"
72
- msgstr "Affiche la liste des langues"
73
-
74
- #: include/widget.php:6
75
- #@ polylang
76
  msgid "Language Switcher"
77
  msgstr "Liste des langues"
78
 
79
- #: include/widget.php:64
80
- #@ polylang
 
 
 
 
 
81
  msgid "Title:"
82
  msgstr "Titre : truc"
83
 
84
- #: include/widget.php:70
85
- #@ polylang
86
- msgid "Display language names"
 
87
  msgstr "Afficher le nom des langues"
88
 
89
- #: include/widget.php:76
90
- #@ polylang
91
- msgid "Display flags"
 
92
  msgstr "Afficher les drapeaux"
93
 
94
- #: include/widget.php:82
95
- #@ polylang
96
- msgid "Display as dropdown"
97
  msgstr "Afficher comme liste déroulante"
98
 
99
- #: include/admin.php:90
100
- #@ default
 
 
 
 
 
 
 
 
101
  msgid "Settings"
102
  msgstr "Réglages"
103
 
104
- #: include/admin.php:97
105
- #: include/admin.php:393
106
- #: include/languages-form.php:14
107
- #: include/list-table.php:13
108
- #@ polylang
109
  msgid "Languages"
110
  msgstr "Langues"
111
 
112
- #: include/admin.php:310
113
- #@ polylang
 
 
 
 
 
114
  msgid "Enter a valid WorPress locale"
115
  msgstr "Entrez un code local WordPress valide"
116
 
117
- #: include/admin.php:311
118
- #@ polylang
119
  msgid "The language code must be 2 characters long"
120
  msgstr "Le code de la langue doit avoir 2 lettres"
121
 
122
- #: include/admin.php:312
123
- #@ polylang
124
  msgid "The language code must be unique"
125
  msgstr "Le code de la langue doit être unique"
126
 
127
- #: include/admin.php:313
128
- #@ polylang
129
  msgid "The language must have a name"
130
  msgstr "La langue doit avoir un nom"
131
 
132
- #: include/admin.php:381
133
- #@ polylang
134
- msgid "Show all languages"
135
- msgstr "Afficher toutes les langues"
136
-
137
- #: include/admin.php:607
138
- #@ polylang
139
- msgid "Theme locations and languages"
140
- msgstr "Emplacements du thème et langues"
141
-
142
- #: include/admin.php:612
143
- #, php-format
144
- #@ polylang
145
- msgid "Please go to the %slanguages page%s to set theme locations and languages"
146
- msgstr "Aller à la %spage langues%s pour définir les emplacements du thème et les langues "
147
-
148
- #: include/admin.php:624
149
- #@ polylang
150
- msgid "The widget is displayed for:"
151
- msgstr "Afficher le widget pour :"
152
-
153
- #: include/admin.php:627
154
- #@ polylang
155
- msgid "All languages"
156
- msgstr "Toutes les langues"
157
 
158
- #: include/post-metabox.php:3
159
- #@ polylang
160
  msgid "Page's language:"
161
  msgstr "Langue de la page"
162
 
163
- #: include/post-metabox.php:3
164
- #@ polylang
165
  msgid "Post's language:"
166
  msgstr "Langue de l'article"
167
 
168
- #: include/term-translations.php:5
169
- #: include/term-translations.php:9
170
- #@ polylang
171
  msgid "Translations"
172
  msgstr "Traductions"
173
 
174
- #: include/term-translations.php:14
175
- #@ polylang
176
  msgid "Translation"
177
  msgstr "Traduction"
178
 
179
- #: include/list-table.php:32
180
- #: include/post-translations.php:6
181
- #: include/post-translations.php:28
182
- #: include/term-translations.php:14
183
- #: include/term-translations.php:75
184
- #@ polylang
185
  msgid "Edit"
186
  msgstr "Modifier"
187
 
188
- #: include/post-translations.php:33
189
- #: include/term-translations.php:61
190
- #@ polylang
191
  msgid "Add new"
192
  msgstr "Ajouter"
193
 
194
- #: include/list-table.php:33
195
- #@ polylang
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  msgid "Delete"
197
  msgstr "Supprimer"
198
 
199
- #: include/languages-form.php:50
200
- #: include/list-table.php:50
201
- #@ polylang
202
  msgid "Full name"
203
  msgstr "Nom"
204
 
205
- #: include/languages-form.php:56
206
- #: include/list-table.php:51
207
- #@ polylang
208
  msgid "Locale"
209
  msgstr "Code local"
210
 
211
- #: include/list-table.php:52
212
- #@ polylang
213
  msgid "Code"
214
  msgstr "Code"
215
 
216
- #: include/list-table.php:53
217
- #@ polylang
 
 
 
 
 
218
  msgid "Posts"
219
  msgstr "Articles"
220
 
221
- #: include/calendar.php:88
222
- #: include/calendar.php:96
 
 
 
 
 
 
 
 
223
  #, php-format
224
- #@ default
225
  msgid "View posts for %1$s %2$s"
226
  msgstr ""
227
 
228
- #: include/languages-form.php:33
229
- #@ polylang
230
  msgid "Edit language"
231
  msgstr "Modifier la langue"
232
 
233
- #: include/languages-form.php:33
234
- #: include/languages-form.php:67
235
- #@ polylang
236
  msgid "Add new language"
237
  msgstr "Ajouter une nouvelle langue"
238
 
239
- #: include/languages-form.php:52
240
- #@ polylang
 
 
 
 
 
 
 
 
 
 
241
  msgid "The name is how it is displayed on your site (for example: English)."
242
  msgstr "Le nom est utilisé un peu partout sur le site (par exemple : Français)"
243
 
244
- #: include/languages-form.php:58
245
- #@ polylang
246
  msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
247
  msgstr "Code local utilisé par Wordpress pour la langue (par exemple : fr_FR). Vous aurez besoin d'installer les fichiers .mo correspondant"
248
 
249
- #: include/languages-form.php:62
250
- #@ polylang
251
  msgid "Language code"
252
  msgstr "Code de la langue"
253
 
254
- #: include/languages-form.php:64
255
- #@ polylang
256
  msgid "2-letters ISO 639-1 language code (for example: en)"
257
  msgstr "Code ISO 639-1 à 2 lettres (par exemple : fr)"
258
 
259
- #: include/languages-form.php:67
260
- #@ default
261
  msgid "Update"
262
  msgstr "Mettre à jour"
263
 
264
- #: include/languages-form.php:79
265
- #@ polylang
266
- msgid "Menus"
267
- msgstr "Menus"
268
-
269
- #: include/languages-form.php:87
270
- #@ polylang
271
- msgid "Theme location"
272
- msgstr "Emplacement du thème"
273
-
274
- #: include/languages-form.php:131
275
- #@ polylang
276
- msgid "Options"
277
- msgstr "Options"
278
 
279
- #: include/languages-form.php:140
280
- #@ polylang
281
  msgid "Default language"
282
  msgstr "Langue par défaut"
283
 
284
- #: include/languages-form.php:169
285
- #@ polylang
286
  msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
287
  msgstr "Il y a des articles, pages, catégories ou tags sans langue définie. Voulez-vous leur attribuer la langue par défaut ?"
288
 
289
- #: include/languages-form.php:177
290
- #@ polylang
291
  msgid "Detect browser language"
292
  msgstr "Détecter la langue du navigateur"
293
 
294
- #: include/languages-form.php:183
295
- #@ polylang
296
  msgid "When the front page is visited, set the language according to the browser preference"
297
  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"
298
 
299
- #: include/languages-form.php:190
300
- #@ polylang
301
  msgid "URL modifications"
302
  msgstr "Modifications des URL"
303
 
304
- #: include/languages-form.php:196
305
- #@ polylang
306
  msgid "Keep /language/ in pretty permalinks. Example:"
307
  msgstr "Conserve /language/ dans les permaliens. Exemple :"
308
 
309
- #: include/languages-form.php:204
310
- #@ polylang
311
  msgid "Remove /language/ in pretty permalinks. Example:"
312
  msgstr "Supprime /language/ dans les permaliens. Exemple :"
313
 
314
- #: include/languages-form.php:212
315
- #@ polylang
316
  msgid "Hide URL language information for default language"
317
  msgstr "Cacher l'information de langue dans l'URL pour la langue par défaut"
318
 
319
- #: include/post-translations.php:1
320
- #@ polylang
321
  msgid "ID of pages in other languages:"
322
  msgstr "ID des pages dans les autres langues"
323
 
324
- #: include/post-translations.php:1
325
- #@ polylang
326
  msgid "ID of posts in other languages:"
327
  msgstr "ID des articles dans les autres langues"
328
 
329
- #: include/post-translations.php:5
330
- #@ polylang
331
  msgid "Page ID"
332
  msgstr "ID de la page"
333
 
334
- #: include/post-translations.php:5
335
- #@ polylang
336
  msgid "Post ID"
337
  msgstr "ID de l'article"
338
 
339
- #: include/personal-options.php:3
340
- #@ polylang
341
  msgid "Admin language"
342
  msgstr "Langue pour l'interface d'administration"
343
 
344
- #. translators: Calendar caption: 1: month name, 2: 4-digit year
345
- #: include/calendar.php:62
346
- #, php-format
347
- #@ default
348
- msgctxt "calendar caption"
349
- msgid "%1$s %2$s"
350
- msgstr ""
351
-
2
  msgstr ""
3
  "Project-Id-Version: polylang\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-12-05 20:53+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; plural=n>1;\n"
 
 
14
  "X-Poedit-SourceCharset: utf-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
16
  "X-Poedit-Basepath: .\n"
17
+ "X-Textdomain-Support: yes\n"
18
  "X-Poedit-SearchPath-0: ..\n"
 
19
 
20
+ # @ polylang
21
+ #: ../polylang.php:169
22
  msgid "Error: Upgrade directory doesn't exist!"
23
  msgstr "Erreur : Le répertoire de mise à jour n'existe pas"
24
 
25
+ # @ polylang
26
+ #: ../polylang.php:170
27
  msgid "Please create"
28
  msgstr "Créez le répertoire"
29
 
30
+ # @ polylang
31
+ #: ../polylang.php:177
32
  msgid "Error: Backup of local flags failed!"
33
  msgstr "Erreur : La sauvegarde des drapeaux personnalisés a échoué"
34
 
35
+ # @ polylang
36
+ #: ../polylang.php:178
37
  msgid "Please backup"
38
  msgstr "Sauvegardez"
39
 
40
+ # @ polylang
41
+ #: ../polylang.php:193
42
  msgid "Error: Restore of local flags failed!"
43
  msgstr "Erreur : La restauration des drapeaux personnalisés a échoué"
44
 
45
+ # @ polylang
46
+ #: ../polylang.php:194
47
  msgid "Please restore your local flags"
48
  msgstr "Restaurez vos drapeaux personnalisés"
49
 
50
+ # @ polylang
51
+ #: ../include/edit-term-form.php:6
52
+ #: ../include/term-translations.php:15
53
+ #: ../include/admin-filters.php:91
54
+ #: ../include/admin-filters.php:327
55
+ #: ../include/add-term-form.php:5
56
+ #: ../include/list-table.php:12
 
57
  msgid "Language"
58
  msgstr "Langue"
59
 
60
+ # @ polylang
61
+ #: ../include/edit-term-form.php:19
62
+ #: ../include/add-term-form.php:13
63
  msgid "Sets the language"
64
  msgstr "Définit la langue"
65
 
66
+ # @ polylang
67
+ #: ../include/widget.php:6
 
 
 
 
 
68
  msgid "Language Switcher"
69
  msgstr "Liste des langues"
70
 
71
+ # @ polylang
72
+ #: ../include/widget.php:6
73
+ msgid "Displays a language switcher"
74
+ msgstr "Affiche la liste des langues"
75
+
76
+ # @ polylang
77
+ #: ../include/widget.php:62
78
  msgid "Title:"
79
  msgstr "Titre : truc"
80
 
81
+ # @ polylang
82
+ #: ../include/widget.php:65
83
+ #: ../include/admin.php:236
84
+ msgid "Displays language names"
85
  msgstr "Afficher le nom des langues"
86
 
87
+ # @ polylang
88
+ #: ../include/widget.php:66
89
+ #: ../include/admin.php:237
90
+ msgid "Displays flags"
91
  msgstr "Afficher les drapeaux"
92
 
93
+ # @ polylang
94
+ #: ../include/widget.php:67
95
+ msgid "Displays as dropdown"
96
  msgstr "Afficher comme liste déroulante"
97
 
98
+ # @ polylang
99
+ #: ../include/widget.php:68
100
+ #: ../include/admin.php:238
101
+ msgid "Forces link to front page"
102
+ msgstr "Force le lien vers la page d'accueil"
103
+
104
+ # @ default
105
+ # @ polylang
106
+ #: ../include/admin.php:21
107
+ #: ../include/admin.php:209
108
  msgid "Settings"
109
  msgstr "Réglages"
110
 
111
+ # @ polylang
112
+ #: ../include/admin.php:28
113
+ #: ../include/admin.php:207
114
+ #: ../include/admin-filters.php:135
115
+ #: ../include/list-table.php:13
116
  msgid "Languages"
117
  msgstr "Langues"
118
 
119
+ # @ polylang
120
+ #: ../include/admin.php:208
121
+ msgid "Menus"
122
+ msgstr "Menus"
123
+
124
+ # @ polylang
125
+ #: ../include/admin.php:225
126
  msgid "Enter a valid WorPress locale"
127
  msgstr "Entrez un code local WordPress valide"
128
 
129
+ # @ polylang
130
+ #: ../include/admin.php:226
131
  msgid "The language code must be 2 characters long"
132
  msgstr "Le code de la langue doit avoir 2 lettres"
133
 
134
+ # @ polylang
135
+ #: ../include/admin.php:227
136
  msgid "The language code must be unique"
137
  msgstr "Le code de la langue doit être unique"
138
 
139
+ # @ polylang
140
+ #: ../include/admin.php:228
141
  msgid "The language must have a name"
142
  msgstr "La langue doit avoir un nom"
143
 
144
+ # @ polylang
145
+ #: ../include/admin.php:235
146
+ msgid "Displays a language switcher at the end of the menu"
147
+ msgstr "Affiche la liste des langues"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
 
149
+ # @ polylang
150
+ #: ../include/post-metabox.php:5
151
  msgid "Page's language:"
152
  msgstr "Langue de la page"
153
 
154
+ # @ polylang
155
+ #: ../include/post-metabox.php:5
156
  msgid "Post's language:"
157
  msgstr "Langue de l'article"
158
 
159
+ # @ polylang
160
+ #: ../include/term-translations.php:6
161
+ #: ../include/term-translations.php:11
162
  msgid "Translations"
163
  msgstr "Traductions"
164
 
165
+ # @ polylang
166
+ #: ../include/term-translations.php:15
167
  msgid "Translation"
168
  msgstr "Traduction"
169
 
170
+ # @ polylang
171
+ #: ../include/term-translations.php:15
172
+ #: ../include/term-translations.php:76
173
+ #: ../include/list-table.php:33
 
 
174
  msgid "Edit"
175
  msgstr "Modifier"
176
 
177
+ # @ polylang
178
+ #: ../include/term-translations.php:62
 
179
  msgid "Add new"
180
  msgstr "Ajouter"
181
 
182
+ # @ polylang
183
+ #: ../include/admin-filters.php:123
184
+ msgid "Show all languages"
185
+ msgstr "Afficher toutes les langues"
186
+
187
+ # @ polylang
188
+ #: ../include/admin-filters.php:400
189
+ msgid "Theme locations and languages"
190
+ msgstr "Emplacements du thème et langues"
191
+
192
+ # @ polylang
193
+ #: ../include/admin-filters.php:405
194
+ #, php-format
195
+ msgid "Please go to the %slanguages page%s to set theme locations and languages"
196
+ msgstr "Aller à la %spage langues%s pour définir les emplacements du thème et les langues"
197
+
198
+ # @ polylang
199
+ #: ../include/admin-filters.php:416
200
+ msgid "The widget is displayed for:"
201
+ msgstr "Afficher le widget pour :"
202
+
203
+ # @ polylang
204
+ #: ../include/admin-filters.php:417
205
+ msgid "All languages"
206
+ msgstr "Toutes les langues"
207
+
208
+ # @ polylang
209
+ #: ../include/list-table.php:34
210
  msgid "Delete"
211
  msgstr "Supprimer"
212
 
213
+ # @ polylang
214
+ #: ../include/list-table.php:52
215
+ #: ../include/languages-form.php:66
216
  msgid "Full name"
217
  msgstr "Nom"
218
 
219
+ # @ polylang
220
+ #: ../include/list-table.php:53
221
+ #: ../include/languages-form.php:72
222
  msgid "Locale"
223
  msgstr "Code local"
224
 
225
+ # @ polylang
226
+ #: ../include/list-table.php:54
227
  msgid "Code"
228
  msgstr "Code"
229
 
230
+ # @ polylang
231
+ #: ../include/list-table.php:55
232
+ msgid "Flag"
233
+ msgstr "Drapeau"
234
+
235
+ # @ polylang
236
+ #: ../include/list-table.php:56
237
  msgid "Posts"
238
  msgstr "Articles"
239
 
240
+ # @ default
241
+ #: ../include/calendar.php:99
242
+ #, php-format
243
+ msgctxt "calendar caption"
244
+ msgid "%1$s %2$s"
245
+ msgstr ""
246
+
247
+ # @ default
248
+ #: ../include/calendar.php:125
249
+ #: ../include/calendar.php:133
250
  #, php-format
 
251
  msgid "View posts for %1$s %2$s"
252
  msgstr ""
253
 
254
+ # @ polylang
255
+ #: ../include/languages-form.php:33
256
  msgid "Edit language"
257
  msgstr "Modifier la langue"
258
 
259
+ # @ polylang
260
+ #: ../include/languages-form.php:33
261
+ #: ../include/languages-form.php:83
262
  msgid "Add new language"
263
  msgstr "Ajouter une nouvelle langue"
264
 
265
+ # @ polylang
266
+ #: ../include/languages-form.php:54
267
+ msgid "Choose a language"
268
+ msgstr "Choisir une langue"
269
+
270
+ # @ polylang
271
+ #: ../include/languages-form.php:62
272
+ msgid "You can choose a language in the list or directly edit it below."
273
+ msgstr "Choisissez une langue dans la liste ou éditez la directement ci-dessous."
274
+
275
+ # @ polylang
276
+ #: ../include/languages-form.php:68
277
  msgid "The name is how it is displayed on your site (for example: English)."
278
  msgstr "Le nom est utilisé un peu partout sur le site (par exemple : Français)"
279
 
280
+ # @ polylang
281
+ #: ../include/languages-form.php:74
282
  msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
283
  msgstr "Code local utilisé par Wordpress pour la langue (par exemple : fr_FR). Vous aurez besoin d'installer les fichiers .mo correspondant"
284
 
285
+ # @ polylang
286
+ #: ../include/languages-form.php:78
287
  msgid "Language code"
288
  msgstr "Code de la langue"
289
 
290
+ # @ polylang
291
+ #: ../include/languages-form.php:80
292
  msgid "2-letters ISO 639-1 language code (for example: en)"
293
  msgstr "Code ISO 639-1 à 2 lettres (par exemple : fr)"
294
 
295
+ # @ default
296
+ #: ../include/languages-form.php:83
297
  msgid "Update"
298
  msgstr "Mettre à jour"
299
 
300
+ # @ polylang
301
+ #: ../include/languages-form.php:131
302
+ msgid "Language switcher"
303
+ msgstr "Liste des langues"
 
 
 
 
 
 
 
 
 
 
304
 
305
+ # @ polylang
306
+ #: ../include/languages-form.php:158
307
  msgid "Default language"
308
  msgstr "Langue par défaut"
309
 
310
+ # @ polylang
311
+ #: ../include/languages-form.php:187
312
  msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
313
  msgstr "Il y a des articles, pages, catégories ou tags sans langue définie. Voulez-vous leur attribuer la langue par défaut ?"
314
 
315
+ # @ polylang
316
+ #: ../include/languages-form.php:195
317
  msgid "Detect browser language"
318
  msgstr "Détecter la langue du navigateur"
319
 
320
+ # @ polylang
321
+ #: ../include/languages-form.php:201
322
  msgid "When the front page is visited, set the language according to the browser preference"
323
  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"
324
 
325
+ # @ polylang
326
+ #: ../include/languages-form.php:208
327
  msgid "URL modifications"
328
  msgstr "Modifications des URL"
329
 
330
+ # @ polylang
331
+ #: ../include/languages-form.php:214
332
  msgid "Keep /language/ in pretty permalinks. Example:"
333
  msgstr "Conserve /language/ dans les permaliens. Exemple :"
334
 
335
+ # @ polylang
336
+ #: ../include/languages-form.php:222
337
  msgid "Remove /language/ in pretty permalinks. Example:"
338
  msgstr "Supprime /language/ dans les permaliens. Exemple :"
339
 
340
+ # @ polylang
341
+ #: ../include/languages-form.php:230
342
  msgid "Hide URL language information for default language"
343
  msgstr "Cacher l'information de langue dans l'URL pour la langue par défaut"
344
 
345
+ # @ polylang
346
+ #: ../include/post-translations.php:1
347
  msgid "ID of pages in other languages:"
348
  msgstr "ID des pages dans les autres langues"
349
 
350
+ # @ polylang
351
+ #: ../include/post-translations.php:1
352
  msgid "ID of posts in other languages:"
353
  msgstr "ID des articles dans les autres langues"
354
 
355
+ # @ polylang
356
+ #: ../include/post-translations.php:5
357
  msgid "Page ID"
358
  msgstr "ID de la page"
359
 
360
+ # @ polylang
361
+ #: ../include/post-translations.php:5
362
  msgid "Post ID"
363
  msgstr "ID de l'article"
364
 
365
+ # @ polylang
366
+ #: ../include/personal-options.php:5
367
  msgid "Admin language"
368
  msgstr "Langue pour l'interface d'administration"
369
 
 
 
 
 
 
 
 
 
languages/polylang-ru_RU.mo CHANGED
Binary file
languages/polylang-ru_RU.po CHANGED
@@ -2,14 +2,15 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: polylang\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2011-11-22 09:49+0100\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: YoYurec <yoyurec@gmail.com>\n"
8
  "Language-Team: \n"
 
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
  "X-Poedit-Language: Russian\n"
14
  "X-Poedit-Country: RUSSIAN FEDERATION\n"
15
  "X-Poedit-SourceCharset: utf-8\n"
@@ -18,333 +19,353 @@ msgstr ""
18
  "X-Textdomain-Support: yes\n"
19
  "X-Poedit-SearchPath-0: ..\n"
20
 
21
- #@ polylang
22
- #: polylang.php:194
23
  msgid "Error: Upgrade directory doesn't exist!"
24
  msgstr "Ошибка: Отсутствует папка для обновления!"
25
 
26
- #@ polylang
27
- #: polylang.php:195
28
  msgid "Please create"
29
  msgstr "Пожалуйста, создайте"
30
 
31
- #@ polylang
32
- #: polylang.php:202
33
  msgid "Error: Backup of local flags failed!"
34
  msgstr "Ошибка: Не удалось создать резервную копию пользовательских иконок-флагов!"
35
 
36
- #@ polylang
37
- #: polylang.php:203
38
  msgid "Please backup"
39
  msgstr "Пожалуйста, сделайте резервную копию"
40
 
41
- #@ polylang
42
- #: polylang.php:218
43
  msgid "Error: Restore of local flags failed!"
44
  msgstr "Ошибка: Не удалось восстановить пользовательские иконки-флаги из резервной копиии!"
45
 
46
- #@ polylang
47
- #: polylang.php:219
48
  msgid "Please restore your local flags"
49
  msgstr "Пожалуйста, создайте резервную копию пользовательских иконок-флагов!"
50
 
51
- #@ polylang
52
- #: include/add-term-form.php:3
53
- #: include/admin.php:349
54
- #: include/admin.php:503
55
- #: include/edit-term-form.php:6
56
- #: include/list-table.php:12
57
- #: include/post-translations.php:4
58
- #: include/term-translations.php:14
59
  msgid "Language"
60
  msgstr "Язык"
61
 
62
- #@ polylang
63
- #: include/add-term-form.php:10
64
- #: include/edit-term-form.php:18
65
  msgid "Sets the language"
66
  msgstr "Устанавливает язык"
67
 
68
- #@ polylang
69
- #: include/widget.php:5
70
- msgid "Displays a language switcher"
71
- msgstr "Показывает переключатель языков"
72
-
73
- #@ polylang
74
- #: include/widget.php:6
75
  msgid "Language Switcher"
76
  msgstr "Переключатель языков"
77
 
78
- #@ polylang
79
- #: include/widget.php:64
 
 
 
 
 
80
  msgid "Title:"
81
  msgstr "Название:"
82
 
83
- #@ polylang
84
- #: include/widget.php:70
85
- msgid "Display language names"
 
86
  msgstr "Показывать названия языков"
87
 
88
- #@ polylang
89
- #: include/widget.php:76
90
- msgid "Display flags"
 
91
  msgstr "Показывать флаги"
92
 
93
- #@ polylang
94
- #: include/widget.php:82
95
- msgid "Display as dropdown"
96
  msgstr "Показывать как выпадающий список"
97
 
98
- #@ default
99
- #: include/admin.php:90
 
 
 
 
 
 
 
 
100
  msgid "Settings"
101
  msgstr "Настройки"
102
 
103
- #@ polylang
104
- #: include/admin.php:97
105
- #: include/admin.php:393
106
- #: include/languages-form.php:14
107
- #: include/list-table.php:13
108
  msgid "Languages"
109
  msgstr "Языки"
110
 
111
- #@ polylang
112
- #: include/admin.php:310
 
 
 
 
 
113
  msgid "Enter a valid WorPress locale"
114
  msgstr "Введите корректную WordPress локаль"
115
 
116
- #@ polylang
117
- #: include/admin.php:311
118
  msgid "The language code must be 2 characters long"
119
  msgstr "Код языка должен состоять из 2-х символов"
120
 
121
- #@ polylang
122
- #: include/admin.php:312
123
  msgid "The language code must be unique"
124
  msgstr "Код языка должен быть уникальным"
125
 
126
- #@ polylang
127
- #: include/admin.php:313
128
  msgid "The language must have a name"
129
  msgstr "У языка должно быть название"
130
 
131
- #@ polylang
132
- #: include/admin.php:381
133
- msgid "Show all languages"
134
- msgstr "Показать все языки"
135
-
136
- #@ polylang
137
- #: include/admin.php:607
138
- msgid "Theme locations and languages"
139
- msgstr "Расположение темы и языков"
140
-
141
- #@ polylang
142
- #: include/admin.php:612
143
- #, php-format
144
- msgid "Please go to the %slanguages page%s to set theme locations and languages"
145
- msgstr "Перейдите на %slanguages page%s для указания расположения темы и языков"
146
-
147
- #@ polylang
148
- #: include/admin.php:624
149
- msgid "The widget is displayed for:"
150
- msgstr "Показывать виджет для"
151
-
152
- #@ polylang
153
- #: include/admin.php:627
154
- msgid "All languages"
155
- msgstr "Все языки"
156
 
157
- #@ polylang
158
- #: include/post-metabox.php:3
159
  msgid "Page's language:"
160
  msgstr "Язык страницы"
161
 
162
- #@ polylang
163
- #: include/post-metabox.php:3
164
  msgid "Post's language:"
165
  msgstr "Язык записи"
166
 
167
- #@ polylang
168
- #: include/term-translations.php:5
169
- #: include/term-translations.php:9
170
  msgid "Translations"
171
  msgstr "Переводы"
172
 
173
- #@ polylang
174
- #: include/term-translations.php:14
175
  msgid "Translation"
176
  msgstr "Перевод"
177
 
178
- #@ polylang
179
- #: include/list-table.php:32
180
- #: include/post-translations.php:6
181
- #: include/post-translations.php:28
182
- #: include/term-translations.php:14
183
- #: include/term-translations.php:75
184
  msgid "Edit"
185
  msgstr "Редактировать"
186
 
187
- #@ polylang
188
- #: include/post-translations.php:33
189
- #: include/term-translations.php:61
190
  msgid "Add new"
191
  msgstr "Добавить новый"
192
 
193
- #@ polylang
194
- #: include/list-table.php:33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  msgid "Delete"
196
  msgstr "Удалить"
197
 
198
- #@ polylang
199
- #: include/languages-form.php:50
200
- #: include/list-table.php:50
201
  msgid "Full name"
202
  msgstr "Полное название"
203
 
204
- #@ polylang
205
- #: include/languages-form.php:56
206
- #: include/list-table.php:51
207
  msgid "Locale"
208
  msgstr "Локаль"
209
 
210
- #@ polylang
211
- #: include/list-table.php:52
212
  msgid "Code"
213
  msgstr "Код"
214
 
215
- #@ polylang
216
- #: include/list-table.php:53
 
 
 
 
 
217
  msgid "Posts"
218
  msgstr "Записи"
219
 
220
- #@ default
221
- #: include/calendar.php:88
222
- #: include/calendar.php:96
 
 
 
 
 
 
 
223
  #, php-format
224
  msgid "View posts for %1$s %2$s"
225
  msgstr "Показать записи для %1$s %2$s"
226
 
227
- #@ polylang
228
- #: include/languages-form.php:33
229
  msgid "Edit language"
230
  msgstr "Редактировать язык"
231
 
232
- #@ polylang
233
- #: include/languages-form.php:33
234
- #: include/languages-form.php:67
235
  msgid "Add new language"
236
  msgstr "Добавить новый язык"
237
 
238
- #@ polylang
239
- #: include/languages-form.php:52
 
 
 
 
 
 
 
 
 
 
240
  msgid "The name is how it is displayed on your site (for example: English)."
241
  msgstr "Название для отображения на сайте (например: Русский)."
242
 
243
- #@ polylang
244
- #: include/languages-form.php:58
245
  msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
246
  msgstr "Локаль Wordpress'a для языка (например: ru_RU). Вы должны установить файлы .mo для админ.панели и используемой темы."
247
 
248
- #@ polylang
249
- #: include/languages-form.php:62
250
  msgid "Language code"
251
  msgstr "Код языка"
252
 
253
- #@ polylang
254
- #: include/languages-form.php:64
255
  msgid "2-letters ISO 639-1 language code (for example: en)"
256
  msgstr "2х-буквенный ISO 639-1 код языка (например: ru)"
257
 
258
- #@ default
259
- #: include/languages-form.php:67
260
  msgid "Update"
261
  msgstr "Обновить"
262
 
263
- #@ polylang
264
- #: include/languages-form.php:79
265
- msgid "Menus"
266
- msgstr "Меню"
267
-
268
- #@ polylang
269
- #: include/languages-form.php:87
270
- msgid "Theme location"
271
- msgstr "Расположение темы"
272
-
273
- #@ polylang
274
- #: include/languages-form.php:131
275
- msgid "Options"
276
- msgstr "Настройки"
277
 
278
- #@ polylang
279
- #: include/languages-form.php:140
280
  msgid "Default language"
281
  msgstr "Язык по-умолчанию"
282
 
283
- #@ polylang
284
- #: include/languages-form.php:169
285
  msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
286
  msgstr "Найдены записи, страницы, категории или метки без указанния какого-либо языка. Установить им язык по-умолчанию?"
287
 
288
- #@ polylang
289
- #: include/languages-form.php:177
290
  msgid "Detect browser language"
291
  msgstr "Определять язык в браузере"
292
 
293
- #@ polylang
294
- #: include/languages-form.php:183
295
  msgid "When the front page is visited, set the language according to the browser preference"
296
  msgstr "Установить язык сайта согласно настройкам браузера"
297
 
298
- #@ polylang
299
- #: include/languages-form.php:190
300
  msgid "URL modifications"
301
  msgstr "Модификации URL"
302
 
303
- #@ polylang
304
- #: include/languages-form.php:196
305
  msgid "Keep /language/ in pretty permalinks. Example:"
306
  msgstr "Оставить /language/ в ЧПУ. Пример:"
307
 
308
- #@ polylang
309
- #: include/languages-form.php:204
310
  msgid "Remove /language/ in pretty permalinks. Example:"
311
  msgstr "Удалить /language/ в ЧПУ. Пример:"
312
 
313
- #@ polylang
314
- #: include/languages-form.php:212
315
  msgid "Hide URL language information for default language"
316
  msgstr "Спрятать название языка по-умолчанию из URL"
317
 
318
- #@ polylang
319
- #: include/post-translations.php:1
320
  msgid "ID of pages in other languages:"
321
  msgstr "ID страницы на других языках:"
322
 
323
- #@ polylang
324
- #: include/post-translations.php:1
325
  msgid "ID of posts in other languages:"
326
  msgstr "ID записи на других языках:"
327
 
328
- #@ polylang
329
- #: include/post-translations.php:5
330
  msgid "Page ID"
331
  msgstr "ID страницы"
332
 
333
- #@ polylang
334
- #: include/post-translations.php:5
335
  msgid "Post ID"
336
  msgstr "ID записи"
337
 
338
- #@ polylang
339
- #: include/personal-options.php:3
340
  msgid "Admin language"
341
  msgstr "Язык админ.панели"
342
 
343
- #@ default
344
- #. translators: Calendar caption: 1: month name, 2: 4-digit year
345
- #: include/calendar.php:62
346
- #, php-format
347
- msgctxt "calendar caption"
348
- msgid "%1$s %2$s"
349
- msgstr "%1$s %2$s"
350
-
2
  msgstr ""
3
  "Project-Id-Version: polylang\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-12-05 20:53+0100\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: YoYurec <yoyurec@gmail.com>\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=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
14
  "X-Poedit-Language: Russian\n"
15
  "X-Poedit-Country: RUSSIAN FEDERATION\n"
16
  "X-Poedit-SourceCharset: utf-8\n"
19
  "X-Textdomain-Support: yes\n"
20
  "X-Poedit-SearchPath-0: ..\n"
21
 
22
+ # @ polylang
23
+ #: ../polylang.php:169
24
  msgid "Error: Upgrade directory doesn't exist!"
25
  msgstr "Ошибка: Отсутствует папка для обновления!"
26
 
27
+ # @ polylang
28
+ #: ../polylang.php:170
29
  msgid "Please create"
30
  msgstr "Пожалуйста, создайте"
31
 
32
+ # @ polylang
33
+ #: ../polylang.php:177
34
  msgid "Error: Backup of local flags failed!"
35
  msgstr "Ошибка: Не удалось создать резервную копию пользовательских иконок-флагов!"
36
 
37
+ # @ polylang
38
+ #: ../polylang.php:178
39
  msgid "Please backup"
40
  msgstr "Пожалуйста, сделайте резервную копию"
41
 
42
+ # @ polylang
43
+ #: ../polylang.php:193
44
  msgid "Error: Restore of local flags failed!"
45
  msgstr "Ошибка: Не удалось восстановить пользовательские иконки-флаги из резервной копиии!"
46
 
47
+ # @ polylang
48
+ #: ../polylang.php:194
49
  msgid "Please restore your local flags"
50
  msgstr "Пожалуйста, создайте резервную копию пользовательских иконок-флагов!"
51
 
52
+ # @ polylang
53
+ #: ../include/edit-term-form.php:6
54
+ #: ../include/term-translations.php:15
55
+ #: ../include/admin-filters.php:91
56
+ #: ../include/admin-filters.php:327
57
+ #: ../include/add-term-form.php:5
58
+ #: ../include/list-table.php:12
 
59
  msgid "Language"
60
  msgstr "Язык"
61
 
62
+ # @ polylang
63
+ #: ../include/edit-term-form.php:19
64
+ #: ../include/add-term-form.php:13
65
  msgid "Sets the language"
66
  msgstr "Устанавливает язык"
67
 
68
+ # @ polylang
69
+ #: ../include/widget.php:6
 
 
 
 
 
70
  msgid "Language Switcher"
71
  msgstr "Переключатель языков"
72
 
73
+ # @ polylang
74
+ #: ../include/widget.php:6
75
+ msgid "Displays a language switcher"
76
+ msgstr "Показывает переключатель языков"
77
+
78
+ # @ polylang
79
+ #: ../include/widget.php:62
80
  msgid "Title:"
81
  msgstr "Название:"
82
 
83
+ # @ polylang
84
+ #: ../include/widget.php:65
85
+ #: ../include/admin.php:236
86
+ msgid "Displays language names"
87
  msgstr "Показывать названия языков"
88
 
89
+ # @ polylang
90
+ #: ../include/widget.php:66
91
+ #: ../include/admin.php:237
92
+ msgid "Displays flags"
93
  msgstr "Показывать флаги"
94
 
95
+ # @ polylang
96
+ #: ../include/widget.php:67
97
+ msgid "Displays as dropdown"
98
  msgstr "Показывать как выпадающий список"
99
 
100
+ # @ polylang
101
+ #: ../include/widget.php:68
102
+ #: ../include/admin.php:238
103
+ msgid "Forces link to front page"
104
+ msgstr "Принудительно переходить на главную страницу при смене языка"
105
+
106
+ # @ default
107
+ # @ polylang
108
+ #: ../include/admin.php:21
109
+ #: ../include/admin.php:209
110
  msgid "Settings"
111
  msgstr "Настройки"
112
 
113
+ # @ polylang
114
+ #: ../include/admin.php:28
115
+ #: ../include/admin.php:207
116
+ #: ../include/admin-filters.php:135
117
+ #: ../include/list-table.php:13
118
  msgid "Languages"
119
  msgstr "Языки"
120
 
121
+ # @ polylang
122
+ #: ../include/admin.php:208
123
+ msgid "Menus"
124
+ msgstr "Меню"
125
+
126
+ # @ polylang
127
+ #: ../include/admin.php:225
128
  msgid "Enter a valid WorPress locale"
129
  msgstr "Введите корректную WordPress локаль"
130
 
131
+ # @ polylang
132
+ #: ../include/admin.php:226
133
  msgid "The language code must be 2 characters long"
134
  msgstr "Код языка должен состоять из 2-х символов"
135
 
136
+ # @ polylang
137
+ #: ../include/admin.php:227
138
  msgid "The language code must be unique"
139
  msgstr "Код языка должен быть уникальным"
140
 
141
+ # @ polylang
142
+ #: ../include/admin.php:228
143
  msgid "The language must have a name"
144
  msgstr "У языка должно быть название"
145
 
146
+ # @ polylang
147
+ #: ../include/admin.php:235
148
+ msgid "Displays a language switcher at the end of the menu"
149
+ msgstr "Показывает переключатель языков"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
+ # @ polylang
152
+ #: ../include/post-metabox.php:5
153
  msgid "Page's language:"
154
  msgstr "Язык страницы"
155
 
156
+ # @ polylang
157
+ #: ../include/post-metabox.php:5
158
  msgid "Post's language:"
159
  msgstr "Язык записи"
160
 
161
+ # @ polylang
162
+ #: ../include/term-translations.php:6
163
+ #: ../include/term-translations.php:11
164
  msgid "Translations"
165
  msgstr "Переводы"
166
 
167
+ # @ polylang
168
+ #: ../include/term-translations.php:15
169
  msgid "Translation"
170
  msgstr "Перевод"
171
 
172
+ # @ polylang
173
+ #: ../include/term-translations.php:15
174
+ #: ../include/term-translations.php:76
175
+ #: ../include/list-table.php:33
 
 
176
  msgid "Edit"
177
  msgstr "Редактировать"
178
 
179
+ # @ polylang
180
+ #: ../include/term-translations.php:62
 
181
  msgid "Add new"
182
  msgstr "Добавить новый"
183
 
184
+ # @ polylang
185
+ #: ../include/admin-filters.php:123
186
+ msgid "Show all languages"
187
+ msgstr "Показать все языки"
188
+
189
+ # @ polylang
190
+ #: ../include/admin-filters.php:400
191
+ msgid "Theme locations and languages"
192
+ msgstr "Расположение темы и языков"
193
+
194
+ # @ polylang
195
+ #: ../include/admin-filters.php:405
196
+ #, php-format
197
+ msgid "Please go to the %slanguages page%s to set theme locations and languages"
198
+ msgstr "Перейдите на %slanguages page%s для указания расположения темы и языков"
199
+
200
+ # @ polylang
201
+ #: ../include/admin-filters.php:416
202
+ msgid "The widget is displayed for:"
203
+ msgstr "Показывать виджет для"
204
+
205
+ # @ polylang
206
+ #: ../include/admin-filters.php:417
207
+ msgid "All languages"
208
+ msgstr "Все языки"
209
+
210
+ # @ polylang
211
+ #: ../include/list-table.php:34
212
  msgid "Delete"
213
  msgstr "Удалить"
214
 
215
+ # @ polylang
216
+ #: ../include/list-table.php:52
217
+ #: ../include/languages-form.php:66
218
  msgid "Full name"
219
  msgstr "Полное название"
220
 
221
+ # @ polylang
222
+ #: ../include/list-table.php:53
223
+ #: ../include/languages-form.php:72
224
  msgid "Locale"
225
  msgstr "Локаль"
226
 
227
+ # @ polylang
228
+ #: ../include/list-table.php:54
229
  msgid "Code"
230
  msgstr "Код"
231
 
232
+ # @ polylang
233
+ #: ../include/list-table.php:55
234
+ msgid "Flag"
235
+ msgstr "Флаг"
236
+
237
+ # @ polylang
238
+ #: ../include/list-table.php:56
239
  msgid "Posts"
240
  msgstr "Записи"
241
 
242
+ # @ default
243
+ #: ../include/calendar.php:99
244
+ #, php-format
245
+ msgctxt "calendar caption"
246
+ msgid "%1$s %2$s"
247
+ msgstr "%1$s %2$s"
248
+
249
+ # @ default
250
+ #: ../include/calendar.php:125
251
+ #: ../include/calendar.php:133
252
  #, php-format
253
  msgid "View posts for %1$s %2$s"
254
  msgstr "Показать записи для %1$s %2$s"
255
 
256
+ # @ polylang
257
+ #: ../include/languages-form.php:33
258
  msgid "Edit language"
259
  msgstr "Редактировать язык"
260
 
261
+ # @ polylang
262
+ #: ../include/languages-form.php:33
263
+ #: ../include/languages-form.php:83
264
  msgid "Add new language"
265
  msgstr "Добавить новый язык"
266
 
267
+ # @ polylang
268
+ #: ../include/languages-form.php:54
269
+ msgid "Choose a language"
270
+ msgstr "Показать все языки"
271
+
272
+ # @ polylang
273
+ #: ../include/languages-form.php:62
274
+ msgid "You can choose a language in the list or directly edit it below."
275
+ msgstr "Выберите язык из списка или укажите сами."
276
+
277
+ # @ polylang
278
+ #: ../include/languages-form.php:68
279
  msgid "The name is how it is displayed on your site (for example: English)."
280
  msgstr "Название для отображения на сайте (например: Русский)."
281
 
282
+ # @ polylang
283
+ #: ../include/languages-form.php:74
284
  msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
285
  msgstr "Локаль Wordpress'a для языка (например: ru_RU). Вы должны установить файлы .mo для админ.панели и используемой темы."
286
 
287
+ # @ polylang
288
+ #: ../include/languages-form.php:78
289
  msgid "Language code"
290
  msgstr "Код языка"
291
 
292
+ # @ polylang
293
+ #: ../include/languages-form.php:80
294
  msgid "2-letters ISO 639-1 language code (for example: en)"
295
  msgstr "2х-буквенный ISO 639-1 код языка (например: ru)"
296
 
297
+ # @ default
298
+ #: ../include/languages-form.php:83
299
  msgid "Update"
300
  msgstr "Обновить"
301
 
302
+ # @ polylang
303
+ #: ../include/languages-form.php:131
304
+ msgid "Language switcher"
305
+ msgstr "Переключатель языков"
 
 
 
 
 
 
 
 
 
 
306
 
307
+ # @ polylang
308
+ #: ../include/languages-form.php:158
309
  msgid "Default language"
310
  msgstr "Язык по-умолчанию"
311
 
312
+ # @ polylang
313
+ #: ../include/languages-form.php:187
314
  msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
315
  msgstr "Найдены записи, страницы, категории или метки без указанния какого-либо языка. Установить им язык по-умолчанию?"
316
 
317
+ # @ polylang
318
+ #: ../include/languages-form.php:195
319
  msgid "Detect browser language"
320
  msgstr "Определять язык в браузере"
321
 
322
+ # @ polylang
323
+ #: ../include/languages-form.php:201
324
  msgid "When the front page is visited, set the language according to the browser preference"
325
  msgstr "Установить язык сайта согласно настройкам браузера"
326
 
327
+ # @ polylang
328
+ #: ../include/languages-form.php:208
329
  msgid "URL modifications"
330
  msgstr "Модификации URL"
331
 
332
+ # @ polylang
333
+ #: ../include/languages-form.php:214
334
  msgid "Keep /language/ in pretty permalinks. Example:"
335
  msgstr "Оставить /language/ в ЧПУ. Пример:"
336
 
337
+ # @ polylang
338
+ #: ../include/languages-form.php:222
339
  msgid "Remove /language/ in pretty permalinks. Example:"
340
  msgstr "Удалить /language/ в ЧПУ. Пример:"
341
 
342
+ # @ polylang
343
+ #: ../include/languages-form.php:230
344
  msgid "Hide URL language information for default language"
345
  msgstr "Спрятать название языка по-умолчанию из URL"
346
 
347
+ # @ polylang
348
+ #: ../include/post-translations.php:1
349
  msgid "ID of pages in other languages:"
350
  msgstr "ID страницы на других языках:"
351
 
352
+ # @ polylang
353
+ #: ../include/post-translations.php:1
354
  msgid "ID of posts in other languages:"
355
  msgstr "ID записи на других языках:"
356
 
357
+ # @ polylang
358
+ #: ../include/post-translations.php:5
359
  msgid "Page ID"
360
  msgstr "ID страницы"
361
 
362
+ # @ polylang
363
+ #: ../include/post-translations.php:5
364
  msgid "Post ID"
365
  msgstr "ID записи"
366
 
367
+ # @ polylang
368
+ #: ../include/personal-options.php:5
369
  msgid "Admin language"
370
  msgstr "Язык админ.панели"
371
 
 
 
 
 
 
 
 
 
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-22 09:45+0100\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: F. Demarle\n"
8
  "Language-Team: \n"
@@ -17,176 +17,192 @@ msgstr ""
17
  "X-Poedit-SearchPath-0: ..\n"
18
  "X-Poedit-SearchPath-1: ../include\n"
19
 
20
- #: ../polylang.php:194
21
  msgid "Error: Upgrade directory doesn't exist!"
22
  msgstr ""
23
 
24
- #: ../polylang.php:195
25
  msgid "Please create"
26
  msgstr ""
27
 
28
- #: ../polylang.php:202
29
  msgid "Error: Backup of local flags failed!"
30
  msgstr ""
31
 
32
- #: ../polylang.php:203
33
  msgid "Please backup"
34
  msgstr ""
35
 
36
- #: ../polylang.php:218
37
  msgid "Error: Restore of local flags failed!"
38
  msgstr ""
39
 
40
- #: ../polylang.php:219
41
  msgid "Please restore your local flags"
42
  msgstr ""
43
 
44
  #: ../include/edit-term-form.php:6
45
- #: ../include/admin.php:349
46
- #: ../include/admin.php:503
47
- #: ../include/term-translations.php:14
48
- #: ../include/add-term-form.php:3
49
  #: ../include/list-table.php:12
50
- #: ../include/post-translations.php:4
51
  msgid "Language"
52
  msgstr ""
53
 
54
- #: ../include/edit-term-form.php:18
55
- #: ../include/add-term-form.php:10
56
  msgid "Sets the language"
57
  msgstr ""
58
 
59
- #: ../include/widget.php:5
60
- msgid "Displays a language switcher"
61
  msgstr ""
62
 
63
  #: ../include/widget.php:6
64
- msgid "Language Switcher"
65
  msgstr ""
66
 
67
- #: ../include/widget.php:64
68
  msgid "Title:"
69
  msgstr ""
70
 
71
- #: ../include/widget.php:70
72
- msgid "Display language names"
 
73
  msgstr ""
74
 
75
- #: ../include/widget.php:76
76
- msgid "Display flags"
 
77
  msgstr ""
78
 
79
- #: ../include/widget.php:82
80
- msgid "Display as dropdown"
81
  msgstr ""
82
 
83
- #: ../include/admin.php:90
 
 
 
 
 
 
84
  msgid "Settings"
85
  msgstr ""
86
 
87
- #: ../include/admin.php:97
88
- #: ../include/admin.php:393
 
89
  #: ../include/list-table.php:13
90
- #: ../include/languages-form.php:14
91
  msgid "Languages"
92
  msgstr ""
93
 
94
- #: ../include/admin.php:310
 
 
 
 
95
  msgid "Enter a valid WorPress locale"
96
  msgstr ""
97
 
98
- #: ../include/admin.php:311
99
  msgid "The language code must be 2 characters long"
100
  msgstr ""
101
 
102
- #: ../include/admin.php:312
103
  msgid "The language code must be unique"
104
  msgstr ""
105
 
106
- #: ../include/admin.php:313
107
  msgid "The language must have a name"
108
  msgstr ""
109
 
110
- #: ../include/admin.php:381
111
- msgid "Show all languages"
112
  msgstr ""
113
 
114
- #: ../include/admin.php:607
115
- msgid "Theme locations and languages"
116
  msgstr ""
117
 
118
- #: ../include/admin.php:612
119
- #, php-format
120
- msgid "Please go to the %slanguages page%s to set theme locations and languages"
121
  msgstr ""
122
 
123
- #: ../include/admin.php:624
124
- msgid "The widget is displayed for:"
 
125
  msgstr ""
126
 
127
- #: ../include/admin.php:627
128
- msgid "All languages"
129
  msgstr ""
130
 
131
- #: ../include/post-metabox.php:3
132
- msgid "Page's language:"
 
 
133
  msgstr ""
134
 
135
- #: ../include/post-metabox.php:3
136
- msgid "Post's language:"
137
  msgstr ""
138
 
139
- #: ../include/term-translations.php:5
140
- #: ../include/term-translations.php:9
141
- msgid "Translations"
142
  msgstr ""
143
 
144
- #: ../include/term-translations.php:14
145
- msgid "Translation"
146
  msgstr ""
147
 
148
- #: ../include/term-translations.php:14
149
- #: ../include/term-translations.php:75
150
- #: ../include/list-table.php:32
151
- #: ../include/post-translations.php:6
152
- #: ../include/post-translations.php:28
153
- msgid "Edit"
154
  msgstr ""
155
 
156
- #: ../include/term-translations.php:61
157
- #: ../include/post-translations.php:33
158
- msgid "Add new"
159
  msgstr ""
160
 
161
- #: ../include/list-table.php:33
 
 
 
 
162
  msgid "Delete"
163
  msgstr ""
164
 
165
- #: ../include/list-table.php:50
166
- #: ../include/languages-form.php:50
167
  msgid "Full name"
168
  msgstr ""
169
 
170
- #: ../include/list-table.php:51
171
- #: ../include/languages-form.php:56
172
  msgid "Locale"
173
  msgstr ""
174
 
175
- #: ../include/list-table.php:52
176
  msgid "Code"
177
  msgstr ""
178
 
179
- #: ../include/list-table.php:53
 
 
 
 
180
  msgid "Posts"
181
  msgstr ""
182
 
183
- #: ../include/calendar.php:62
184
  #, php-format
185
  msgid "%1$s %2$s"
186
  msgstr ""
187
 
188
- #: ../include/calendar.php:88
189
- #: ../include/calendar.php:96
190
  #, php-format
191
  msgid "View posts for %1$s %2$s"
192
  msgstr ""
@@ -196,71 +212,71 @@ msgid "Edit language"
196
  msgstr ""
197
 
198
  #: ../include/languages-form.php:33
199
- #: ../include/languages-form.php:67
200
  msgid "Add new language"
201
  msgstr ""
202
 
203
- #: ../include/languages-form.php:52
 
 
 
 
 
 
 
 
204
  msgid "The name is how it is displayed on your site (for example: English)."
205
  msgstr ""
206
 
207
- #: ../include/languages-form.php:58
208
  msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
209
  msgstr ""
210
 
211
- #: ../include/languages-form.php:62
212
  msgid "Language code"
213
  msgstr ""
214
 
215
- #: ../include/languages-form.php:64
216
  msgid "2-letters ISO 639-1 language code (for example: en)"
217
  msgstr ""
218
 
219
- #: ../include/languages-form.php:67
220
  msgid "Update"
221
  msgstr ""
222
 
223
- #: ../include/languages-form.php:79
224
- msgid "Menus"
225
- msgstr ""
226
-
227
- #: ../include/languages-form.php:87
228
- msgid "Theme location"
229
- msgstr ""
230
-
231
  #: ../include/languages-form.php:131
232
- msgid "Options"
233
  msgstr ""
234
 
235
- #: ../include/languages-form.php:140
236
  msgid "Default language"
237
  msgstr ""
238
 
239
- #: ../include/languages-form.php:169
240
  msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
241
  msgstr ""
242
 
243
- #: ../include/languages-form.php:177
244
  msgid "Detect browser language"
245
  msgstr ""
246
 
247
- #: ../include/languages-form.php:183
248
  msgid "When the front page is visited, set the language according to the browser preference"
249
  msgstr ""
250
 
251
- #: ../include/languages-form.php:190
252
  msgid "URL modifications"
253
  msgstr ""
254
 
255
- #: ../include/languages-form.php:196
256
  msgid "Keep /language/ in pretty permalinks. Example:"
257
  msgstr ""
258
 
259
- #: ../include/languages-form.php:204
260
  msgid "Remove /language/ in pretty permalinks. Example:"
261
  msgstr ""
262
 
263
- #: ../include/languages-form.php:212
264
  msgid "Hide URL language information for default language"
265
  msgstr ""
266
 
@@ -280,7 +296,7 @@ msgstr ""
280
  msgid "Post ID"
281
  msgstr ""
282
 
283
- #: ../include/personal-options.php:3
284
  msgid "Admin language"
285
  msgstr ""
286
 
2
  msgstr ""
3
  "Project-Id-Version: polylang\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-12-05 20:52+0100\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: F. Demarle\n"
8
  "Language-Team: \n"
17
  "X-Poedit-SearchPath-0: ..\n"
18
  "X-Poedit-SearchPath-1: ../include\n"
19
 
20
+ #: ../polylang.php:169
21
  msgid "Error: Upgrade directory doesn't exist!"
22
  msgstr ""
23
 
24
+ #: ../polylang.php:170
25
  msgid "Please create"
26
  msgstr ""
27
 
28
+ #: ../polylang.php:177
29
  msgid "Error: Backup of local flags failed!"
30
  msgstr ""
31
 
32
+ #: ../polylang.php:178
33
  msgid "Please backup"
34
  msgstr ""
35
 
36
+ #: ../polylang.php:193
37
  msgid "Error: Restore of local flags failed!"
38
  msgstr ""
39
 
40
+ #: ../polylang.php:194
41
  msgid "Please restore your local flags"
42
  msgstr ""
43
 
44
  #: ../include/edit-term-form.php:6
45
+ #: ../include/term-translations.php:15
46
+ #: ../include/admin-filters.php:91
47
+ #: ../include/admin-filters.php:327
48
+ #: ../include/add-term-form.php:5
49
  #: ../include/list-table.php:12
 
50
  msgid "Language"
51
  msgstr ""
52
 
53
+ #: ../include/edit-term-form.php:19
54
+ #: ../include/add-term-form.php:13
55
  msgid "Sets the language"
56
  msgstr ""
57
 
58
+ #: ../include/widget.php:6
59
+ msgid "Language Switcher"
60
  msgstr ""
61
 
62
  #: ../include/widget.php:6
63
+ msgid "Displays a language switcher"
64
  msgstr ""
65
 
66
+ #: ../include/widget.php:62
67
  msgid "Title:"
68
  msgstr ""
69
 
70
+ #: ../include/widget.php:65
71
+ #: ../include/admin.php:236
72
+ msgid "Displays language names"
73
  msgstr ""
74
 
75
+ #: ../include/widget.php:66
76
+ #: ../include/admin.php:237
77
+ msgid "Displays flags"
78
  msgstr ""
79
 
80
+ #: ../include/widget.php:67
81
+ msgid "Displays as dropdown"
82
  msgstr ""
83
 
84
+ #: ../include/widget.php:68
85
+ #: ../include/admin.php:238
86
+ msgid "Forces link to front page"
87
+ msgstr ""
88
+
89
+ #: ../include/admin.php:21
90
+ #: ../include/admin.php:209
91
  msgid "Settings"
92
  msgstr ""
93
 
94
+ #: ../include/admin.php:28
95
+ #: ../include/admin.php:207
96
+ #: ../include/admin-filters.php:135
97
  #: ../include/list-table.php:13
 
98
  msgid "Languages"
99
  msgstr ""
100
 
101
+ #: ../include/admin.php:208
102
+ msgid "Menus"
103
+ msgstr ""
104
+
105
+ #: ../include/admin.php:225
106
  msgid "Enter a valid WorPress locale"
107
  msgstr ""
108
 
109
+ #: ../include/admin.php:226
110
  msgid "The language code must be 2 characters long"
111
  msgstr ""
112
 
113
+ #: ../include/admin.php:227
114
  msgid "The language code must be unique"
115
  msgstr ""
116
 
117
+ #: ../include/admin.php:228
118
  msgid "The language must have a name"
119
  msgstr ""
120
 
121
+ #: ../include/admin.php:235
122
+ msgid "Displays a language switcher at the end of the menu"
123
  msgstr ""
124
 
125
+ #: ../include/post-metabox.php:5
126
+ msgid "Page's language:"
127
  msgstr ""
128
 
129
+ #: ../include/post-metabox.php:5
130
+ msgid "Post's language:"
 
131
  msgstr ""
132
 
133
+ #: ../include/term-translations.php:6
134
+ #: ../include/term-translations.php:11
135
+ msgid "Translations"
136
  msgstr ""
137
 
138
+ #: ../include/term-translations.php:15
139
+ msgid "Translation"
140
  msgstr ""
141
 
142
+ #: ../include/term-translations.php:15
143
+ #: ../include/term-translations.php:76
144
+ #: ../include/list-table.php:33
145
+ msgid "Edit"
146
  msgstr ""
147
 
148
+ #: ../include/term-translations.php:62
149
+ msgid "Add new"
150
  msgstr ""
151
 
152
+ #: ../include/admin-filters.php:123
153
+ msgid "Show all languages"
 
154
  msgstr ""
155
 
156
+ #: ../include/admin-filters.php:400
157
+ msgid "Theme locations and languages"
158
  msgstr ""
159
 
160
+ #: ../include/admin-filters.php:405
161
+ #, php-format
162
+ msgid "Please go to the %slanguages page%s to set theme locations and languages"
 
 
 
163
  msgstr ""
164
 
165
+ #: ../include/admin-filters.php:416
166
+ msgid "The widget is displayed for:"
 
167
  msgstr ""
168
 
169
+ #: ../include/admin-filters.php:417
170
+ msgid "All languages"
171
+ msgstr ""
172
+
173
+ #: ../include/list-table.php:34
174
  msgid "Delete"
175
  msgstr ""
176
 
177
+ #: ../include/list-table.php:52
178
+ #: ../include/languages-form.php:66
179
  msgid "Full name"
180
  msgstr ""
181
 
182
+ #: ../include/list-table.php:53
183
+ #: ../include/languages-form.php:72
184
  msgid "Locale"
185
  msgstr ""
186
 
187
+ #: ../include/list-table.php:54
188
  msgid "Code"
189
  msgstr ""
190
 
191
+ #: ../include/list-table.php:55
192
+ msgid "Flag"
193
+ msgstr ""
194
+
195
+ #: ../include/list-table.php:56
196
  msgid "Posts"
197
  msgstr ""
198
 
199
+ #: ../include/calendar.php:99
200
  #, php-format
201
  msgid "%1$s %2$s"
202
  msgstr ""
203
 
204
+ #: ../include/calendar.php:125
205
+ #: ../include/calendar.php:133
206
  #, php-format
207
  msgid "View posts for %1$s %2$s"
208
  msgstr ""
212
  msgstr ""
213
 
214
  #: ../include/languages-form.php:33
215
+ #: ../include/languages-form.php:83
216
  msgid "Add new language"
217
  msgstr ""
218
 
219
+ #: ../include/languages-form.php:54
220
+ msgid "Choose a language"
221
+ msgstr ""
222
+
223
+ #: ../include/languages-form.php:62
224
+ msgid "You can choose a language in the list or directly edit it below."
225
+ msgstr ""
226
+
227
+ #: ../include/languages-form.php:68
228
  msgid "The name is how it is displayed on your site (for example: English)."
229
  msgstr ""
230
 
231
+ #: ../include/languages-form.php:74
232
  msgid "Wordpress Locale for the language (for example: en_US). You will need to install the .mo file for this language."
233
  msgstr ""
234
 
235
+ #: ../include/languages-form.php:78
236
  msgid "Language code"
237
  msgstr ""
238
 
239
+ #: ../include/languages-form.php:80
240
  msgid "2-letters ISO 639-1 language code (for example: en)"
241
  msgstr ""
242
 
243
+ #: ../include/languages-form.php:83
244
  msgid "Update"
245
  msgstr ""
246
 
 
 
 
 
 
 
 
 
247
  #: ../include/languages-form.php:131
248
+ msgid "Language switcher"
249
  msgstr ""
250
 
251
+ #: ../include/languages-form.php:158
252
  msgid "Default language"
253
  msgstr ""
254
 
255
+ #: ../include/languages-form.php:187
256
  msgid "There are posts, pages, categories or tags without language set. Do you want to set them all to default language ?"
257
  msgstr ""
258
 
259
+ #: ../include/languages-form.php:195
260
  msgid "Detect browser language"
261
  msgstr ""
262
 
263
+ #: ../include/languages-form.php:201
264
  msgid "When the front page is visited, set the language according to the browser preference"
265
  msgstr ""
266
 
267
+ #: ../include/languages-form.php:208
268
  msgid "URL modifications"
269
  msgstr ""
270
 
271
+ #: ../include/languages-form.php:214
272
  msgid "Keep /language/ in pretty permalinks. Example:"
273
  msgstr ""
274
 
275
+ #: ../include/languages-form.php:222
276
  msgid "Remove /language/ in pretty permalinks. Example:"
277
  msgstr ""
278
 
279
+ #: ../include/languages-form.php:230
280
  msgid "Hide URL language information for default language"
281
  msgstr ""
282
 
296
  msgid "Post ID"
297
  msgstr ""
298
 
299
+ #: ../include/personal-options.php:5
300
  msgid "Admin language"
301
  msgstr ""
302
 
polylang.php CHANGED
@@ -2,12 +2,12 @@
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://wordpress.org/extend/plugins/polylang/
5
- Version: 0.4.4
6
  Author: F. Demarle
7
  Description: Adds multilingual capability to Wordpress
8
  */
9
 
10
- /* Copyright 2011 F. Demarle
11
 
12
  This program is free software; you can redistribute it and/or modify
13
  it under the terms of the GNU General Public License, version 2, as
@@ -23,22 +23,24 @@ 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.4.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') );
@@ -46,6 +48,7 @@ class Polylang extends Polylang_Base {
46
  // manages plugin upgrade
47
  add_filter('upgrader_pre_install', array(&$this, 'pre_upgrade'));
48
  add_filter('upgrader_post_install', array(&$this, 'post_upgrade'));
 
49
 
50
  // plugin and widget initialization
51
  add_action('init', array(&$this, 'init'));
@@ -54,80 +57,35 @@ class Polylang extends Polylang_Base {
54
  // rewrite rules
55
  add_filter('rewrite_rules_array', array(&$this, 'rewrite_rules_array' ));
56
 
57
- // filters categories and post tags by language
58
- add_filter('terms_clauses', array(&$this, 'terms_clauses'), 10, 3);
59
-
60
- if (is_admin())
61
  new Polylang_Admin();
 
62
  else {
63
- // text domain management
64
- add_filter('locale', array(&$this, 'get_locale'));
65
- add_filter('override_load_textdomain', array(&$this, 'mofile'), 10, 3);
66
- add_action('wp', array(&$this, 'load_textdomains'));
67
-
68
- // filters posts according to the language
69
- add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
70
-
71
- // meta in the html head section
72
- remove_action('wp_head', 'rel_canonical');
73
- add_action('wp_head', array(&$this, 'wp_head'));
74
-
75
- // prevents redirection of the homepage
76
- add_filter('redirect_canonical', array(&$this, 'redirect_canonical'), 10, 2);
77
-
78
- // adds javascript at the end of the document
79
- add_action('wp_print_footer_scripts', array(&$this, 'wp_print_footer_scripts'));
80
-
81
- // adds the language information in the search form
82
- add_filter('get_search_form', array(&$this, 'get_search_form'));
83
-
84
- // filters the pages according to the current language in wp_list_pages
85
- add_filter('wp_list_pages_excludes', array(&$this, 'wp_list_pages_excludes'));
86
-
87
- // filters the comments according to the current language
88
- add_filter('comments_clauses', array(&$this, 'comments_clauses'), 10, 2);
89
-
90
- // rewrites feed links to filter them by language
91
- add_filter('feed_link', array(&$this, 'feed_link'), 10, 2);
92
-
93
- // rewrites archives links to filter them by language
94
- add_filter('getarchives_join', array(&$this, 'posts_join'));
95
- add_filter('getarchives_where', array(&$this, 'posts_where'));
96
-
97
- // rewrites author and date links to filter them by language
98
- add_filter('author_link', array(&$this, 'archive_link'));
99
- add_filter('year_link', array(&$this, 'archive_link'));
100
- add_filter('month_link', array(&$this, 'archive_link'));
101
- add_filter('day_link', array(&$this, 'archive_link'));
102
-
103
- // modifies the calendar to filter posts by language
104
- add_filter('get_calendar', array(&$this, 'get_calendar'));
105
-
106
- // rewrites next and previous post links to filter them by language
107
- add_filter('get_previous_post_join', array(&$this, 'posts_join'));
108
- add_filter('get_next_post_join', array(&$this, 'posts_join'));
109
- add_filter('get_previous_post_where', array(&$this, 'posts_where'));
110
- add_filter('get_next_post_where', array(&$this, 'posts_where'));
111
-
112
- // filters the nav menus according to the current language
113
- add_filter('wp_nav_menu_args', array(&$this, 'wp_nav_menu_args'));
114
-
115
- // filters the widgets according to the current language
116
- add_filter('widget_display_callback', array(&$this, 'widget_display_callback'), 10, 3);
117
-
118
- // modifies the home url
119
- add_filter('home_url', array(&$this, 'home_url'));
120
 
121
- // allows a new value for the 'show' parameter to display the homepage url according to the current language
122
- add_filter('bloginfo_url', array(&$this, 'bloginfo_url'), 10, 2);
 
123
 
124
- // Template tags
125
- add_action('the_languages', array(&$this, 'the_languages'));
 
 
 
 
 
126
  }
 
 
127
  }
128
 
129
  // plugin activation
130
- function activate() {
131
  // create the termmeta table - not provided by WP by default - if it does not already exists
132
  // uses exactly the same model as other meta tables to be able to use access functions provided by WP
133
  global $wpdb;
@@ -169,11 +127,28 @@ class Polylang extends Polylang_Base {
169
  $wp_rewrite->flush_rules();
170
  }
171
 
172
- // plugin deactivation
173
  function deactivate() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  // delete our rewrite rules
175
  remove_filter('rewrite_rules_array', array(&$this,'rewrite_rules_array' ));
176
- global $wp_rewrite;
177
  $wp_rewrite->flush_rules();
178
  }
179
 
@@ -193,7 +168,7 @@ class Polylang extends Polylang_Base {
193
  return new WP_Error('polylang_upgrade_error', sprintf('%s<br />%s <strong>%s</strong>',
194
  __("Error: Upgrade directory doesn't exist!", 'polylang'),
195
  __('Please create', 'polylang'),
196
- esc_attr($dir)
197
  ));
198
  }
199
 
@@ -201,7 +176,7 @@ class Polylang extends Polylang_Base {
201
  return new WP_Error('polylang_backup_error', sprintf('%s<br />%s <strong>%s</strong>',
202
  __('Error: Backup of local flags failed!', 'polylang'),
203
  __('Please backup', 'polylang'),
204
- esc_attr($flags_dir)
205
  ));
206
 
207
  return true;
@@ -217,13 +192,56 @@ class Polylang extends Polylang_Base {
217
  return new WP_Error('polylang_restore_error', sprintf('%s<br />%s (<strong>%s</strong>)',
218
  __('Error: Restore of local flags failed!', 'polylang'),
219
  __('Please restore your local flags', 'polylang'),
220
- esc_attr($upgrade_dir)
221
  ));
222
 
223
  @rmdir(WP_CONTENT_DIR . '/upgrade/polylang');
224
  return true;
225
  }
226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  // some initialization
228
  function init() {
229
  global $wpdb;
@@ -244,19 +262,23 @@ class Polylang extends Polylang_Base {
244
  if ($options['rewrite'] && $wp_rewrite->extra_permastructs)
245
  $wp_rewrite->extra_permastructs['language'][0] = '%language%';
246
 
247
- $this->default_locale = get_locale(); // save the default locale before we start any language manipulation
248
  load_plugin_textdomain('polylang', false, basename(POLYLANG_DIR).'/languages'); // plugin i18n
249
  }
250
 
251
- // registers our widget
252
  function widgets_init() {
253
  register_widget('Polylang_Widget');
 
 
 
 
254
  }
255
 
256
  // rewrites rules if pretty permalinks are used
257
  function rewrite_rules_array($rules) {
258
  $options = get_option('polylang');
259
  $newrules = array();
 
260
  $listlanguages = $this->get_languages_list();
261
 
262
  // modifies the rules created by WordPress when '/language/' is removed in permalinks
@@ -305,561 +327,6 @@ class Polylang extends Polylang_Base {
305
  return $newrules + $rules;
306
  }
307
 
308
- // filters categories and post tags by language when needed (both in admin panels and frontend)
309
- function terms_clauses($clauses, $taxonomies, $args) {
310
- // does nothing except on taxonomies which have show_ui set to 1 (includes category and post_tags)
311
- foreach ($taxonomies as $tax) {
312
- if(!get_taxonomy($tax)->show_ui)
313
- return $clauses;
314
- }
315
-
316
- if (is_admin()) {
317
-
318
- if (function_exists('get_current_screen'))
319
- $screen = get_current_screen(); // since WP 3.1, may not be available the first time(s) get_terms is called
320
-
321
- // does nothing in the Categories, Post tags, Languages and Posts* admin panels
322
- if (!isset($screen) || $screen->base == 'edit-tags' || $screen->base == 'toplevel_page_mlang' || $screen->base == 'edit')
323
- return $clauses;
324
-
325
- // *FIXME I want all categories in the dropdown list and only the ones in the right language in the inline edit
326
- // It seems that I need javascript to get the post_id as inline edit data are manipulated in inline-edit-post.js
327
-
328
- $this->curlang = $this->get_current_language();
329
- }
330
-
331
- // adds our clauses to filter by current language
332
- if ($this->curlang) {
333
- global $wpdb;
334
- $clauses['join'] .= " INNER JOIN $wpdb->termmeta AS tm ON t.term_id = tm.term_id";
335
- $clauses['where'] .= $wpdb->prepare(" AND tm.meta_key = '_language' AND tm.meta_value = %d", $this->curlang->term_id);
336
- }
337
- return $clauses;
338
- }
339
-
340
- // returns the language according to browser preference or the default language
341
- function get_preferred_language() {
342
- // check first is the user was already browsing this site
343
- if (isset($_COOKIE['wordpress_polylang']))
344
- return $this->get_language($_COOKIE['wordpress_polylang']);
345
-
346
- // sets the browsing language according to the browser preferences
347
- // code adapted from http://www.thefutureoftheweb.com/blog/use-accept-language-header
348
- $options = get_option('polylang');
349
- if ($options['browser']) {
350
- $accept_langs = array();
351
-
352
- if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
353
- // break up string into pieces (languages and q factors)
354
- preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
355
-
356
- if (count($lang_parse[1])) {
357
- // NOTE: array_combine => PHP5
358
- $accept_langs = array_combine($lang_parse[1], $lang_parse[4]); // create a list like "en" => 0.8
359
- // set default to 1 for any without q factor
360
- foreach ($accept_langs as $accept_lang => $val) {
361
- if ($val === '') $accept_langs[$accept_lang] = 1;
362
- }
363
- arsort($accept_langs, SORT_NUMERIC); // sort list based on value
364
- }
365
- }
366
-
367
- // looks through sorted list and use first one that matches our language list
368
- $listlanguages = $this->get_languages_list(true); // hides languages with no post
369
- foreach ($accept_langs as $accept_lang => $val) {
370
- foreach ($listlanguages as $language) {
371
- if (strpos($accept_lang, $language->slug) === 0 && !isset($pref_lang)) {
372
- $pref_lang = $language;
373
- }
374
- }
375
- }
376
- } // options['browser']
377
-
378
- // either there is no preference in the browser or preferences does not match our language list or it is requested not to use the browser preference
379
- if (!isset($pref_lang))
380
- $pref_lang = $this->get_language($options['default_lang']);
381
-
382
- return $pref_lang;
383
- }
384
-
385
- // returns the current language
386
- function get_current_language() {
387
- global $post_ID;
388
-
389
- if($this->curlang)
390
- return $this->curlang;
391
-
392
- // no language set for 404 and attachment
393
- if (is_404() || is_attachment())
394
- return $this->get_preferred_language();
395
-
396
-
397
- if (is_admin()) {
398
- if (isset($post_ID))
399
- $lang = $this->get_post_language($post_ID);
400
-
401
- if (isset($_POST['action']) && $_POST['action'] == 'get-tagcloud') {
402
- // to get the language in the Post Tags metabox in the Edit Post screen (as $post_ID not defined)
403
- $qvars = $this->get_referer_vars();
404
- if (isset($qvars['new_lang']))
405
- $lang= $this->get_language($qvars['new_lang']); // post has been created with 'add new' (translation)
406
- elseif (isset($qvars['post']))
407
- $lang = $this->get_post_language($qvars['post']); // edit post
408
- }
409
-
410
- // the post is created with the 'add new' (translation) link
411
- if (isset($_GET['new_lang']))
412
- $lang = $this->get_language($_GET['new_lang']);
413
- }
414
- elseif ($var = get_query_var('lang'))
415
- $lang = $this->get_language($var);
416
-
417
- elseif (is_single() || is_page() && $var = get_queried_object_id())
418
- $lang = $this->get_post_language($var);
419
-
420
- else {
421
- foreach (get_taxonomies(array('show_ui'=>true)) as $taxonomy) {
422
- if ($var = get_query_var(get_taxonomy($taxonomy)->query_var))
423
- $lang = $this->get_term_language($var, $taxonomy);
424
- }
425
- }
426
-
427
- return (isset($lang)) ? $lang : NULL;
428
- }
429
-
430
- // returns the locale based on current language
431
- function get_locale($locale) {
432
- if ($this->curlang)
433
- $locale = $this->curlang->description;
434
- return $locale;
435
- }
436
-
437
- // saves all text domains in a table for later usage
438
- function mofile($bool, $domain, $mofile) {
439
- $this->list_textdomains[] = array ('mo' => $mofile, 'domain' => $domain);
440
- return true; // prevents WP loading text domains as we will load them all later
441
- }
442
-
443
- // NOTE: I believe there are two ways for a plugin to force the WP language
444
- // as done by xili_language and here: load text domains and reinitialize wp_locale with the action 'wp'
445
- // as done by qtranslate: define the locale with the action 'plugins_loaded', but in this case, the language must be specified in the url.
446
- function load_textdomains() {
447
- // sets the current language and set a cookie to remember it
448
- if ($this->curlang = $this->get_current_language())
449
- setcookie('wordpress_polylang', $this->curlang->slug, time() + 31536000 /* 1 year */, COOKIEPATH, COOKIE_DOMAIN);
450
-
451
- // our override_load_textdomain filter has done its job. let's remove it before calling load_textdomain
452
- remove_filter('override_load_textdomain', array(&$this, 'mofile'));
453
-
454
- // now we can load text domains with the right language
455
- $new_locale = get_locale();
456
- foreach ($this->list_textdomains as $textdomain)
457
- load_textdomain( $textdomain['domain'], str_replace($this->default_locale, $new_locale, $textdomain['mo']));
458
-
459
- global $wp_locale;
460
- $wp_locale->init(); // reinitializes wp_locale for weekdays and months
461
- }
462
-
463
- // filters posts according to the language
464
- function pre_get_posts($query) {
465
- $options = get_option('polylang');
466
- $qvars = $query->query_vars;
467
-
468
- // detect our exclude pages query and returns to avoid conflicts
469
- // this test should be sufficient
470
- if (isset($qvars['tax_query'][0]) && isset($qvars['tax_query'][0]['taxonomy']) && isset($qvars['tax_query'][0]['operator']))
471
- return;
472
-
473
- if (empty($query->query)) {
474
- if ( $options['hide_default'] && isset($_COOKIE['wordpress_polylang']) )
475
- $this->curlang = $this->get_language($options['default_lang']);
476
- else
477
- $this->curlang = $this->get_preferred_language(); // sets the language according to browser preference or default language
478
-
479
- if ($options['default_lang'] == $this->curlang->slug && $options['hide_default']) {
480
- if (($post_id = get_option('page_on_front')) && $link_id = $this->get_post($post_id, $this->curlang))
481
- $query->set('page_id', $link_id);
482
- else
483
- $query->set('lang', $this->curlang->slug);
484
- }
485
- else {
486
- if (($post_id = get_option('page_on_front')) && $link_id = $this->get_post($post_id, $this->curlang))
487
- $url = _get_page_link($link_id);
488
- else
489
- $url = home_url('?lang='.$this->curlang->slug);
490
-
491
- wp_redirect($url);
492
- exit;
493
- }
494
- }
495
-
496
- // sets the language for posts page in case the front page displays a static page
497
- if (($page_for_posts = get_option('page_for_posts')) &&
498
- isset($query->queried_object_id) &&
499
- $this->get_post($query->queried_object_id, $this->get_post_language($page_for_posts)) == $page_for_posts
500
- ) {
501
- $query->set('lang',$this->get_post_language($query->queried_object_id)->slug);
502
- $query->queried_object_id = get_option('page_for_posts');
503
- $query->is_page = false;
504
- $query->is_home = true;
505
- $query->is_posts_page = true;
506
- $query->is_singular = false;
507
- }
508
-
509
- // FIXME to generalize as I probably forget things
510
- // sets the language in case we hide the default language
511
- if ( $options['hide_default'] && !isset($qvars['lang']) && (
512
- (count($query->query) == 1 && isset($qvars['paged']) && $qvars['paged']) ||
513
- isset($qvars['m']) && $qvars['m'] ||
514
- isset($qvars['feed']) && $qvars['feed'] ||
515
- isset($qvars['author']) && $qvars['author']))
516
- $query->set('lang', $options['default_lang']);
517
-
518
- // filters recent posts to the current language
519
- // FIXME if $qvars['post_type'] == 'nav_menu_item', setting lang breaks custom menus.
520
- // since to get nav_menu_items, get_post is used and no language is linked to nav_menu_items
521
- if ($query->is_home && $this->curlang && !isset($qvars['post_type']))
522
- $query->set('lang', $this->curlang->slug);
523
-
524
- // remove pages query when the language is set unless we do a search
525
- // FIXME is only search broken by this ?
526
- if (isset($qvars['lang']) && $qvars['lang'] && !isset($qvars['post_type']) && !is_search())
527
- $query->set('post_type', 'post');
528
-
529
- // unset the is_archive flag for language pages to prevent loading the archive template
530
- // keep archive flag for comment feed otherwise the language filter does not work
531
- if (isset($qvars['lang']) && $qvars['lang'] && !is_post_type_archive() && !is_date() && !is_author() && !is_category() && !is_tag() && !is_comment_feed())
532
- $query->is_archive = false;
533
-
534
- // unset the is_tax flag for authors pages
535
- // FIXME Probably I should do this for other cases
536
- if (isset($qvars['lang']) && $qvars['lang'] && is_author())
537
- $query->is_tax = false;
538
- }
539
-
540
- function wp_head() {
541
- // modifies the canonical link to the homepage
542
- if (is_singular()) {
543
- global $wp_the_query;
544
- if ($id = $wp_the_query->get_queried_object_id()) {
545
- if (is_page())
546
- $link = _get_page_link($id); // ignores page_on_front unlike get_permalink
547
- else
548
- $link = get_permalink ($id);
549
- echo "<link rel='canonical' href='$link' />\n";
550
- }
551
- }
552
-
553
- // outputs references to translated pages (if exists) in the html head section
554
- foreach ($this->get_languages_list() as $language) {
555
- if ($language->slug != $this->curlang->slug && $url = $this->get_translation_url($language))
556
- printf("<link hreflang='%s' href='%s' rel='alternate' />\n", esc_attr($language->slug), esc_url($url));
557
- }
558
- }
559
-
560
- // prevents redirection of the homepage
561
- function redirect_canonical($redirect_url, $requested_url) {
562
- if($requested_url == _get_page_link(get_option('page_on_front')))
563
- return false;
564
- return $redirect_url;
565
- }
566
-
567
- // adds some javascript workaround knowing it's not perfect...
568
- function wp_print_footer_scripts() {
569
- if ($this->curlang) {
570
- $js = '';
571
-
572
- // modifies the search form since filtering get_search_form won't work if the template uses searchform.php
573
- // don't use directly e[0] just in case there is somewhere else an element named 's'
574
- // check before if the hidden input has not already been introduced by get_search_form
575
- if (!$this->search_form_filter) {
576
- $lang = esc_js($this->curlang->slug);
577
- $js .= "e = document.getElementsByName('s');
578
- for (i = 0; i < e.length; i++) {
579
- if (e[i] == '[object HTMLInputElement]') {
580
- var ih = document.createElement('input');
581
- ih.type = 'hidden';
582
- ih.name = 'lang';
583
- ih.value = '$lang';
584
- e[i].parentNode.appendChild(ih);
585
- }
586
- }";
587
- }
588
-
589
- if ($js)
590
- echo "<script type='text/javascript'>" .$js. "</script>";
591
- }
592
- }
593
-
594
- // adds the language information in the search form
595
- // does not work if searchform.php is used
596
- function get_search_form($form) {
597
- if ($form) {
598
- $this->search_form_filter = true;
599
- $form = str_replace('</form>', '<input type="hidden" name="lang" value="'.esc_attr($this->curlang->slug).'" /></form>', $form);
600
- }
601
- return $form;
602
- }
603
-
604
- // excludes pages which are not in the current language for wp_list_pages
605
- // useful for the pages widget
606
- function wp_list_pages_excludes($pages) {
607
- if (isset($this->curlang)) {
608
- $q = array(
609
- 'numberposts'=>-1,
610
- 'post_type' => 'page',
611
- 'fields' => 'ids',
612
- 'tax_query' => array(array(
613
- 'taxonomy'=>'language',
614
- 'fields' => 'id',
615
- 'terms'=>$this->curlang->term_id,
616
- 'operator'=>'NOT IN'
617
- ))
618
- );
619
- $pages = array_merge($pages, get_posts($q));
620
- }
621
- return $pages;
622
- }
623
-
624
- // filters the comments according to the current language mainly for the recent comments widget
625
- function comments_clauses($clauses, $comment_query) {
626
- // first test if wp_posts.ID already available in the query
627
- if ($this->curlang && strpos($clauses['join'], '.ID')) {
628
- global $wpdb;
629
- $clauses['join'] .= " INNER JOIN $wpdb->term_relationships AS tr ON tr.object_id = ID";
630
- $clauses['join'] .= " INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
631
- $clauses['where'] .= $wpdb->prepare(" AND tt.term_id = %d", $this->curlang->term_id);
632
- }
633
- return $clauses;
634
- }
635
-
636
- // Modifies the feed link to add the language parameter
637
- function feed_link($url, $feed) {
638
- global $wp_rewrite;
639
- $options = get_option('polylang');
640
-
641
- if ($this->curlang) {
642
- if ($wp_rewrite->using_permalinks()) {
643
- $home = get_option('home');
644
- $base = $options['rewrite'] ? '/' : '/language/';
645
- $slug = $options['default_lang'] == $this->curlang->slug && $options['hide_default'] ? '' : $base.$this->curlang->slug;
646
- $url = esc_url(str_replace($home, $home.$slug, $url));
647
- }
648
- elseif ($feed)
649
- $url = esc_url(home_url('?lang='.$this->curlang->slug.'&feed='.$feed));
650
-
651
- }
652
- return $url;
653
- }
654
-
655
- // modifies the sql request for wp_get_archives an get_adjacent_post to filter by the current language
656
- function posts_join($sql) {
657
- if ($this->curlang) {
658
- global $wpdb;
659
- $sql .= " INNER JOIN $wpdb->term_relationships ON object_id = ID";
660
- }
661
- return $sql;
662
- }
663
-
664
- // modifies the sql request for wp_get_archives and get_adjacent_post to filter by the current language
665
- function posts_where($sql) {
666
- if ($this->curlang) {
667
- global $wpdb;
668
- $sql .= $wpdb->prepare(" AND term_taxonomy_id = %d", $this->curlang->term_id);
669
- }
670
- return $sql;
671
- }
672
-
673
- // modifies the author and date links to add the language parameter
674
- function archive_link($link) {
675
- if ($this->curlang) {
676
- global $wp_rewrite;
677
- $options = get_option('polylang');
678
- $home = get_option('home');
679
-
680
- if ($wp_rewrite->using_permalinks()) {
681
- $base = $options['rewrite'] ? '/' : '/language/';
682
- $slug = $options['default_lang'] == $this->curlang->slug && $options['hide_default'] ? '' : $base.$this->curlang->slug;
683
- $link = esc_url(str_replace($home, $home.$slug, $link));
684
- }
685
- else
686
- $link = esc_url(str_replace($home.'/?', $home.'/?lang='.$this->curlang->slug.'&amp;', $link));
687
- }
688
- return $link;
689
- }
690
-
691
- // modifies the calendar to filter posts by language
692
- function get_calendar() {
693
- require_once(INC_DIR.'/calendar.php');
694
- return $calendar_output;
695
- }
696
-
697
- // returns the url of the translation (if exists) of the current page
698
- function get_translation_url($language) {
699
- global $wp_query, $wp_rewrite;
700
- $qvars = $wp_query->query;
701
- $options = get_option('polylang');
702
- $hide = $options['default_lang'] == $language->slug && $options['hide_default'];
703
-
704
- // is_single is set to 1 for attachment but no language is set
705
- if (is_single() && !is_attachment() && $id = $this->get_post(get_the_ID(), $language))
706
- $url = get_permalink($id);
707
-
708
- // page for posts
709
- elseif (isset($wp_query->queried_object_id) && $wp_query->queried_object_id == ($page_for_posts = get_option('page_for_posts')))
710
- $url = get_permalink($this->get_post($page_for_posts, $language));
711
-
712
- elseif (is_page() && $id = $this->get_post(get_the_ID(), $language))
713
- $url = $hide && $id == $this->get_post(get_option('page_on_front'), $language) ?
714
- get_option('home') :
715
- _get_page_link($id);
716
-
717
- elseif ( !is_tax ('language') && (is_category() || is_tag() || is_tax () ) ) {
718
- $term = get_queried_object();
719
- $lang = $this->get_term_language($term->term_id);
720
- $taxonomy = $term->taxonomy;
721
-
722
- if ($language->slug == $lang->slug)
723
- $url = get_term_link($term, $taxonomy); // self link
724
- elseif ($link_id = $this->get_translated_term($term->term_id, $language))
725
- $url = get_term_link(get_term($link_id, $taxonomy), $taxonomy);
726
- }
727
-
728
- // don't test if there are existing translations before creating the url as it would be very expensive in sql queries
729
- elseif(is_archive()) {
730
- if ($wp_rewrite->using_permalinks()) {
731
- $base = $options['rewrite'] ? '/' : '/language/';
732
- $base = $hide ? '' : $base.$language->slug;
733
- $base = get_option('home').$base.'/';
734
-
735
- if (is_author())
736
- $url = esc_url($base.'author/'.$qvars['author_name'].'/');
737
-
738
- if (is_year())
739
- $url = esc_url($base.$qvars['year'].'/');
740
-
741
- if (is_month())
742
- $url = esc_url($base.$qvars['year'].'/'.$qvars['monthnum'].'/');
743
-
744
- if (is_day())
745
- $url = esc_url($base.$qvars['year'].'/'.$qvars['monthnum'].'/'.$qvars['day'].'/');
746
- }
747
- else
748
- $url = $hide ? remove_query_arg('lang') : add_query_arg('lang', $language->slug);
749
- }
750
-
751
- elseif (is_home() || is_tax('language') )
752
- $url = $hide ? get_option('home') : get_term_link($language, 'language');
753
-
754
- return isset($url) ? $url : null;
755
- }
756
-
757
- // filters the nav menus according to the current language
758
- function wp_nav_menu_args($args) {
759
- if (!$args['menu'] && $args['theme_location'] && $this->curlang) {
760
- $menu_lang = get_option('polylang_nav_menus');
761
- $args['menu'] = $menu_lang[$args['theme_location']][$this->curlang->slug];
762
- }
763
- return $args;
764
- }
765
-
766
- // filters the widgets according to the current language
767
- function widget_display_callback($instance, $widget, $args) {
768
- $widget_lang = get_option('polylang_widgets');
769
- // don't display if a language filter is set and this is not the current one
770
- if (isset($this->curlang) && isset($widget_lang[$widget->id]) && $widget_lang[$widget->id] && $widget_lang[$widget->id] != $this->curlang->slug)
771
- return false;
772
-
773
- return $instance;
774
- }
775
-
776
- // filters the home url to get the right language
777
- function home_url($url) {
778
- if ( !(did_action('template_redirect') && rtrim($url,'/') == rtrim(get_option('home'),'/') && $this->curlang) )
779
- return $url;
780
-
781
- // don't like this but at least for WP_Widget_Categories::widget, it seems to be the only solution
782
- // FIXME are there other exceptions ?
783
- foreach (debug_backtrace() as $trace) {
784
- $exceptions = $trace['function'] == 'get_pagenum_link' ||
785
- $trace['function'] == 'get_author_posts_url' ||
786
- ($trace['function'] == 'widget' && $trace['class'] == 'WP_Widget_Categories');
787
- if ($exceptions)
788
- return $url;
789
- }
790
-
791
- return $this->get_home_url($this->curlang);
792
- }
793
-
794
- // returns the home url in the right language
795
- function get_home_url($language) {
796
- $options = get_option('polylang');
797
- if ($options['default_lang'] == $language->slug && $options['hide_default'])
798
- return trailingslashit(get_option('home'));
799
-
800
- // a static page is used as front page
801
- if (($post_id = get_option('page_on_front')) && $id = $this->get_post($post_id, $language))
802
- $url = _get_page_link($id);
803
-
804
- return isset($url) ? $url : get_term_link($language, 'language');
805
- }
806
-
807
- // adds 'lang_url' as possible value to the 'show' parameter of bloginfo to display the home url in the correct language
808
- // FIXME not tested
809
- function bloginfo_url($output, $show) {
810
- if ($show == 'lang_url' && $this->curlang) {
811
- $url = $this->get_home_url($this->curlang);
812
- $output = isset($url) ? $url : get_option('home');
813
- }
814
- return $output;
815
- }
816
-
817
- // Template tag: Displays links to the current page in other languages
818
- // Usage: do_action('the_languages');
819
- function the_languages($args = '') {
820
- $defaults = array(
821
- 'dropdown' => 0, // display as list and not as dropdown
822
- 'show_names' => 1, // show language names
823
- 'show_flags' => 0, // don't show flags
824
- 'hide_if_empty' => 1 // hides languages with no posts (or pages)
825
- );
826
- extract(wp_parse_args($args, $defaults));
827
-
828
- $listlanguages = $this->get_languages_list($hide_if_empty);
829
- $output = $dropdown ? '<select name="lang_choice" id="lang_choice">' : "<ul>\n";
830
-
831
- foreach ($listlanguages as $language) {
832
- if ($dropdown) {
833
- $output .= sprintf(
834
- "<option value='%s'%s>%s</option>\n",
835
- esc_attr($language->slug),
836
- $language->slug == $this->curlang->slug ? ' selected="selected"' : '',
837
- esc_attr($language->name) // FIXME flag does not work for the dropdown list
838
- );
839
- }
840
- else {
841
- $url = $this->get_translation_url($language);
842
- $url = isset($url) ? $url : $this->get_home_url($language); // if the page is not translated, link to the home page
843
-
844
- $class = 'lang-item lang-item-'.esc_attr($language->term_id);
845
- $class .= $language->slug == $this->curlang->slug ? ' current-lang' : '';
846
-
847
- $flag = $show_flags && (
848
- file_exists(POLYLANG_DIR.($file = '/local_flags/'.$language->description.'.png')) ||
849
- file_exists(POLYLANG_DIR.($file = '/local_flags/'.$language->description.'.jpg')) ||
850
- file_exists(POLYLANG_DIR.($file = '/flags/'.$language->description.'.png')) ) ?
851
- '<img src="'.esc_url(WP_PLUGIN_URL.'/polylang'.$file).'" alt="'.esc_attr($language->name).'" />' : '';
852
-
853
- $name = $show_names || !$show_flags ? esc_attr($language->name) : '';
854
-
855
- $output .= '<li class="'.$class.'"><a href="'.esc_url($url).'">'.($show_flags && $show_names ? $flag.'&nbsp;'.$name : $flag.$name)."</a></li>\n";
856
- }
857
- }
858
-
859
- $output .= $dropdown ? '</select>' : "</ul>\n";
860
- echo $output;
861
- }
862
-
863
  } // class Polylang
864
 
865
  if (class_exists("Polylang"))
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://wordpress.org/extend/plugins/polylang/
5
+ Version: 0.5
6
  Author: F. Demarle
7
  Description: Adds multilingual capability to Wordpress
8
  */
9
 
10
+ /* Copyright 2011 F. Demarle
11
 
12
  This program is free software; you can redistribute it and/or modify
13
  it under the terms of the GNU General Public License, version 2, as
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  */
25
 
26
+ define('POLYLANG_VERSION', '0.5');
27
 
28
  define('POLYLANG_DIR', dirname(__FILE__));
29
+ define('PLL_INC', POLYLANG_DIR.'/include');
30
 
31
+ if (!defined('PLL_DISPLAY_ALL'))
32
+ define('PLL_DISPLAY_ALL', false); // diplaying posts & terms with undefined language is disabled by default
 
33
 
34
+ require_once(PLL_INC.'/base.php');
35
+ require_once(PLL_INC.'/widget.php');
36
+ require_once(PLL_INC.'/calendar.php');
37
+
38
+ // controls the plugin, deals with activation, deactivation, upgrades, initialization as well as rewrite rules
39
  class Polylang extends Polylang_Base {
 
 
 
 
40
 
41
  function __construct() {
42
+ global $polylang;
43
+
44
  // manages plugin activation and deactivation
45
  register_activation_hook( __FILE__, array(&$this, 'activate') );
46
  register_deactivation_hook( __FILE__, array(&$this, 'deactivate') );
48
  // manages plugin upgrade
49
  add_filter('upgrader_pre_install', array(&$this, 'pre_upgrade'));
50
  add_filter('upgrader_post_install', array(&$this, 'post_upgrade'));
51
+ add_action('admin_init', array(&$this, 'admin_init'));
52
 
53
  // plugin and widget initialization
54
  add_action('init', array(&$this, 'init'));
57
  // rewrite rules
58
  add_filter('rewrite_rules_array', array(&$this, 'rewrite_rules_array' ));
59
 
60
+ if (is_admin()) {
61
+ require_once(PLL_INC.'/admin.php');
 
 
62
  new Polylang_Admin();
63
+ }
64
  else {
65
+ require_once(PLL_INC.'/core.php');
66
+ require_once(PLL_INC.'/api.php');
67
+ $polylang = new Polylang_Core();
68
+ }
69
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
+ // plugin activation for multisite
72
+ function activate() {
73
+ global $wpdb;
74
 
75
+ // check if it is a network activation - if so, run the activation function for each blog
76
+ if (is_multisite() && isset($_GET['networkwide']) && ($_GET['networkwide'] == 1)) {
77
+ foreach ($wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs")) as $blog_id) {
78
+ switch_to_blog($blog_id);
79
+ $this->_activate();
80
+ }
81
+ restore_current_blog();
82
  }
83
+ else
84
+ $this->_activate();
85
  }
86
 
87
  // plugin activation
88
+ function _activate() {
89
  // create the termmeta table - not provided by WP by default - if it does not already exists
90
  // uses exactly the same model as other meta tables to be able to use access functions provided by WP
91
  global $wpdb;
127
  $wp_rewrite->flush_rules();
128
  }
129
 
130
+ // plugin deactivation for multisite
131
  function deactivate() {
132
+ global $wpdb;
133
+
134
+ // check if it is a network deactivation - if so, run the deactivation function for each blog
135
+ if (is_multisite() && isset($_GET['networkwide']) && ($_GET['networkwide'] == 1)) {
136
+ foreach ($wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs")) as $blog_id) {
137
+ switch_to_blog($blog_id);
138
+ $this->_deactivate();
139
+ }
140
+ restore_current_blog();
141
+ }
142
+ else
143
+ $this->_deactivate();
144
+ }
145
+
146
+ // plugin deactivation
147
+ function _deactivate() {
148
+ global $wp_rewrite;
149
+
150
  // delete our rewrite rules
151
  remove_filter('rewrite_rules_array', array(&$this,'rewrite_rules_array' ));
 
152
  $wp_rewrite->flush_rules();
153
  }
154
 
168
  return new WP_Error('polylang_upgrade_error', sprintf('%s<br />%s <strong>%s</strong>',
169
  __("Error: Upgrade directory doesn't exist!", 'polylang'),
170
  __('Please create', 'polylang'),
171
+ esc_html($dir)
172
  ));
173
  }
174
 
176
  return new WP_Error('polylang_backup_error', sprintf('%s<br />%s <strong>%s</strong>',
177
  __('Error: Backup of local flags failed!', 'polylang'),
178
  __('Please backup', 'polylang'),
179
+ esc_html($flags_dir)
180
  ));
181
 
182
  return true;
192
  return new WP_Error('polylang_restore_error', sprintf('%s<br />%s (<strong>%s</strong>)',
193
  __('Error: Restore of local flags failed!', 'polylang'),
194
  __('Please restore your local flags', 'polylang'),
195
+ esc_html($upgrade_dir)
196
  ));
197
 
198
  @rmdir(WP_CONTENT_DIR . '/upgrade/polylang');
199
  return true;
200
  }
201
 
202
+ // upgrades from old translation used up to V0.4.4 to new model used in V0.5+
203
+ function upgrade_translations($type, $ids) {
204
+ $listlanguages = $this->get_languages_list();
205
+ foreach ($ids as $id) {
206
+ $lang = call_user_func(array(&$this, 'get_'.$type.'_language'), $id);
207
+ if (!$lang)
208
+ continue;
209
+
210
+ $tr = array();
211
+ foreach ($listlanguages as $language) {
212
+ if ($meta = get_metadata($type, $id, '_lang-'.$language->slug, true))
213
+ $tr[$language->slug] = $meta;
214
+ }
215
+
216
+ if(!empty($tr)) {
217
+ $tr = serialize(array_merge(array($lang->slug => $id), $tr));
218
+ update_metadata($type, $id, '_translations', $tr);
219
+ }
220
+ }
221
+ }
222
+
223
+ // manage upgrade even when it is done manually
224
+ function admin_init() {
225
+ $options = get_option('polylang');
226
+ if (version_compare($options['version'], POLYLANG_VERSION, '<')) {
227
+
228
+ if (version_compare($options['version'], '0.4', '<'))
229
+ $options['hide_default'] = 0; // option introduced in 0.4
230
+
231
+ // translation model changed in 0.5
232
+ // FIXME will not delete old data before 0.6 (just in case...)
233
+ if (version_compare($options['version'], '0.5', '<')) {
234
+ $ids = get_posts(array('numberposts'=>-1, 'fields' => 'ids', 'post_type'=>'any', 'post_status'=>'any'));
235
+ $this->upgrade_translations('post', $ids);
236
+ $ids = get_terms(get_taxonomies(array('show_ui'=>true)), array('get'=>'all', 'fields'=>'ids'));
237
+ $this->upgrade_translations('term', $ids);
238
+ }
239
+
240
+ $options['version'] = POLYLANG_VERSION;
241
+ update_option('polylang', $options);
242
+ }
243
+ }
244
+
245
  // some initialization
246
  function init() {
247
  global $wpdb;
262
  if ($options['rewrite'] && $wp_rewrite->extra_permastructs)
263
  $wp_rewrite->extra_permastructs['language'][0] = '%language%';
264
 
 
265
  load_plugin_textdomain('polylang', false, basename(POLYLANG_DIR).'/languages'); // plugin i18n
266
  }
267
 
268
+ // registers our widgets
269
  function widgets_init() {
270
  register_widget('Polylang_Widget');
271
+
272
+ // overwrites the calendar widget to filter posts by language
273
+ unregister_widget('WP_Widget_Calendar');
274
+ register_widget('Polylang_Widget_Calendar');
275
  }
276
 
277
  // rewrites rules if pretty permalinks are used
278
  function rewrite_rules_array($rules) {
279
  $options = get_option('polylang');
280
  $newrules = array();
281
+
282
  $listlanguages = $this->get_languages_list();
283
 
284
  // modifies the rules created by WordPress when '/language/' is removed in permalinks
327
  return $newrules + $rules;
328
  }
329
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  } // class Polylang
331
 
332
  if (class_exists("Polylang"))
readme.txt CHANGED
@@ -1,9 +1,10 @@
1
  === Polylang ===
2
  Contributors: Chouby
3
- Tags: bilingual, language, i18n, international, l10n, localization, multilingual, translate, translation, widget
 
4
  Requires at least: 3.1
5
  Tested up to: 3.3
6
- Stable tag: 0.4.4
7
 
8
  Polylang adds multilingual support to WordPress. You set a language for each post and it will be displayed only when browsing this language.
9
 
@@ -11,19 +12,24 @@ Polylang adds multilingual support to WordPress. You set a language for each pos
11
 
12
  You write posts, pages and create categories and post tags as usual, and then define the language for each of them. The translation is optional. A language switcher widget is provided with the plugin. The plugin does not integrate automatic or professional translation. You have to do the work yourself.
13
 
 
 
 
 
14
  = Features =
15
 
16
  * You can create as many languages as you want
17
  * You can translate posts, pages, categories, post tags, menus
18
  * RSS feed available for each language
19
- * Support for Search form (see FAQ)
20
  * Support for pretty permalinks
21
  * Support for static page (in the right language) used as front page
22
- * All WordPress default widgets (archives, categories, pages, recent comments, recent posts, tag cloud and calendar) are automatically in the right language
23
- * Language switcher provided as a widget
24
  * All widgets can be displayed or not, depending on the language (new in 0.3)
25
  * Each user can set the WordPress admin language in its profile (new in 0.4)
26
  * Support for custom post types and custom taxonomies (new in 0.4)
 
27
 
28
  The plugin admin interface is currently available in:
29
 
@@ -32,13 +38,12 @@ The plugin admin interface is currently available in:
32
  * German
33
  * Russian contributed by [yoyurec](http://yoyurec.in.ua)
34
 
35
- Other translators are welcome ! [Contact me](http://www.flabellina.com/polylang-contact/). I am especially looking for someone who could replace me for the German translation which I did probably very bad...
36
 
37
  = Notes =
38
 
39
- * The tests have been made with WordPress from version 3.1 up to 3.3 beta 3. The plugin does not work with WordPress 3.0.5 and lower.
40
  * Your server must run PHP5
41
- * Multisite is not supported yet.
42
  * You must deactivate other multilingual plugins before activating Polylang, otherwise, you may get unexpected results !
43
  * 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...).
44
 
@@ -48,17 +53,17 @@ Don't hesitate to [give your feedback](http://wordpress.org/tags/polylang?forum_
48
 
49
  == Upgrade Notice ==
50
 
51
- Your custom flags in 'polylang/local_flags' directory will be removed when automatically upgrading from v0.4, v0.4.1, v0.4.2. So either do a manual upgrade or backup your custom flags. This problem is solved when upgrading from v0.4.3 to a higher version.
52
 
53
  == Installation ==
54
 
55
  1. Download the plugin
56
- 1. Extract all the files.
57
  1. Upload everything (keeping the directory structure) to the `/wp-content/plugins/` directory.
58
  1. Activate the plugin through the 'Plugins' menu in WordPress.
59
  1. Add the 'language switcher' Widget to let your visitors switch the language.
60
  1. Go to the languages settings page and create the languages you need
61
- 1. Upload corresponding .mo files in WordPress languages directory (no need for English). You can download it from [here](http://svn.automattic.com/wordpress-i18n/).
62
  1. Take care that your theme must come with the corresponding .mo file too. If your theme is not internationalized yet, please refer to the [codex](http://codex.wordpress.org/I18n_for_WordPress_Developers#I18n_for_theme_and_plugin_developers) or ask the theme author to internationalize it.
63
 
64
  == Frequently Asked Questions ==
@@ -71,29 +76,46 @@ Xili language: I tested the version 2.2.0. It looks too complex. For example you
71
 
72
  qtranslate: I tested the version 2.5.23. As claimed by its author, it's probably the best existing plugin... when using it. However, you must know that it is very difficult to come back to a clean site if you deactivate it (as, for example, one post in the database contains all translations). Moreover, it modifies urls so again, if you deactivate it, all links to your internal urls would be broken (not good for SEO).
73
 
74
- In comparison to these plugins, Polylang tries to keep things simple and light, and does not mess your blog if you deactivate it. But it is still very young so be indulgent ;-)
75
 
76
  = Where to find help ? =
77
 
78
- * A [documentation](http://plugins.svn.wordpress.org/polylang/trunk/doc/documentation-en.pdf) is supplied whith the plugin (look in the doc directory). I spent time to write it so please read it ! A FAQ is available at the end of the document.
79
- * Search the [support forum](http://wordpress.org/tags/polylang?forum_id=10). Other people may had the same issue.
80
- * If you still have a problem, open a new thread in the [support forum](http://wordpress.org/tags/polylang?forum_id=10)
81
 
82
- = Is Polylang compatible with multisite ? =
83
 
84
- Not yet. It is planned for v0.5 (to be released before the end of the year)
85
 
86
  = Can I use my own flags for the language switcher ? =
87
 
88
- Yes. You have to use PNG or JPG 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.
89
 
90
- = Polylang does not come with a lot flags. Where can I find other flags ? =
91
 
92
- There are many sources. I included some of the [famfamfam](http://www.famfamfam.com) flags which I renamed.
93
 
94
  == Changelog ==
95
 
96
- = 0.4.4 (2011-11-28) =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  * Bug correction: When using a static front page, the translated home page displays posts instead of the translated page
99
  * Bug correction: Automatic language setting of existing categories and post tags does not work correctly
@@ -103,7 +125,7 @@ There are many sources. I included some of the [famfamfam](http://www.famfamfam.
103
  * Add Russian translation contributed by [yoyurec](http://wordpress.org/support/profile/yoyurec)
104
  * Bug correction: Impossible to suppress the language name in the language switcher widget settings
105
  * Bug correction: Post's page does not work when using a static front page
106
- * Bug correction: Flags in local_flags directory are removed after an automatic upgrade (should now work for an upgrade from 0.4.3+ to a higher version)
107
  * Bug correction: Switching to default language displays a 404 Error when hiding the default language in url and displaying the language switcher as dropdown
108
  * Other minor bug corrections
109
  * Tests done with WordPress 3.3 beta 3
@@ -150,7 +172,7 @@ There are many sources. I included some of the [famfamfam](http://www.famfamfam.
150
 
151
  * Bug correction: the widget settings cannot be saved when activating Polylang
152
  * Bug correction: the archives widget does not display any links
153
- * Bug correction: ajax form for translations not working in the 'Categories' and 'Post tags' admin panels
154
 
155
  = 0.3 (2011-10-07) =
156
 
@@ -161,7 +183,7 @@ There are many sources. I included some of the [famfamfam](http://www.famfamfam.
161
 
162
  = 0.2 (2011-10-05) =
163
 
164
- * Add language filter for nav menus
165
  * Add German translation
166
  * Add language filter for recent comments
167
  * Add ajax to term edit form
1
  === Polylang ===
2
  Contributors: Chouby
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CCWWYUUQV8F4E
4
+ Tags: bilingual, language, i18n, international, l10n, localization, multilingual, multisite, translate, translation, widget
5
  Requires at least: 3.1
6
  Tested up to: 3.3
7
+ Stable tag: 0.5
8
 
9
  Polylang adds multilingual support to WordPress. You set a language for each post and it will be displayed only when browsing this language.
10
 
12
 
13
  You write posts, pages and create categories and post tags as usual, and then define the language for each of them. The translation is optional. A language switcher widget is provided with the plugin. The plugin does not integrate automatic or professional translation. You have to do the work yourself.
14
 
15
+ = Upgrade Notice =
16
+
17
+ Your custom flags in 'polylang/local_flags' directory will be removed when automatically upgrading from v0.4, v0.4.1, v0.4.2. So either do a manual upgrade or backup your custom flags. This problem is solved when upgrading from v0.4.3+ to a higher version. It's always safer to do a database backup before any upgrade.
18
+
19
  = Features =
20
 
21
  * You can create as many languages as you want
22
  * You can translate posts, pages, categories, post tags, menus
23
  * RSS feed available for each language
24
+ * Support for Search form (see the FAQ in the documentation)
25
  * Support for pretty permalinks
26
  * Support for static page (in the right language) used as front page
27
+ * All WordPress default widgets (archives, categories, pages, recent comments, recent posts, tag cloud and calendar) are automatically in the right language
28
+ * Language switcher provided as a widget or in the nav menu
29
  * All widgets can be displayed or not, depending on the language (new in 0.3)
30
  * Each user can set the WordPress admin language in its profile (new in 0.4)
31
  * Support for custom post types and custom taxonomies (new in 0.4)
32
+ * Support for multisite (new in 0.5)
33
 
34
  The plugin admin interface is currently available in:
35
 
38
  * German
39
  * Russian contributed by [yoyurec](http://yoyurec.in.ua)
40
 
41
+ Other translators are welcome !
42
 
43
  = Notes =
44
 
45
+ * The tests have been made with WordPress from version 3.1 up to 3.3 RC1. The plugin does not work with WordPress 3.0.5 and older.
46
  * Your server must run PHP5
 
47
  * You must deactivate other multilingual plugins before activating Polylang, otherwise, you may get unexpected results !
48
  * 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...).
49
 
53
 
54
  == Upgrade Notice ==
55
 
56
+ Your custom flags in 'polylang/local_flags' directory will be removed when automatically upgrading from v0.4, v0.4.1, v0.4.2. So either do a manual upgrade or backup your custom flags. This problem is solved when upgrading from v0.4.3+ to a higher version. It's always safer to do a database backup before any upgrade.
57
 
58
  == Installation ==
59
 
60
  1. Download the plugin
61
+ 1. Extract all the files.
62
  1. Upload everything (keeping the directory structure) to the `/wp-content/plugins/` directory.
63
  1. Activate the plugin through the 'Plugins' menu in WordPress.
64
  1. Add the 'language switcher' Widget to let your visitors switch the language.
65
  1. Go to the languages settings page and create the languages you need
66
+ 1. Upload corresponding .mo files in WordPress languages directory (no need for English). You can download them from [here](http://svn.automattic.com/wordpress-i18n/).
67
  1. Take care that your theme must come with the corresponding .mo file too. If your theme is not internationalized yet, please refer to the [codex](http://codex.wordpress.org/I18n_for_WordPress_Developers#I18n_for_theme_and_plugin_developers) or ask the theme author to internationalize it.
68
 
69
  == Frequently Asked Questions ==
76
 
77
  qtranslate: I tested the version 2.5.23. As claimed by its author, it's probably the best existing plugin... when using it. However, you must know that it is very difficult to come back to a clean site if you deactivate it (as, for example, one post in the database contains all translations). Moreover, it modifies urls so again, if you deactivate it, all links to your internal urls would be broken (not good for SEO).
78
 
79
+ In comparison to these plugins, Polylang tries to keep things simple and light, and does not mess your blog if you deactivate it. But it is still very young so be indulgent ;-)
80
 
81
  = Where to find help ? =
82
 
83
+ * Read the [documentation](http://plugins.svn.wordpress.org/polylang/trunk/doc/documentation-en.pdf) supplied whith the plugin (in the doc directory) and search the [support forum](http://wordpress.org/tags/polylang?forum_id=10) first. You will most probably find your answer here.
84
+ * If you still have a problem, open a new thread in the [support forum](http://wordpress.org/tags/polylang?forum_id=10).
 
85
 
86
+ = Is Polylang compatible with multisite ? =
87
 
88
+ Yes. Since v0.5
89
 
90
  = Can I use my own flags for the language switcher ? =
91
 
92
+ Yes. You have to use PNG or JPG 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 would be removed when updating the plugin.
93
 
94
+ == Screenshots ==
95
 
96
+ 1. The Polylang languages admin panel in WordPress 3.3
97
 
98
  == Changelog ==
99
 
100
+ = 0.5 (2011-12-07) =
101
+
102
+ * Add multisite support
103
+ * Rework the Polylang admin panel. There is now a set of predefined languages
104
+ * Improve categories and tags language filter in the edit post panel
105
+ * Categories and tags created in the edit post panel are now created with the same language as the post
106
+ * The language switcher can now force the link to the front page instead of the translated page
107
+ * The nav menus can now display a language switcher
108
+ * Improved performance
109
+ * Optimized the calendar widget (less code and sql queries executed)
110
+ * Added the possibility to display posts and terms with no language set (see the documentation to know how to enable this functionnality)
111
+ * Started the creation of a small API for theme and plugin programmers
112
+ * Bug correction: When using a static front page, the page for posts does not work when using the default permalink settings
113
+ * Bug correction: The search form does not work if a static front page is used
114
+ * Bug correction: Quick edit breaks translations
115
+ * Bug correction: Categories and post tags translations don't work for more than 2 languages
116
+ * Bug correction: The output of wp_page_menu is not correct for non default languages
117
+
118
+ = 0.4.4 (2011-11-28) =
119
 
120
  * Bug correction: When using a static front page, the translated home page displays posts instead of the translated page
121
  * Bug correction: Automatic language setting of existing categories and post tags does not work correctly
125
  * Add Russian translation contributed by [yoyurec](http://wordpress.org/support/profile/yoyurec)
126
  * Bug correction: Impossible to suppress the language name in the language switcher widget settings
127
  * Bug correction: Post's page does not work when using a static front page
128
+ * Bug correction: Flags in local_flags directory are removed after an automatic upgrade (now works for an upgrade from 0.4.3+ to a higher version)
129
  * Bug correction: Switching to default language displays a 404 Error when hiding the default language in url and displaying the language switcher as dropdown
130
  * Other minor bug corrections
131
  * Tests done with WordPress 3.3 beta 3
172
 
173
  * Bug correction: the widget settings cannot be saved when activating Polylang
174
  * Bug correction: the archives widget does not display any links
175
+ * Bug correction: ajax form for translations not working in the 'Categories' and 'Post tags' admin panels
176
 
177
  = 0.3 (2011-10-07) =
178
 
183
 
184
  = 0.2 (2011-10-05) =
185
 
186
+ * Add language filter for nav menus
187
  * Add German translation
188
  * Add language filter for recent comments
189
  * Add ajax to term edit form
screenshot-1.png ADDED
Binary file
uninstall.php CHANGED
@@ -1,39 +1,68 @@
1
  <?php
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
-
9
- foreach ($languages as $lang) {
10
- // delete references to this language in all posts
11
- $args = array('numberposts'=> -1, 'post_type'=>'any', 'post_status'=>'any');
12
- $posts = get_posts($args);
13
- foreach ($posts as $post) {
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);
21
- }
22
- // finally delete the language itself
23
- wp_delete_term($lang->term_id, 'language');
24
- }
25
 
26
- // delete the termmeta table only if it is empty as other plugins may use it
27
- $table = $wpdb->termmeta;
28
- $count = $wpdb->get_var("SELECT COUNT(*) FROM $table;");
29
- if (!$count) {
30
- $wpdb->query("DROP TABLE $table;");
31
- unset($wpdb->termmeta);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
- // delete options
35
- delete_option('polylang');
36
- delete_option('polylang_nav_menus');
37
- delete_option('polylang_widgets');
38
- delete_option('widget_polylang_widget'); // automatically created by WP
39
  ?>
1
  <?php
2
 
3
+ class Polylang_Uninstall {
4
+
5
+ function __construct() {
6
+ global $wpdb;
7
+
8
+ // check if it is a multisite uninstall - if so, run the uninstall function for each blog id
9
+ if (is_multisite()) {
10
+ foreach ($wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs")) as $blog_id) {
11
+ switch_to_blog($blog_id);
12
+ $this->uninstall();
13
+ }
14
+ restore_current_blog();
15
+ }
16
+ else
17
+ $this->uninstall();
18
  }
 
 
 
 
 
 
 
 
 
19
 
20
+ // removes ALL plugin data (languages, translation, and the termmeta table if empty
21
+ function uninstall() {
22
+ global $wpdb;
23
+ $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // registers the termmeta table in wpdb
24
+ register_taxonomy('language', get_post_types(array('show_ui' => true)), array('label' => false, 'query_var'=>'lang')); // need to register the language taxonomy
25
+
26
+ $languages = get_terms('language', array('hide_empty'=>false));
27
+
28
+ $ids = get_posts(array('numberposts'=> -1, 'fields' => 'ids', 'post_type'=>'any', 'post_status'=>'any'));
29
+ foreach ($ids as $id) {
30
+ foreach ($languages as $lang)
31
+ delete_post_meta($id, '_lang-'.$lang->slug); //FIXME before 0.5
32
+
33
+ delete_post_meta($id, '_translations'); // V0.5+
34
+ }
35
+
36
+ $ids = get_terms(get_taxonomies(array('show_ui'=>true)), array('get'=>'all', 'fields'=>'ids'));
37
+ foreach ($ids as $id) {
38
+ foreach ($languages as $lang)
39
+ delete_metadata('term', $id, '_lang-'.$lang->slug); //FIXME before 0.5
40
+
41
+ delete_metadata('term', $id, '_translations'); // V0.5+
42
+ delete_metadata('term', $id, '_language');
43
+ }
44
+
45
+ // finally delete languages
46
+ foreach ($languages as $lang)
47
+ wp_delete_term($lang->term_id, 'language');
48
+
49
+ // delete the termmeta table only if it is empty as other plugins may use it
50
+ $table = $wpdb->termmeta;
51
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $table;");
52
+ if (!$count) {
53
+ $wpdb->query("DROP TABLE $table;");
54
+ unset($wpdb->termmeta);
55
+ }
56
+
57
+ // delete options
58
+ delete_option('polylang');
59
+ delete_option('polylang_nav_menus');
60
+ delete_option('polylang_widgets');
61
+ delete_option('polylang_widget'); // automatically created by WP
62
+ }
63
  }
64
 
65
+ if (class_exists("Polylang_Uninstall"))
66
+ new Polylang_Uninstall();
67
+
 
 
68
  ?>