PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.17
Yatra – Travel Booking & Tour Operator Software v3.0.17
3.0.17 3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 All 85 releases
← All changes | assets/js/downloads-list.js +27 -11 3.0.3 → 3.0.17 View file →
@@ -2,8 +2,24 @@
2 2 * Downloads List JavaScript
3 3 * Handles download functionality for the list view with visibility checks
4 4 */
5 5
6 +// Translation helpers — idempotent shim matching the other frontend bundles.
7 +(function () {
8 + if (typeof window.__ === 'function') return;
9 + if (window.wp && window.wp.i18n && typeof window.wp.i18n.__ === 'function') {
10 + window.__ = function (text, domain) { return window.wp.i18n.__(text, domain || 'yatra'); };
11 + window._n = function (s, p, n, domain) { return window.wp.i18n._n(s, p, n, domain || 'yatra'); };
12 + window._x = function (text, ctx, domain) { return window.wp.i18n._x(text, ctx, domain || 'yatra'); };
13 + window.sprintf = window.sprintf || (window.wp.i18n.sprintf || function (fmt) { return fmt; });
14 + } else {
15 + window.__ = function (text) { return text; };
16 + window._n = function (s, p, n) { return n === 1 ? s : p; };
17 + window._x = function (text) { return text; };
18 + window.sprintf = window.sprintf || function (fmt) { return fmt; };
19 + }
20 +})();
21 +
6 22 document.addEventListener('DOMContentLoaded', function() {
7 23 // Use centralized API helper
8 24 if (typeof window.YatraApiHelper === 'undefined') {
9 25 console.error('YatraApiHelper not loaded');
@@ -26,9 +42,9 @@
26 42 }
27 43
28 44 // Show loading state
29 45 const originalContent = this.innerHTML;
30 - this.innerHTML = '<span class="yatra-download-spinner"></span> Getting download...';
46 + this.innerHTML = '<span class="yatra-download-spinner"></span> ' + __('Getting download...', 'yatra');
31 47 this.disabled = true;
32 48
33 49 // For booked_only downloads, we need to get booking ID
34 50 // In a real implementation, you'd get this from user's bookings
@@ -41,9 +57,9 @@
41 57 window.YatraApiHelper.getDownloadUrl(downloadId)
42 58 .then(response => {
43 59 if (!response.ok) {
44 60 return response.json().then(err => {
45 - throw new Error(err.message || 'Download failed');
61 + throw new Error(err.message || __('Download failed', 'yatra'));
46 62 });
47 63 }
48 64 return response.json();
49 65 })
@@ -57,9 +73,9 @@
57 73 document.body.appendChild(link);
58 74 link.click();
59 75 document.body.removeChild(link);
60 76 } else {
61 - throw new Error('No download URL provided');
77 + throw new Error(__('No download URL provided', 'yatra'));
62 78 }
63 79 })
64 80 .catch(error => {
65 81 console.error('Download error:', error);
@@ -64,15 +80,15 @@
64 80 .catch(error => {
65 81 console.error('Download error:', error);
66 82
67 83 // Show user-friendly error message
68 - let errorMessage = 'Download failed. Please try again.';
84 + let errorMessage = __('Download failed. Please try again.', 'yatra');
69 85 if (error.message.includes('booking')) {
70 - errorMessage = 'This download requires a booking. Please book this trip first.';
86 + errorMessage = __('This download requires a booking. Please book this trip first.', 'yatra');
71 87 } else if (error.message.includes('login')) {
72 - errorMessage = 'Please log in to download this file.';
88 + errorMessage = __('Please log in to download this file.', 'yatra');
73 89 } else if (error.message.includes('permission')) {
74 - errorMessage = 'You do not have permission to download this file.';
90 + errorMessage = __('You do not have permission to download this file.', 'yatra');
75 91 }
76 92
77 93 alert(errorMessage);
78 94 })
@@ -91,14 +107,14 @@
91 107 button.addEventListener('click', function(e) {
92 108 e.preventDefault();
93 109
94 110 const visibility = this.getAttribute('data-visibility');
95 - let message = 'Download not available.';
96 -
111 + let message = __('Download not available.', 'yatra');
112 +
97 113 if (visibility === 'logged_in') {
98 - message = 'Please log in to download this file.';
114 + message = __('Please log in to download this file.', 'yatra');
99 115 } else if (visibility === 'booked_only') {
100 - message = 'This download requires a booking for this trip.';
116 + message = __('This download requires a booking for this trip.', 'yatra');
101 117 }
102 118
103 119 alert(message);
104 120 });