@seip/bluebird-js 0.1.7 → 0.2.1
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/AGENTS.md +727 -620
- package/README.md +670 -607
- package/app/models/user.js +19 -0
- package/app/resources/html/home.html +137 -0
- package/app/resources/html/layouts/main.html +55 -0
- package/app/resources/html/notFound.html +14 -0
- package/app/resources/html/table.html +15 -0
- package/app/resources/html/terms.html +46 -0
- package/app/resources/index.html +27 -0
- package/app/resources/layouts/AppLayout.jsx +92 -0
- package/app/resources/main.jsx +18 -0
- package/app/resources/pages/Dashboard.jsx +93 -0
- package/app/resources/pages/Home.jsx +140 -0
- package/app/resources/pages/Login.jsx +35 -0
- package/app/resources/pages/NotFound.jsx +16 -0
- package/app/resources/pages/Register.jsx +55 -0
- package/app/resources/pages/TableDemo.jsx +85 -0
- package/app/resources/routes.jsx +59 -0
- package/app/resources/spa.js +73 -0
- package/app/resources/styles.css +9 -0
- package/app/routes/api.js +129 -50
- package/app/routes/auth.js +209 -0
- package/app/routes/web.js +89 -47
- package/core/ai.js +30 -10
- package/core/app.d.ts +2 -18
- package/core/app.js +987 -801
- package/core/auth.d.ts +2 -13
- package/core/auth.js +444 -326
- package/core/cli/build.js +37 -0
- package/core/cli/dev.js +155 -0
- package/core/cli/doctor.js +37 -2
- package/core/cli/export.js +191 -0
- package/core/cli/init.js +91 -322
- package/core/cli/nginx.js +1 -1
- package/core/cli/templates.js +139 -0
- package/core/cli/view.js +98 -161
- package/core/config.js +44 -2
- package/core/csrf.js +156 -24
- package/core/database.js +1184 -1131
- package/core/debug.js +1 -1
- package/core/html.js +8 -1
- package/core/index.d.ts +126 -310
- package/core/paths.js +55 -0
- package/core/ratelimit.js +10 -1
- package/core/react/client/api.js +239 -0
- package/core/react/client/auth.js +236 -0
- package/core/react/client/components.js +1321 -0
- package/core/react/client/datatable.js +595 -0
- package/core/react/client/i18n.js +440 -0
- package/core/react/client/index.d.ts +314 -0
- package/core/react/client/index.js +50 -0
- package/core/react/client/router.js +26 -0
- package/core/react/client/theme.css +512 -0
- package/core/render-cache.js +250 -212
- package/core/render.d.ts +25 -21
- package/core/render.js +738 -736
- package/core/router.d.ts +2 -3
- package/core/router.js +171 -171
- package/core/seo.js +10 -0
- package/core/spa.js +599 -0
- package/core/view-loader.js +155 -613
- package/core/vite-plugin.d.ts +18 -0
- package/core/vite-plugin.js +162 -0
- package/core/vite.js +250 -145
- package/index.js +22 -18
- package/jsconfig.json +5 -3
- package/package.json +114 -92
- package/production.md +8 -3
- package/public/js/bluebird.js +1886 -0
- package/templates/_auth/app/database.js +19 -0
- package/templates/_auth/app/models/user.js +22 -0
- package/templates/_auth/app/routes/auth-router.js +304 -0
- package/templates/_base/app/resources/html/layouts/main.html +55 -0
- package/templates/_base/app/resources/html/notFound.html +14 -0
- package/templates/_base/app/resources/index.html +27 -0
- package/templates/_base/app/resources/styles.css +9 -0
- package/templates/api/app/models/note.js +18 -0
- package/templates/api/app/routes/api.js +82 -0
- package/templates/api/app/routes/auth.js +11 -0
- package/templates/api/index.js +19 -0
- package/templates/api/template.json +13 -0
- package/templates/auth/app/mail.js +11 -0
- package/templates/auth/app/models/password_reset.js +18 -0
- package/templates/auth/app/resources/html/home.html +21 -0
- package/templates/auth/app/resources/html/partials/nav.html +2 -0
- package/templates/auth/app/resources/layouts/AppLayout.jsx +60 -0
- package/templates/auth/app/resources/main.jsx +18 -0
- package/templates/auth/app/resources/pages/Dashboard.jsx +51 -0
- package/templates/auth/app/resources/pages/ForgotPassword.jsx +34 -0
- package/templates/auth/app/resources/pages/Login.jsx +36 -0
- package/templates/auth/app/resources/pages/NotFound.jsx +16 -0
- package/templates/auth/app/resources/pages/Profile.jsx +99 -0
- package/templates/auth/app/resources/pages/Register.jsx +50 -0
- package/templates/auth/app/resources/pages/ResetPassword.jsx +50 -0
- package/templates/auth/app/resources/routes.jsx +54 -0
- package/templates/auth/app/resources/spa.js +29 -0
- package/templates/auth/app/routes/api.js +17 -0
- package/templates/auth/app/routes/auth.js +13 -0
- package/templates/auth/app/routes/web.js +21 -0
- package/templates/auth/index.js +19 -0
- package/templates/auth/template.json +15 -0
- package/templates/blank/app/models/.gitkeep +0 -0
- package/templates/blank/app/resources/html/home.html +27 -0
- package/templates/blank/app/resources/html/partials/nav.html +1 -0
- package/templates/blank/app/resources/main.jsx +16 -0
- package/templates/blank/app/resources/pages/Home.jsx +42 -0
- package/templates/blank/app/resources/pages/NotFound.jsx +27 -0
- package/templates/blank/app/resources/routes.jsx +15 -0
- package/templates/blank/app/resources/spa.js +24 -0
- package/templates/blank/app/routes/api.js +11 -0
- package/templates/blank/app/routes/web.js +21 -0
- package/templates/blank/index.js +13 -0
- package/templates/blank/template.json +12 -0
- package/templates/blog/app/lib/blog.js +149 -0
- package/templates/blog/app/models/post.js +22 -0
- package/templates/blog/app/resources/html/home.html +28 -0
- package/templates/blog/app/resources/html/not-found.html +5 -0
- package/templates/blog/app/resources/html/partials/nav.html +2 -0
- package/templates/blog/app/resources/html/partials/post-card.html +9 -0
- package/templates/blog/app/resources/html/post.html +8 -0
- package/templates/blog/app/resources/layouts/AdminLayout.jsx +54 -0
- package/templates/blog/app/resources/main.jsx +18 -0
- package/templates/blog/app/resources/pages/Login.jsx +31 -0
- package/templates/blog/app/resources/pages/NotFound.jsx +16 -0
- package/templates/blog/app/resources/pages/PostEditor.jsx +51 -0
- package/templates/blog/app/resources/pages/Posts.jsx +83 -0
- package/templates/blog/app/resources/pages/Register.jsx +43 -0
- package/templates/blog/app/resources/routes.jsx +51 -0
- package/templates/blog/app/resources/spa.js +25 -0
- package/templates/blog/app/resources/styles.css +40 -0
- package/templates/blog/app/routes/api.js +77 -0
- package/templates/blog/app/routes/auth.js +10 -0
- package/templates/blog/app/routes/web.js +114 -0
- package/templates/blog/index.js +21 -0
- package/templates/blog/template.json +14 -0
- package/vite.config.js +11 -0
- package/app/views/components/Header.jsx +0 -42
- package/app/views/components/LiveCounter.jsx +0 -67
- package/app/views/layouts/main/view.jsx +0 -201
- package/app/views/legal/terms.html +0 -29
- package/app/views/pages/about.jsx +0 -98
- package/app/views/pages/dashboard.jsx +0 -278
- package/app/views/pages/index.jsx +0 -123
- package/app/views/pages/login.jsx +0 -141
- package/core/actions.d.ts +0 -4
- package/core/actions.js +0 -355
- package/core/jsx.d.ts +0 -38
- package/core/jsx.js +0 -1597
- package/core/vite.d.ts +0 -3
- package/public/js/bluebird-client.js +0 -3265
- package/public/js/tailwind.js +0 -8
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Built-in UI strings for the React components (kept identical to `public/js/bluebird.js`).
|
|
5
|
+
* Keys missing in a language fall back to English.
|
|
6
|
+
* @type {Record<string, Record<string, string>>}
|
|
7
|
+
*/
|
|
8
|
+
export const MESSAGES = {
|
|
9
|
+
en: {
|
|
10
|
+
"toast.info": "Info",
|
|
11
|
+
"toast.success": "Success",
|
|
12
|
+
"toast.warning": "Warning",
|
|
13
|
+
"toast.error": "Error",
|
|
14
|
+
"toast.danger": "Alert",
|
|
15
|
+
"toast.region": "Notifications",
|
|
16
|
+
"toast.dismiss": "Dismiss notification",
|
|
17
|
+
"theme.toLight": "Switch to light theme",
|
|
18
|
+
"theme.toDark": "Switch to dark theme",
|
|
19
|
+
"theme.light": "Light",
|
|
20
|
+
"theme.dark": "Dark",
|
|
21
|
+
"dialog.close": "Close",
|
|
22
|
+
"dialog.label": "Dialog",
|
|
23
|
+
"drawer.label": "Panel",
|
|
24
|
+
"carousel.label": "Featured showcase",
|
|
25
|
+
"carousel.role": "carousel",
|
|
26
|
+
"carousel.slide": "slide",
|
|
27
|
+
"carousel.slides": "Slides",
|
|
28
|
+
"carousel.choose": "Choose a slide",
|
|
29
|
+
"carousel.prev": "Previous slide",
|
|
30
|
+
"carousel.next": "Next slide",
|
|
31
|
+
"carousel.prevShort": "Prev",
|
|
32
|
+
"carousel.nextShort": "Next",
|
|
33
|
+
"carousel.goTo": "Go to slide {n}",
|
|
34
|
+
"carousel.position": "{n} of {total}",
|
|
35
|
+
"carousel.status": "Slide {n} of {total}",
|
|
36
|
+
"loading": "Loading...",
|
|
37
|
+
"request.failed": "Request failed",
|
|
38
|
+
"request.network": "Network error",
|
|
39
|
+
"form.invalid": "Please check this field.",
|
|
40
|
+
"form.validation": "Validation error",
|
|
41
|
+
"value.invalid": "Invalid value",
|
|
42
|
+
"copy.done": "Copied to clipboard",
|
|
43
|
+
"auth.deniedTitle": "Access denied",
|
|
44
|
+
"auth.deniedText": "You do not have permission to view this section.",
|
|
45
|
+
"table.search": "Search...",
|
|
46
|
+
"table.empty": "No results",
|
|
47
|
+
"table.rowsPerPage": "Rows per page",
|
|
48
|
+
"table.range": "{from}-{to} of {total}",
|
|
49
|
+
"table.prev": "Previous page",
|
|
50
|
+
"table.next": "Next page",
|
|
51
|
+
"table.page": "Page {n} of {total}",
|
|
52
|
+
"table.actions": "Actions",
|
|
53
|
+
"table.view": "View",
|
|
54
|
+
"table.edit": "Edit",
|
|
55
|
+
"table.delete": "Delete",
|
|
56
|
+
"table.confirmTitle": "Delete this record?",
|
|
57
|
+
"table.confirmText": "This action cannot be undone.",
|
|
58
|
+
"table.cancel": "Cancel",
|
|
59
|
+
"table.more": "Show details",
|
|
60
|
+
"table.less": "Hide details",
|
|
61
|
+
"table.sortBy": "Sort by {column}",
|
|
62
|
+
},
|
|
63
|
+
es: {
|
|
64
|
+
"toast.info": "Info",
|
|
65
|
+
"toast.success": "Correcto",
|
|
66
|
+
"toast.warning": "Cuidado",
|
|
67
|
+
"toast.error": "Error",
|
|
68
|
+
"toast.danger": "Alerta",
|
|
69
|
+
"toast.region": "Notificaciones",
|
|
70
|
+
"toast.dismiss": "Cerrar notificación",
|
|
71
|
+
"theme.toLight": "Cambiar a tema claro",
|
|
72
|
+
"theme.toDark": "Cambiar a tema oscuro",
|
|
73
|
+
"theme.light": "Claro",
|
|
74
|
+
"theme.dark": "Oscuro",
|
|
75
|
+
"dialog.close": "Cerrar",
|
|
76
|
+
"dialog.label": "Diálogo",
|
|
77
|
+
"drawer.label": "Panel",
|
|
78
|
+
"carousel.label": "Destacados",
|
|
79
|
+
"carousel.role": "carrusel",
|
|
80
|
+
"carousel.slide": "diapositiva",
|
|
81
|
+
"carousel.slides": "Diapositivas",
|
|
82
|
+
"carousel.choose": "Elegir diapositiva",
|
|
83
|
+
"carousel.prev": "Diapositiva anterior",
|
|
84
|
+
"carousel.next": "Diapositiva siguiente",
|
|
85
|
+
"carousel.prevShort": "Anterior",
|
|
86
|
+
"carousel.nextShort": "Siguiente",
|
|
87
|
+
"carousel.goTo": "Ir a la diapositiva {n}",
|
|
88
|
+
"carousel.position": "{n} de {total}",
|
|
89
|
+
"carousel.status": "Diapositiva {n} de {total}",
|
|
90
|
+
"loading": "Cargando...",
|
|
91
|
+
"request.failed": "La solicitud falló",
|
|
92
|
+
"request.network": "Error de red",
|
|
93
|
+
"form.invalid": "Revisa este campo.",
|
|
94
|
+
"form.validation": "Error de validación",
|
|
95
|
+
"value.invalid": "Valor inválido",
|
|
96
|
+
"copy.done": "Copiado al portapapeles",
|
|
97
|
+
"auth.deniedTitle": "Acceso denegado",
|
|
98
|
+
"auth.deniedText": "No tienes permiso para ver esta sección.",
|
|
99
|
+
"table.search": "Buscar...",
|
|
100
|
+
"table.empty": "Sin resultados",
|
|
101
|
+
"table.rowsPerPage": "Filas por página",
|
|
102
|
+
"table.range": "{from}-{to} de {total}",
|
|
103
|
+
"table.prev": "Página anterior",
|
|
104
|
+
"table.next": "Página siguiente",
|
|
105
|
+
"table.page": "Página {n} de {total}",
|
|
106
|
+
"table.actions": "Acciones",
|
|
107
|
+
"table.view": "Ver",
|
|
108
|
+
"table.edit": "Editar",
|
|
109
|
+
"table.delete": "Eliminar",
|
|
110
|
+
"table.confirmTitle": "¿Eliminar este registro?",
|
|
111
|
+
"table.confirmText": "Esta acción no se puede deshacer.",
|
|
112
|
+
"table.cancel": "Cancelar",
|
|
113
|
+
"table.more": "Ver detalles",
|
|
114
|
+
"table.less": "Ocultar detalles",
|
|
115
|
+
"table.sortBy": "Ordenar por {column}",
|
|
116
|
+
},
|
|
117
|
+
pt: {
|
|
118
|
+
"toast.info": "Info",
|
|
119
|
+
"toast.success": "Sucesso",
|
|
120
|
+
"toast.warning": "Atenção",
|
|
121
|
+
"toast.error": "Erro",
|
|
122
|
+
"toast.danger": "Alerta",
|
|
123
|
+
"toast.region": "Notificações",
|
|
124
|
+
"toast.dismiss": "Fechar notificação",
|
|
125
|
+
"theme.toLight": "Mudar para o tema claro",
|
|
126
|
+
"theme.toDark": "Mudar para o tema escuro",
|
|
127
|
+
"theme.light": "Claro",
|
|
128
|
+
"theme.dark": "Escuro",
|
|
129
|
+
"dialog.close": "Fechar",
|
|
130
|
+
"dialog.label": "Diálogo",
|
|
131
|
+
"drawer.label": "Painel",
|
|
132
|
+
"carousel.label": "Destaques",
|
|
133
|
+
"carousel.role": "carrossel",
|
|
134
|
+
"carousel.slide": "slide",
|
|
135
|
+
"carousel.slides": "Slides",
|
|
136
|
+
"carousel.choose": "Escolher slide",
|
|
137
|
+
"carousel.prev": "Slide anterior",
|
|
138
|
+
"carousel.next": "Próximo slide",
|
|
139
|
+
"carousel.prevShort": "Anterior",
|
|
140
|
+
"carousel.nextShort": "Próximo",
|
|
141
|
+
"carousel.goTo": "Ir para o slide {n}",
|
|
142
|
+
"carousel.position": "{n} de {total}",
|
|
143
|
+
"carousel.status": "Slide {n} de {total}",
|
|
144
|
+
"loading": "Carregando...",
|
|
145
|
+
"request.failed": "A solicitação falhou",
|
|
146
|
+
"request.network": "Erro de rede",
|
|
147
|
+
"form.invalid": "Verifique este campo.",
|
|
148
|
+
"form.validation": "Erro de validação",
|
|
149
|
+
"value.invalid": "Valor inválido",
|
|
150
|
+
"copy.done": "Copiado para a área de transferência",
|
|
151
|
+
"auth.deniedTitle": "Acesso negado",
|
|
152
|
+
"auth.deniedText": "Você não tem permissão para ver esta seção.",
|
|
153
|
+
"table.search": "Pesquisar...",
|
|
154
|
+
"table.empty": "Nenhum resultado",
|
|
155
|
+
"table.rowsPerPage": "Linhas por página",
|
|
156
|
+
"table.range": "{from}-{to} de {total}",
|
|
157
|
+
"table.prev": "Página anterior",
|
|
158
|
+
"table.next": "Próxima página",
|
|
159
|
+
"table.page": "Página {n} de {total}",
|
|
160
|
+
"table.actions": "Ações",
|
|
161
|
+
"table.view": "Ver",
|
|
162
|
+
"table.edit": "Editar",
|
|
163
|
+
"table.delete": "Excluir",
|
|
164
|
+
"table.confirmTitle": "Excluir este registro?",
|
|
165
|
+
"table.confirmText": "Esta ação não pode ser desfeita.",
|
|
166
|
+
"table.cancel": "Cancelar",
|
|
167
|
+
"table.more": "Ver detalhes",
|
|
168
|
+
"table.less": "Ocultar detalhes",
|
|
169
|
+
"table.sortBy": "Ordenar por {column}",
|
|
170
|
+
},
|
|
171
|
+
fr: {
|
|
172
|
+
"toast.info": "Info",
|
|
173
|
+
"toast.success": "Succès",
|
|
174
|
+
"toast.warning": "Attention",
|
|
175
|
+
"toast.error": "Erreur",
|
|
176
|
+
"toast.danger": "Alerte",
|
|
177
|
+
"toast.region": "Notifications",
|
|
178
|
+
"toast.dismiss": "Fermer la notification",
|
|
179
|
+
"theme.toLight": "Passer au thème clair",
|
|
180
|
+
"theme.toDark": "Passer au thème sombre",
|
|
181
|
+
"theme.light": "Clair",
|
|
182
|
+
"theme.dark": "Sombre",
|
|
183
|
+
"dialog.close": "Fermer",
|
|
184
|
+
"dialog.label": "Boîte de dialogue",
|
|
185
|
+
"drawer.label": "Panneau",
|
|
186
|
+
"carousel.label": "À la une",
|
|
187
|
+
"carousel.role": "carrousel",
|
|
188
|
+
"carousel.slide": "diapositive",
|
|
189
|
+
"carousel.slides": "Diapositives",
|
|
190
|
+
"carousel.choose": "Choisir une diapositive",
|
|
191
|
+
"carousel.prev": "Diapositive précédente",
|
|
192
|
+
"carousel.next": "Diapositive suivante",
|
|
193
|
+
"carousel.prevShort": "Préc.",
|
|
194
|
+
"carousel.nextShort": "Suiv.",
|
|
195
|
+
"carousel.goTo": "Aller à la diapositive {n}",
|
|
196
|
+
"carousel.position": "{n} sur {total}",
|
|
197
|
+
"carousel.status": "Diapositive {n} sur {total}",
|
|
198
|
+
"loading": "Chargement...",
|
|
199
|
+
"request.failed": "La requête a échoué",
|
|
200
|
+
"request.network": "Erreur réseau",
|
|
201
|
+
"form.invalid": "Vérifiez ce champ.",
|
|
202
|
+
"form.validation": "Erreur de validation",
|
|
203
|
+
"value.invalid": "Valeur invalide",
|
|
204
|
+
"copy.done": "Copié dans le presse-papiers",
|
|
205
|
+
"auth.deniedTitle": "Accès refusé",
|
|
206
|
+
"auth.deniedText": "Vous n'avez pas l'autorisation de voir cette section.",
|
|
207
|
+
"table.search": "Rechercher...",
|
|
208
|
+
"table.empty": "Aucun résultat",
|
|
209
|
+
"table.rowsPerPage": "Lignes par page",
|
|
210
|
+
"table.range": "{from}-{to} sur {total}",
|
|
211
|
+
"table.prev": "Page précédente",
|
|
212
|
+
"table.next": "Page suivante",
|
|
213
|
+
"table.page": "Page {n} sur {total}",
|
|
214
|
+
"table.actions": "Actions",
|
|
215
|
+
"table.view": "Voir",
|
|
216
|
+
"table.edit": "Modifier",
|
|
217
|
+
"table.delete": "Supprimer",
|
|
218
|
+
"table.confirmTitle": "Supprimer cet enregistrement ?",
|
|
219
|
+
"table.confirmText": "Cette action est irréversible.",
|
|
220
|
+
"table.cancel": "Annuler",
|
|
221
|
+
"table.more": "Voir les détails",
|
|
222
|
+
"table.less": "Masquer les détails",
|
|
223
|
+
"table.sortBy": "Trier par {column}",
|
|
224
|
+
},
|
|
225
|
+
de: {
|
|
226
|
+
"toast.info": "Info",
|
|
227
|
+
"toast.success": "Erfolg",
|
|
228
|
+
"toast.warning": "Achtung",
|
|
229
|
+
"toast.error": "Fehler",
|
|
230
|
+
"toast.danger": "Warnung",
|
|
231
|
+
"toast.region": "Benachrichtigungen",
|
|
232
|
+
"toast.dismiss": "Benachrichtigung schließen",
|
|
233
|
+
"theme.toLight": "Zum hellen Design wechseln",
|
|
234
|
+
"theme.toDark": "Zum dunklen Design wechseln",
|
|
235
|
+
"theme.light": "Hell",
|
|
236
|
+
"theme.dark": "Dunkel",
|
|
237
|
+
"dialog.close": "Schließen",
|
|
238
|
+
"dialog.label": "Dialog",
|
|
239
|
+
"drawer.label": "Seitenleiste",
|
|
240
|
+
"carousel.label": "Highlights",
|
|
241
|
+
"carousel.role": "Karussell",
|
|
242
|
+
"carousel.slide": "Folie",
|
|
243
|
+
"carousel.slides": "Folien",
|
|
244
|
+
"carousel.choose": "Folie auswählen",
|
|
245
|
+
"carousel.prev": "Vorherige Folie",
|
|
246
|
+
"carousel.next": "Nächste Folie",
|
|
247
|
+
"carousel.prevShort": "Zurück",
|
|
248
|
+
"carousel.nextShort": "Weiter",
|
|
249
|
+
"carousel.goTo": "Zu Folie {n}",
|
|
250
|
+
"carousel.position": "{n} von {total}",
|
|
251
|
+
"carousel.status": "Folie {n} von {total}",
|
|
252
|
+
"loading": "Wird geladen...",
|
|
253
|
+
"request.failed": "Anfrage fehlgeschlagen",
|
|
254
|
+
"request.network": "Netzwerkfehler",
|
|
255
|
+
"form.invalid": "Bitte überprüfe dieses Feld.",
|
|
256
|
+
"form.validation": "Validierungsfehler",
|
|
257
|
+
"value.invalid": "Ungültiger Wert",
|
|
258
|
+
"copy.done": "In die Zwischenablage kopiert",
|
|
259
|
+
"auth.deniedTitle": "Zugriff verweigert",
|
|
260
|
+
"auth.deniedText": "Du hast keine Berechtigung, diesen Bereich zu sehen.",
|
|
261
|
+
"table.search": "Suchen...",
|
|
262
|
+
"table.empty": "Keine Ergebnisse",
|
|
263
|
+
"table.rowsPerPage": "Zeilen pro Seite",
|
|
264
|
+
"table.range": "{from}-{to} von {total}",
|
|
265
|
+
"table.prev": "Vorherige Seite",
|
|
266
|
+
"table.next": "Nächste Seite",
|
|
267
|
+
"table.page": "Seite {n} von {total}",
|
|
268
|
+
"table.actions": "Aktionen",
|
|
269
|
+
"table.view": "Ansehen",
|
|
270
|
+
"table.edit": "Bearbeiten",
|
|
271
|
+
"table.delete": "Löschen",
|
|
272
|
+
"table.confirmTitle": "Diesen Eintrag löschen?",
|
|
273
|
+
"table.confirmText": "Diese Aktion kann nicht rückgängig gemacht werden.",
|
|
274
|
+
"table.cancel": "Abbrechen",
|
|
275
|
+
"table.more": "Details anzeigen",
|
|
276
|
+
"table.less": "Details ausblenden",
|
|
277
|
+
"table.sortBy": "Nach {column} sortieren",
|
|
278
|
+
},
|
|
279
|
+
it: {
|
|
280
|
+
"toast.info": "Info",
|
|
281
|
+
"toast.success": "Fatto",
|
|
282
|
+
"toast.warning": "Attenzione",
|
|
283
|
+
"toast.error": "Errore",
|
|
284
|
+
"toast.danger": "Avviso",
|
|
285
|
+
"toast.region": "Notifiche",
|
|
286
|
+
"toast.dismiss": "Chiudi notifica",
|
|
287
|
+
"theme.toLight": "Passa al tema chiaro",
|
|
288
|
+
"theme.toDark": "Passa al tema scuro",
|
|
289
|
+
"theme.light": "Chiaro",
|
|
290
|
+
"theme.dark": "Scuro",
|
|
291
|
+
"dialog.close": "Chiudi",
|
|
292
|
+
"dialog.label": "Finestra di dialogo",
|
|
293
|
+
"drawer.label": "Pannello",
|
|
294
|
+
"carousel.label": "In evidenza",
|
|
295
|
+
"carousel.role": "carosello",
|
|
296
|
+
"carousel.slide": "slide",
|
|
297
|
+
"carousel.slides": "Slide",
|
|
298
|
+
"carousel.choose": "Scegli una slide",
|
|
299
|
+
"carousel.prev": "Slide precedente",
|
|
300
|
+
"carousel.next": "Slide successiva",
|
|
301
|
+
"carousel.prevShort": "Prec.",
|
|
302
|
+
"carousel.nextShort": "Succ.",
|
|
303
|
+
"carousel.goTo": "Vai alla slide {n}",
|
|
304
|
+
"carousel.position": "{n} di {total}",
|
|
305
|
+
"carousel.status": "Slide {n} di {total}",
|
|
306
|
+
"loading": "Caricamento...",
|
|
307
|
+
"request.failed": "Richiesta non riuscita",
|
|
308
|
+
"request.network": "Errore di rete",
|
|
309
|
+
"form.invalid": "Controlla questo campo.",
|
|
310
|
+
"form.validation": "Errore di convalida",
|
|
311
|
+
"value.invalid": "Valore non valido",
|
|
312
|
+
"copy.done": "Copiato negli appunti",
|
|
313
|
+
"auth.deniedTitle": "Accesso negato",
|
|
314
|
+
"auth.deniedText": "Non hai il permesso di vedere questa sezione.",
|
|
315
|
+
"table.search": "Cerca...",
|
|
316
|
+
"table.empty": "Nessun risultato",
|
|
317
|
+
"table.rowsPerPage": "Righe per pagina",
|
|
318
|
+
"table.range": "{from}-{to} di {total}",
|
|
319
|
+
"table.prev": "Pagina precedente",
|
|
320
|
+
"table.next": "Pagina successiva",
|
|
321
|
+
"table.page": "Pagina {n} di {total}",
|
|
322
|
+
"table.actions": "Azioni",
|
|
323
|
+
"table.view": "Vedi",
|
|
324
|
+
"table.edit": "Modifica",
|
|
325
|
+
"table.delete": "Elimina",
|
|
326
|
+
"table.confirmTitle": "Eliminare questo record?",
|
|
327
|
+
"table.confirmText": "Questa azione non può essere annullata.",
|
|
328
|
+
"table.cancel": "Annulla",
|
|
329
|
+
"table.more": "Mostra dettagli",
|
|
330
|
+
"table.less": "Nascondi dettagli",
|
|
331
|
+
"table.sortBy": "Ordina per {column}",
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
/** @type {Record<string, Record<string, string>>} */
|
|
336
|
+
const custom = {};
|
|
337
|
+
/** @type {string|null} */
|
|
338
|
+
let forcedLocale = null;
|
|
339
|
+
let version = 0;
|
|
340
|
+
const listeners = new Set();
|
|
341
|
+
let observer = null;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Notifies subscribed components that the locale or messages changed.
|
|
345
|
+
*/
|
|
346
|
+
function emit() {
|
|
347
|
+
version++;
|
|
348
|
+
for (const fn of listeners) fn();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Returns the active UI locale: `setLocale()` override, then `<html lang>`, then the browser language, then `"en"`.
|
|
353
|
+
* @returns {string}
|
|
354
|
+
*/
|
|
355
|
+
export function getLocale() {
|
|
356
|
+
if (forcedLocale) return forcedLocale;
|
|
357
|
+
if (typeof document !== "undefined" && document.documentElement?.lang) return document.documentElement.lang;
|
|
358
|
+
if (typeof navigator !== "undefined" && navigator.language) return navigator.language;
|
|
359
|
+
return "en";
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Forces the UI locale for all components (`null` returns to `<html lang>` detection).
|
|
364
|
+
* @param {string|null} locale
|
|
365
|
+
*/
|
|
366
|
+
export function setLocale(locale) {
|
|
367
|
+
forcedLocale = locale ? String(locale) : null;
|
|
368
|
+
emit();
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Adds or overrides UI strings for a language, e.g. `addMessages("es", { "toast.warning": "Atención" })`
|
|
373
|
+
* or a new language such as `addMessages("ja", { ... })`.
|
|
374
|
+
* @param {string} locale
|
|
375
|
+
* @param {Record<string, string>} messages
|
|
376
|
+
*/
|
|
377
|
+
export function addMessages(locale, messages) {
|
|
378
|
+
const key = String(locale).toLowerCase();
|
|
379
|
+
custom[key] = { ...(custom[key] || {}), ...messages };
|
|
380
|
+
emit();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Resolves a message for a locale: exact tag (`pt-br`), then base language (`pt`), then English.
|
|
385
|
+
* @param {string} key
|
|
386
|
+
* @param {string} locale
|
|
387
|
+
* @returns {string|undefined}
|
|
388
|
+
*/
|
|
389
|
+
function lookup(key, locale) {
|
|
390
|
+
const full = String(locale || "en").toLowerCase();
|
|
391
|
+
const base = full.split("-")[0];
|
|
392
|
+
for (const tag of [full, base]) {
|
|
393
|
+
if (custom[tag]?.[key] !== undefined) return custom[tag][key];
|
|
394
|
+
if (MESSAGES[tag]?.[key] !== undefined) return MESSAGES[tag][key];
|
|
395
|
+
}
|
|
396
|
+
return custom.en?.[key] ?? MESSAGES.en[key];
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Translates a UI string key for the active locale, replacing `{name}` placeholders.
|
|
401
|
+
* @param {string} key
|
|
402
|
+
* @param {Record<string, string|number>} [params]
|
|
403
|
+
* @param {string} [locale]
|
|
404
|
+
* @returns {string}
|
|
405
|
+
*/
|
|
406
|
+
export function t(key, params, locale) {
|
|
407
|
+
const message = lookup(key, locale || getLocale()) ?? key;
|
|
408
|
+
if (!params) return message;
|
|
409
|
+
return message.replace(/\{(\w+)\}/g, (match, name) => (params[name] !== undefined ? String(params[name]) : match));
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Subscribes to locale changes, including direct changes to `<html lang>`.
|
|
414
|
+
* @param {Function} fn
|
|
415
|
+
* @returns {Function}
|
|
416
|
+
*/
|
|
417
|
+
function subscribe(fn) {
|
|
418
|
+
listeners.add(fn);
|
|
419
|
+
if (!observer && typeof MutationObserver !== "undefined" && typeof document !== "undefined") {
|
|
420
|
+
observer = new MutationObserver(emit);
|
|
421
|
+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] });
|
|
422
|
+
}
|
|
423
|
+
return () => {
|
|
424
|
+
listeners.delete(fn);
|
|
425
|
+
if (listeners.size === 0 && observer) {
|
|
426
|
+
observer.disconnect();
|
|
427
|
+
observer = null;
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* React hook returning the active locale and a bound `t()`; re-renders when the locale or messages change.
|
|
434
|
+
* @returns {{ locale: string, t: (key: string, params?: Record<string, string|number>) => string, setLocale: typeof setLocale }}
|
|
435
|
+
*/
|
|
436
|
+
export function useLocale() {
|
|
437
|
+
useSyncExternalStore(subscribe, () => version, () => 0);
|
|
438
|
+
const locale = getLocale();
|
|
439
|
+
return { locale, t: (key, params) => t(key, params, locale), setLocale };
|
|
440
|
+
}
|