@djangocfg/i18n 2.1.591 → 2.1.592

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,697 +1,5 @@
1
- import * as React from 'react';
2
- import { jsx } from 'react/jsx-runtime';
3
-
4
- // src/context.tsx
5
-
6
- // src/locales/en.ts
7
- var en = {
8
- ui: {
9
- select: {
10
- placeholder: "Select option...",
11
- search: "Search...",
12
- noResults: "No results found.",
13
- selectAll: "Select all",
14
- clearAll: "Clear all",
15
- moreItems: "+{count} more",
16
- loading: "Loading..."
17
- },
18
- pagination: {
19
- previous: "Previous",
20
- next: "Next",
21
- first: "First",
22
- last: "Last",
23
- page: "Page {page}",
24
- of: "of {total}",
25
- showing: "{from}-{to} of {total}"
26
- },
27
- dialog: {
28
- close: "Close",
29
- confirm: "Confirm",
30
- cancel: "Cancel",
31
- ok: "OK",
32
- yes: "Yes",
33
- no: "No",
34
- delete: "Delete",
35
- save: "Save",
36
- discard: "Discard",
37
- alertTitle: "Notice",
38
- confirmTitle: "Confirm",
39
- confirmDelete: "Are you sure you want to delete this?",
40
- promptTitle: "Input Required",
41
- promptPlaceholder: "Enter value..."
42
- },
43
- form: {
44
- submit: "Submit",
45
- cancel: "Cancel",
46
- save: "Save",
47
- delete: "Delete",
48
- edit: "Edit",
49
- create: "Create",
50
- update: "Update",
51
- reset: "Reset",
52
- clear: "Clear",
53
- loading: "Loading...",
54
- saving: "Saving...",
55
- deleting: "Deleting...",
56
- required: "This field is required",
57
- optional: "Optional",
58
- minLength: "{min} characters minimum",
59
- maxLength: "{max} characters maximum",
60
- invalidEmail: "Please enter a valid email address",
61
- invalidUrl: "Please enter a valid URL",
62
- invalidPhone: "Please enter a valid phone number",
63
- passwordMismatch: "Passwords do not match"
64
- },
65
- datetime: {
66
- today: "Today",
67
- yesterday: "Yesterday",
68
- tomorrow: "Tomorrow",
69
- now: "Just now",
70
- secondsAgo: "{count} seconds ago",
71
- minutesAgo: "{count} minutes ago",
72
- hoursAgo: "{count} hours ago",
73
- daysAgo: "{count} days ago",
74
- pickDate: "Pick a date",
75
- pickTime: "Pick a time",
76
- pickDateTime: "Pick date and time",
77
- pickDateRange: "Pick a date range"
78
- },
79
- file: {
80
- upload: "Upload",
81
- uploading: "Uploading...",
82
- dragDrop: "Drag and drop files here",
83
- browse: "Browse files",
84
- remove: "Remove",
85
- maxSize: "Max size: {size}",
86
- invalidType: "Invalid file type",
87
- tooLarge: "File is too large"
88
- },
89
- table: {
90
- noData: "No data available",
91
- loading: "Loading data...",
92
- showing: "Showing {from}-{to} of {total}",
93
- rowsPerPage: "Rows per page",
94
- sortAsc: "Sort ascending",
95
- sortDesc: "Sort descending",
96
- filter: "Filter",
97
- clearFilters: "Clear filters",
98
- selectAll: "Select all",
99
- deselectAll: "Deselect all",
100
- selected: "{count} selected"
101
- },
102
- actions: {
103
- view: "View",
104
- copy: "Copy",
105
- copied: "Copied!",
106
- copyToClipboard: "Copy to clipboard",
107
- download: "Download",
108
- share: "Share",
109
- refresh: "Refresh",
110
- retry: "Retry",
111
- expand: "Expand",
112
- collapse: "Collapse",
113
- showMore: "Show more",
114
- showLess: "Show less",
115
- seeAll: "See all",
116
- goBack: "Go back",
117
- remove: "Remove",
118
- previousSlide: "Previous slide",
119
- nextSlide: "Next slide"
120
- },
121
- phone: {
122
- searchCountries: "Search countries...",
123
- noCountries: "No countries found"
124
- },
125
- navigation: {
126
- title: "Navigation"
127
- },
128
- states: {
129
- loading: "Loading",
130
- empty: "Empty",
131
- error: "Error",
132
- success: "Success",
133
- warning: "Warning",
134
- info: "Info",
135
- pending: "Pending",
136
- active: "Active",
137
- inactive: "Inactive",
138
- enabled: "Enabled",
139
- disabled: "Disabled"
140
- },
141
- errors: {
142
- generic: "Something went wrong",
143
- network: "Network error. Please check your connection.",
144
- timeout: "Request timed out. Please try again.",
145
- notFound: "Not found",
146
- unauthorized: "Please sign in to continue",
147
- forbidden: "You do not have permission to access this",
148
- serverError: "Server error. Please try again later.",
149
- validation: "Please check the form for errors",
150
- unknown: "An unknown error occurred"
151
- }
152
- },
153
- layouts: {
154
- sidebar: {
155
- toggle: "Toggle sidebar",
156
- collapse: "Collapse sidebar",
157
- expand: "Expand sidebar"
158
- },
159
- navigation: {
160
- menu: "Menu",
161
- home: "Home",
162
- back: "Back",
163
- forward: "Forward",
164
- toggleMobile: "Toggle mobile menu",
165
- breadcrumb: "Breadcrumb"
166
- },
167
- profile: {
168
- settings: "Settings",
169
- account: "Account",
170
- logout: "Log out",
171
- login: "Log in",
172
- signUp: "Sign up",
173
- signOut: "Sign Out",
174
- userMenu: "User menu",
175
- language: "Language"
176
- },
177
- theme: {
178
- toggle: "Toggle theme",
179
- light: "Light",
180
- dark: "Dark",
181
- system: "System"
182
- },
183
- search: {
184
- placeholder: "Search...",
185
- noResults: "No results found",
186
- recentSearches: "Recent searches",
187
- clearHistory: "Clear history"
188
- },
189
- mobile: {
190
- closeMenu: "Close menu"
191
- },
192
- errors: {
193
- somethingWentWrong: "Something went wrong",
194
- tryRefreshing: "We're sorry, but something unexpected happened. Please try refreshing the page.",
195
- refreshPage: "Refresh Page",
196
- goBack: "Go Back",
197
- goHome: "Go Home",
198
- needHelp: "Need help?",
199
- contactSupport: "Contact support",
200
- checkStatus: "Check service status",
201
- persistsContact: "If the problem persists, please contact {email}",
202
- error: "Error",
203
- badRequest: "Bad Request",
204
- authRequired: "Authentication Required",
205
- accessDenied: "Access Denied",
206
- pageNotFound: "Page Not Found",
207
- requestTimeout: "Request Timeout",
208
- serverError: "Server Error",
209
- badGateway: "Bad Gateway",
210
- serviceUnavailable: "Service Unavailable",
211
- gatewayTimeout: "Gateway Timeout",
212
- badRequestDesc: "The request could not be understood. Please check your input and try again.",
213
- authRequiredDesc: "You need to sign in to access this page.",
214
- accessDeniedDesc: "You don't have permission to access this resource.",
215
- pageNotFoundDesc: "The page you're looking for doesn't exist or has been moved.",
216
- requestTimeoutDesc: "The request took too long to process. Please try again.",
217
- serverErrorDesc: "Something went wrong on our end. We're working to fix it.",
218
- badGatewayDesc: "The server received an invalid response. Please try again later.",
219
- serviceUnavailableDesc: "The service is temporarily unavailable. Please try again later.",
220
- gatewayTimeoutDesc: "The server took too long to respond. Please try again.",
221
- unknownErrorDesc: "An unexpected error occurred. Please try again or contact support."
222
- },
223
- push: {
224
- enableNotifications: "Enable notifications",
225
- stayUpdated: "Stay updated with important updates and alerts",
226
- enable: "Enable",
227
- notNow: "Not now",
228
- dismiss: "Dismiss"
229
- },
230
- auth: {
231
- authRequired: "Authentication Required",
232
- pleaseSignIn: "Please sign in to continue",
233
- goToSignIn: "Go to Sign In",
234
- identifier: {
235
- title: "Sign in",
236
- subtitle: {
237
- email: "Enter your email to continue",
238
- phone: "Enter your phone number to continue"
239
- },
240
- placeholder: {
241
- email: "email@example.com",
242
- phone: "Enter your phone number"
243
- },
244
- button: "Continue",
245
- oauth: {
246
- github: "Continue with GitHub"
247
- },
248
- channel: {
249
- email: "Email",
250
- phone: "Phone"
251
- }
252
- },
253
- otp: {
254
- title: "Enter code",
255
- subtitle: "We sent a code to",
256
- button: "Verify",
257
- resend: "Resend code",
258
- changeEmail: "Change email",
259
- changePhone: "Change phone",
260
- openMailbox: "Open {provider}"
261
- },
262
- twoFactor: {
263
- title: "Two-factor authentication",
264
- subtitle: {
265
- totp: "Enter the 6-digit code from your authenticator",
266
- backup: "Enter one of your backup codes"
267
- },
268
- placeholder: {
269
- backup: "XXXXXXXX"
270
- },
271
- button: "Verify",
272
- toggle: {
273
- toBackup: "Use backup code",
274
- toTotp: "Use authenticator app"
275
- }
276
- },
277
- setup: {
278
- loading: {
279
- title: "Setting up...",
280
- button: "Loading"
281
- },
282
- qrCode: {
283
- title: "Set up 2FA",
284
- subtitle: "Scan this QR code with your authenticator app",
285
- manualEntry: "Can't scan? Enter manually",
286
- confirmPrompt: "Enter the 6-digit code to confirm",
287
- button: "Enable 2FA",
288
- skip: "Skip for now"
289
- },
290
- complete: {
291
- title: "2FA enabled",
292
- subtitle: "Save these backup codes securely",
293
- instruction: "Each code can only be used once",
294
- copyAll: "Copy all codes",
295
- copied: "Copied",
296
- done: "Done"
297
- }
298
- },
299
- success: {
300
- message: "Signed in successfully",
301
- redirecting: "Taking you in\u2026"
302
- },
303
- divider: {
304
- or: "or"
305
- },
306
- footer: {
307
- terms: "Terms",
308
- privacy: "Privacy",
309
- support: "Support"
310
- },
311
- dev: {
312
- anyCodeWorks: "Dev Mode: Any code works"
313
- }
314
- },
315
- pwa: {
316
- addToHomeScreen: "Add to Home Screen",
317
- installApp: "Install App",
318
- tapToLearnHow: "Tap to learn how",
319
- clickToSeeGuide: "Click to see desktop guide",
320
- tapToInstall: "Tap to install",
321
- installing: "Installing...",
322
- dismiss: "Dismiss",
323
- appLogo: "App logo",
324
- iosTitle: "Add to Home Screen",
325
- iosDescription: "Install this app on your iPhone for quick access and a better experience",
326
- iosStep1Title: "Tap Share",
327
- iosStep1Desc: "At the bottom of Safari",
328
- iosStep2Title: "Scroll & Tap",
329
- iosStep2Desc: '"Add to Home Screen"',
330
- iosStep3Title: "Confirm",
331
- iosStep3Desc: 'Tap "Add" in top-right',
332
- gotIt: "Got It",
333
- desktopTitle: "Install App on Desktop",
334
- desktopDescription: "Install this app on {browser} for quick access from your desktop",
335
- desktopDescSafari: "Safari on macOS has limited PWA support. For the best experience, use Chrome, Edge, or Brave.",
336
- desktopTip: 'You can also right-click the page and look for "Install" option in {browser}',
337
- desktopFirefoxNote: "Firefox has limited PWA support. Some features may not work as expected.",
338
- chromiumStep1Title: "Find Install Icon",
339
- chromiumStep1Desc: "Look for install icon in address bar (right side)",
340
- chromiumStep2Title: "Click Install",
341
- chromiumStep2Desc: 'Click the icon and select "Install"',
342
- chromiumStep3Title: "Confirm",
343
- chromiumStep3Desc: 'Click "Install" in the popup dialog',
344
- firefoxStep1Title: "Open Menu",
345
- firefoxStep1Desc: "Click the menu button (three lines)",
346
- firefoxStep2Title: "Find Install Option",
347
- firefoxStep2Desc: 'Look for "Install" or "Add to Home Screen"',
348
- firefoxStep3Title: "Confirm",
349
- firefoxStep3Desc: "Follow the installation prompts",
350
- safariStep1Title: "Limited Support",
351
- safariStep1Desc: "Safari on macOS has limited PWA support",
352
- safariStep2Title: "Use Chromium Browser",
353
- safariStep2Desc: "Consider using Chrome, Edge, or Brave for full PWA experience",
354
- unknownStep1Title: "Check Address Bar",
355
- unknownStep1Desc: "Look for an install or download icon",
356
- unknownStep2Title: "Or Use Menu",
357
- unknownStep2Desc: "Check browser menu for install option",
358
- unknownStep3Title: "Confirm",
359
- unknownStep3Desc: "Follow the installation prompts",
360
- close: "Close"
361
- },
362
- profilePage: {
363
- title: "Profile",
364
- account: "Account",
365
- personalInfo: "Personal Information",
366
- work: "Work",
367
- security: "Security",
368
- actions: "Actions",
369
- email: "Email",
370
- firstName: "First Name",
371
- lastName: "Last Name",
372
- company: "Company",
373
- position: "Position",
374
- phone: "Phone",
375
- notSet: "Not set",
376
- addFirstName: "Add first name",
377
- addLastName: "Add last name",
378
- addPhone: "Add phone number",
379
- addCompany: "Add company",
380
- addPosition: "Add position",
381
- on: "On",
382
- off: "Off",
383
- save: "Save",
384
- saving: "Saving...",
385
- cancel: "Cancel",
386
- signOut: "Sign Out",
387
- deleteAccount: "Delete Account",
388
- deleting: "Deleting...",
389
- twoFactorAuth: "Two-Factor Authentication",
390
- twoFactorEnabled: "Two-factor authentication is enabled",
391
- twoFactorDisabled: "Add an extra layer of security",
392
- enable2FA: "Enable",
393
- avatar: "Avatar",
394
- changeAvatar: "Change avatar",
395
- memberSince: "Member since {date}",
396
- enterField: "Enter {field}",
397
- profileUpdated: "Profile updated",
398
- avatarUpdated: "Avatar updated",
399
- failedToUpdate: "Failed to update",
400
- failedToUploadAvatar: "Failed to upload avatar",
401
- selectImageFile: "Please select an image file",
402
- fileTooLarge: "File size must be less than 5MB",
403
- notAuthenticated: "Not Authenticated",
404
- pleaseLogIn: "Please log in to view your profile.",
405
- deleteAccountTitle: "Delete Account",
406
- deleteAccountDesc: "This action cannot be undone. Your account will be permanently deleted.",
407
- typeToConfirm: "Type {word} to confirm:",
408
- confirmationWord: "DELETE"
409
- }
410
- },
411
- api: {
412
- errors: {
413
- networkError: "Network error",
414
- connectionFailed: "Connection failed",
415
- requestTimeout: "Request timed out",
416
- serverUnavailable: "Server is unavailable",
417
- invalidResponse: "Invalid response from server",
418
- rateLimited: "Too many requests. Please wait."
419
- },
420
- status: {
421
- connecting: "Connecting...",
422
- connected: "Connected",
423
- disconnected: "Disconnected",
424
- reconnecting: "Reconnecting..."
425
- },
426
- logout: {
427
- title: "Logout",
428
- message: "Are you sure you want to logout?",
429
- confirm: "Logout",
430
- cancel: "Cancel"
431
- }
432
- },
433
- tools: {
434
- code: {
435
- copyCode: "Copy code",
436
- noContent: "No content available"
437
- },
438
- diagram: {
439
- title: "Diagram",
440
- clickToView: "Click to view fullscreen"
441
- },
442
- image: {
443
- noImage: "No image content",
444
- failedToLoad: "Failed to load image",
445
- zoomIn: "Zoom in",
446
- zoomOut: "Zoom out",
447
- fitToView: "Fit to view",
448
- flipHorizontal: "Flip horizontal",
449
- flipVertical: "Flip vertical",
450
- rotate: "Rotate 90\xB0",
451
- fullscreen: "Open in fullscreen"
452
- },
453
- gallery: {
454
- noImages: "No images available",
455
- lightbox: "Image lightbox",
456
- previous: "Previous image",
457
- next: "Next image",
458
- close: "Close lightbox",
459
- download: "Download image",
460
- share: "Share image"
461
- },
462
- video: {
463
- play: "Play video",
464
- fullscreen: "Fullscreen",
465
- unavailable: "Video unavailable"
466
- },
467
- audio: {
468
- restart: "Restart",
469
- back: "Back 5 seconds",
470
- forward: "Forward 5 seconds",
471
- volume: "Volume"
472
- },
473
- color: {
474
- pick: "Pick color"
475
- },
476
- jsonForm: {
477
- validationErrors: "Validation Errors",
478
- addItem: "Add Item",
479
- addFirstItem: "Add First Item",
480
- noItems: "No items added yet."
481
- },
482
- openapi: {
483
- response: "Response",
484
- noResponse: "No response body available",
485
- required: "Required",
486
- optional: "Optional",
487
- searchEndpoints: "Search endpoints...",
488
- all: "All",
489
- methods: "Methods",
490
- path: "Path",
491
- description: "Description",
492
- navigation: "Navigation",
493
- previous: "Previous",
494
- next: "Next",
495
- bearerToken: "Enter Bearer token (optional, uses JWT if empty)"
496
- },
497
- form: {
498
- title: "Form"
499
- },
500
- tour: {
501
- next: "Next",
502
- previous: "Back",
503
- skip: "Skip",
504
- finish: "Finish",
505
- close: "Close",
506
- stepOf: "Step {current} of {total}"
507
- },
508
- upload: {
509
- dragDrop: "Drag & drop files or click to browse",
510
- dropHere: "Drop files here",
511
- maxSize: "Max {size}MB per file",
512
- uploading: "Uploading...",
513
- uploaded: "Uploaded",
514
- failed: "Failed",
515
- retry: "Retry",
516
- remove: "Remove",
517
- cancel: "Cancel",
518
- paused: "Paused",
519
- pending: "Pending"
520
- }
521
- }
522
- };
523
-
524
- // src/utils/interpolate.ts
525
- function interpolate(template, params) {
526
- if (!params) return template;
527
- return template.replace(/\{(\w+)\}/g, (match, key) => {
528
- if (key in params) {
529
- return String(params[key]);
530
- }
531
- return match;
532
- });
533
- }
534
-
535
- // src/utils/merge.ts
536
- function deepMerge(target, source) {
537
- const result = { ...target };
538
- for (const key in source) {
539
- if (Object.prototype.hasOwnProperty.call(source, key)) {
540
- const sourceValue = source[key];
541
- const targetValue = result[key];
542
- if (sourceValue !== null && typeof sourceValue === "object" && !Array.isArray(sourceValue) && targetValue !== null && typeof targetValue === "object" && !Array.isArray(targetValue)) {
543
- result[key] = deepMerge(
544
- targetValue,
545
- sourceValue
546
- );
547
- } else if (sourceValue !== void 0) {
548
- result[key] = sourceValue;
549
- }
550
- }
551
- }
552
- return result;
553
- }
554
- function mergeTranslations(base, overrides) {
555
- return deepMerge(
556
- base,
557
- overrides
558
- );
559
- }
560
- function createTranslations(base, ...overrides) {
561
- return overrides.reduce(
562
- (acc, override) => mergeTranslations(acc, override),
563
- base
564
- );
565
- }
566
-
567
- // src/utils/get-value.ts
568
- function getNestedValue(obj, path) {
569
- const keys = path.split(".");
570
- let current = obj;
571
- for (const key of keys) {
572
- if (current === null || current === void 0) {
573
- return void 0;
574
- }
575
- if (typeof current !== "object") {
576
- return void 0;
577
- }
578
- current = current[key];
579
- }
580
- if (typeof current === "string") {
581
- return current;
582
- }
583
- return void 0;
584
- }
585
- var I18nContext = React.createContext(null);
586
- var defaultTranslations = en;
587
- function I18nProvider({
588
- children,
589
- locale: initialLocale = "en",
590
- translations: initialTranslations,
591
- allTranslations,
592
- onLocaleChange
593
- }) {
594
- const [locale, setLocaleState] = React.useState(initialLocale);
595
- const translations = React.useMemo(() => {
596
- if (allTranslations && allTranslations[locale]) {
597
- const localeTranslations = allTranslations[locale];
598
- return mergeTranslations(defaultTranslations, localeTranslations);
599
- }
600
- if (initialTranslations) {
601
- return mergeTranslations(
602
- defaultTranslations,
603
- initialTranslations
604
- );
605
- }
606
- return defaultTranslations;
607
- }, [locale, allTranslations, initialTranslations]);
608
- const t = React.useCallback(
609
- (key, params) => {
610
- const value2 = getNestedValue(
611
- translations,
612
- key
613
- );
614
- if (value2 === void 0) {
615
- if (typeof window !== "undefined" && window.location.hostname === "localhost") {
616
- console.warn(`[i18n] Missing translation key: "${key}"`);
617
- }
618
- return key;
619
- }
620
- return interpolate(value2, params);
621
- },
622
- [translations]
623
- );
624
- const setLocale = React.useCallback(
625
- (newLocale) => {
626
- setLocaleState(newLocale);
627
- onLocaleChange?.(newLocale);
628
- },
629
- [onLocaleChange]
630
- );
631
- React.useEffect(() => {
632
- setLocaleState((current) => current === initialLocale ? current : initialLocale);
633
- }, [initialLocale]);
634
- const value = React.useMemo(
635
- () => ({
636
- locale,
637
- translations,
638
- t,
639
- setLocale
640
- }),
641
- [locale, translations, t, setLocale]
642
- );
643
- return /* @__PURE__ */ jsx(I18nContext.Provider, { value, children });
644
- }
645
- function useI18n() {
646
- const context = React.useContext(I18nContext);
647
- if (!context) {
648
- return {
649
- locale: "en",
650
- translations: defaultTranslations,
651
- t: (key, params) => {
652
- const value = getNestedValue(
653
- defaultTranslations,
654
- key
655
- );
656
- if (value === void 0) return key;
657
- return interpolate(value, params);
658
- },
659
- setLocale: () => {
660
- if (typeof window !== "undefined" && window.location.hostname === "localhost") {
661
- console.warn(
662
- "[i18n] setLocale called but no I18nProvider found. Wrap your app with I18nProvider to enable locale switching."
663
- );
664
- }
665
- }
666
- };
667
- }
668
- return context;
669
- }
670
- function useTranslation() {
671
- const { t } = useI18n();
672
- return t;
673
- }
674
- function useLocale() {
675
- const { locale } = useI18n();
676
- return locale;
677
- }
678
- function useLocaleOptional() {
679
- const context = React.useContext(I18nContext);
680
- return context?.locale ?? null;
681
- }
682
- var useT = useTranslation;
683
- function useTypedT() {
684
- const { t } = useI18n();
685
- return t;
686
- }
687
- function getT(key, params) {
688
- const value = getNestedValue(
689
- defaultTranslations,
690
- key
691
- );
692
- if (value === void 0) return key;
693
- return interpolate(value, params);
694
- }
1
+ import { useTypedT } from './chunk-G6X7PO3Q.mjs';
2
+ export { I18nProvider, createTranslations, en, getT, interpolate, mergeTranslations, useI18n, useLocale, useLocaleOptional, useT, useTranslation, useTypedT } from './chunk-G6X7PO3Q.mjs';
695
3
 
696
4
  // src/locales/ru.ts
697
5
  var ru = {
@@ -1732,6 +1040,6 @@ var ko = {
1732
1040
  // src/index.ts
1733
1041
  var useAppT = () => useTypedT();
1734
1042
 
1735
- export { I18nProvider, createTranslations, en, getT, interpolate, ko, mergeTranslations, ru, useAppT, useI18n, useLocale, useLocaleOptional, useT, useTranslation, useTypedT };
1043
+ export { ko, ru, useAppT };
1736
1044
  //# sourceMappingURL=index.mjs.map
1737
1045
  //# sourceMappingURL=index.mjs.map