PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.2.7
Yatra – Travel Booking & Tour Operator Software v3.0.2.7
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 2.0.1 All 84 releases
yatra / resources / js / lib / i18n.ts

i18n.ts in Yatra – Travel Booking & Tour Operator Software 3.0.2.7, at resources/js/lib/i18n.ts

142 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Internationalization (i18n) utility
3 * Handles translations for UI text
4 */
5
6 declare global {
7 interface Window {
8 yatraAdmin?: {
9 apiUrl?: string;
10 nonce?: string;
11 brandLogoUrl?: string;
12 pluginUrl?: string;
13 currentUserAvatar?: string;
14 currentUser?: number;
15 siteUrl?: string;
16 permissions?: string[];
17 roles?: string[];
18 capabilities?: Record<string, boolean>;
19 isPro?: boolean;
20 isProActive?: boolean;
21 version?: string;
22 proVersion?: string | null;
23 translations?: Record<string, string>;
24 locale?: string;
25 emailAutomationEnabled?: boolean;
26 tripConsentEnabled?: boolean;
27 additionalServicesEnabled?: boolean;
28 abandonedBookingRecoveryEnabled?: boolean;
29 dynamicPricingEnabled?: boolean;
30 dynamicFormFieldEnabled?: boolean;
31 advancedDiscountEnabled?: boolean;
32 showGoogleCalendarSettingsUI?: boolean;
33 showMailchimpSettingsUI?: boolean;
34 showFacebookPixelSettingsUI?: boolean;
35 showGoogleAnalyticsSettingsUI?: boolean;
36 flexiblePaymentsEnabled?: boolean;
37 currency?: string;
38 date_format?: string;
39 time_format?: string;
40 calendar_name?: string;
41 connected?: boolean;
42 redirect_uri?: string;
43 last_sync?: string | null;
44 googleCalendarRedirectUri?: string;
45 mailchimp?: {
46 connected?: boolean;
47 listId?: string;
48 listName?: string;
49 syncOnBooking?: boolean;
50 syncOnPayment?: boolean;
51 addTags?: boolean;
52 defaultTags?: string[];
53 doubleOptin?: boolean;
54 fieldMapping?: Record<string, string>;
55 };
56 facebookPixel?: {
57 connected?: boolean;
58 pixelId?: string;
59 trackViewContent?: boolean;
60 trackInitiateCheckout?: boolean;
61 trackPurchase?: boolean;
62 useConversionsApi?: boolean;
63 testEventCode?: string;
64 eventConfig?: Record<
65 string,
66 { enabled: boolean; custom_params?: string[] }
67 >;
68 parameterMapping?: Record<string, string>;
69 };
70 googleAnalytics?: {
71 connected?: boolean;
72 measurementId?: string;
73 trackViewItem?: boolean;
74 trackBeginCheckout?: boolean;
75 trackPurchase?: boolean;
76 useMeasurementProtocol?: boolean;
77 debugMode?: boolean;
78 customDimensions?: Array<{
79 name: string;
80 yatra_field: string;
81 scope?: string;
82 }>;
83 eventConfig?: Record<
84 string,
85 { enabled: boolean; custom_params?: string[] }
86 >;
87 };
88 googleCalendar?: {
89 client_id?: string;
90 client_secret?: string;
91 calendar_id?: string;
92 calendar_name?: string;
93 connected?: boolean;
94 redirect_uri?: string;
95 last_sync?: string | null;
96 };
97 };
98 }
99 }
100
101 /**
102 * Internationalization (i18n) utility
103 * Handles translations for UI text
104 */
105
106 import { __ as wpI18n__, _x as wpI18n_x } from "@wordpress/i18n";
107
108 function __(key: string): string;
109 function __(key: string, textDomain: string): string;
110 function __(key: string, textDomain?: string): string {
111 // Use direct WordPress i18n function which is working correctly
112 if (typeof window !== "undefined" && (window as any).wp?.i18n?.__) {
113 return (window as any).wp.i18n.__(key, textDomain || "yatra");
114 }
115 // Fallback to @wordpress/i18n
116 return wpI18n__(key, textDomain || "yatra");
117 }
118
119 function _x(key: string, context: string): string;
120 function _x(key: string, context: string, textDomain: string): string;
121 function _x(key: string, context: string, textDomain?: string): string {
122 // Use direct WordPress i18n function which is working correctly
123 if (typeof window !== "undefined" && (window as any).wp?.i18n?._x) {
124 return (window as any).wp.i18n._x(key, context, textDomain || "yatra");
125 }
126 // Fallback to @wordpress/i18n
127 return wpI18n_x(key, context, textDomain || "yatra");
128 }
129
130 export { __, _x };
131
132 /**
133 * Get translated string with number
134 * @param single - Single form
135 * @param plural - Plural form
136 * @param number - Number to determine form
137 * @returns Translated string
138 */
139 export const _n = (single: string, plural: string, number: number): string => {
140 return number === 1 ? __(single) : __(plural);
141 };
142