@judo/i18n 0.1.0
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/LICENSE +277 -0
- package/README.md +110 -0
- package/dist/formatters.d.ts +79 -0
- package/dist/formatters.d.ts.map +1 -0
- package/dist/i18n-provider.d.ts +83 -0
- package/dist/i18n-provider.d.ts.map +1 -0
- package/dist/i18n-service.d.ts +70 -0
- package/dist/i18n-service.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2569 -0
- package/dist/index.js.map +1 -0
- package/dist/locale-constants.d.ts +8 -0
- package/dist/locale-constants.d.ts.map +1 -0
- package/dist/system-messages.d.ts +198 -0
- package/dist/system-messages.d.ts.map +1 -0
- package/dist/translation-keys.d.ts +54 -0
- package/dist/translation-keys.d.ts.map +1 -0
- package/dist/use-model-label.d.ts +57 -0
- package/dist/use-model-label.d.ts.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
Eclipse Public License - v 2.0
|
|
2
|
+
|
|
3
|
+
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
|
|
4
|
+
PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
|
|
5
|
+
OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
|
|
6
|
+
|
|
7
|
+
1. DEFINITIONS
|
|
8
|
+
|
|
9
|
+
"Contribution" means:
|
|
10
|
+
|
|
11
|
+
a) in the case of the initial Contributor, the initial content
|
|
12
|
+
Distributed under this Agreement, and
|
|
13
|
+
|
|
14
|
+
b) in the case of each subsequent Contributor:
|
|
15
|
+
i) changes to the Program, and
|
|
16
|
+
ii) additions to the Program;
|
|
17
|
+
where such changes and/or additions to the Program originate from
|
|
18
|
+
and are Distributed by that particular Contributor. A Contribution
|
|
19
|
+
"originates" from a Contributor if it was added to the Program by
|
|
20
|
+
such Contributor itself or anyone acting on such Contributor's behalf.
|
|
21
|
+
Contributions do not include changes or additions to the Program that
|
|
22
|
+
are not Modified Works.
|
|
23
|
+
|
|
24
|
+
"Contributor" means any person or entity that Distributes the Program.
|
|
25
|
+
|
|
26
|
+
"Licensed Patents" mean patent claims licensable by a Contributor which
|
|
27
|
+
are necessarily infringed by the use or sale of its Contribution alone
|
|
28
|
+
or when combined with the Program.
|
|
29
|
+
|
|
30
|
+
"Program" means the Contributions Distributed in accordance with this
|
|
31
|
+
Agreement.
|
|
32
|
+
|
|
33
|
+
"Recipient" means anyone who receives the Program under this Agreement
|
|
34
|
+
or any Secondary License (as applicable), including Contributors.
|
|
35
|
+
|
|
36
|
+
"Derivative Works" shall mean any work, whether in Source Code or other
|
|
37
|
+
form, that is based on (or derived from) the Program and for which the
|
|
38
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
39
|
+
represent, as a whole, an original work of authorship.
|
|
40
|
+
|
|
41
|
+
"Modified Works" shall mean any work in Source Code or other form that
|
|
42
|
+
results from an addition to, deletion from, or modification of the
|
|
43
|
+
contents of the Program, including, for purposes of clarity any new file
|
|
44
|
+
in Source Code form that contains any contents of the Program. Modified
|
|
45
|
+
Works shall not include works that contain only declarations,
|
|
46
|
+
interfaces, types, classes, structures, or files of the Program solely
|
|
47
|
+
in each case in order to link to, bind by name, or subclass the Program
|
|
48
|
+
or Modified Works thereof.
|
|
49
|
+
|
|
50
|
+
"Distribute" means the acts of a) distributing or b) making available
|
|
51
|
+
in any manner that enables the transfer of a copy.
|
|
52
|
+
|
|
53
|
+
"Source Code" means the form of a Program preferred for making
|
|
54
|
+
modifications, including but not limited to software source code,
|
|
55
|
+
documentation source, and configuration files.
|
|
56
|
+
|
|
57
|
+
"Secondary License" means either the GNU General Public License,
|
|
58
|
+
Version 2.0, or any later versions of that license, including any
|
|
59
|
+
exceptions or additional permissions as identified by the initial
|
|
60
|
+
Contributor.
|
|
61
|
+
|
|
62
|
+
2. GRANT OF RIGHTS
|
|
63
|
+
|
|
64
|
+
a) Subject to the terms of this Agreement, each Contributor hereby
|
|
65
|
+
grants Recipient a non-exclusive, worldwide, royalty-free copyright
|
|
66
|
+
license to reproduce, prepare Derivative Works of, publicly display,
|
|
67
|
+
publicly perform, Distribute and sublicense the Contribution of such
|
|
68
|
+
Contributor, if any, and such Derivative Works.
|
|
69
|
+
|
|
70
|
+
b) Subject to the terms of this Agreement, each Contributor hereby
|
|
71
|
+
grants Recipient a non-exclusive, worldwide, royalty-free patent
|
|
72
|
+
license under Licensed Patents to make, use, sell, offer to sell,
|
|
73
|
+
import and otherwise transfer the Contribution of such Contributor,
|
|
74
|
+
if any, in Source Code or other form. This patent license shall
|
|
75
|
+
apply to the combination of the Contribution and the Program if, at
|
|
76
|
+
the time the Contribution is added by the Contributor, such addition
|
|
77
|
+
of the Contribution causes such combination to be covered by the
|
|
78
|
+
Licensed Patents. The patent license shall not apply to any other
|
|
79
|
+
combinations which include the Contribution. No hardware per se is
|
|
80
|
+
licensed hereunder.
|
|
81
|
+
|
|
82
|
+
c) Recipient understands that although each Contributor grants the
|
|
83
|
+
licenses to its Contributions set forth herein, no assurances are
|
|
84
|
+
provided by any Contributor that the Program does not infringe the
|
|
85
|
+
patent or other intellectual property rights of any other entity.
|
|
86
|
+
Each Contributor disclaims any liability to Recipient for claims
|
|
87
|
+
brought by any other entity based on infringement of intellectual
|
|
88
|
+
property rights or otherwise. As a condition to exercising the
|
|
89
|
+
rights and licenses granted hereunder, each Recipient hereby
|
|
90
|
+
assumes sole responsibility to secure any other intellectual
|
|
91
|
+
property rights needed, if any. For example, if a third party
|
|
92
|
+
patent license is required to allow Recipient to Distribute the
|
|
93
|
+
Program, it is Recipient's responsibility to acquire that license
|
|
94
|
+
before distributing the Program.
|
|
95
|
+
|
|
96
|
+
d) Each Contributor represents that to its knowledge it has
|
|
97
|
+
sufficient copyright rights in its Contribution, if any, to grant
|
|
98
|
+
the copyright license set forth in this Agreement.
|
|
99
|
+
|
|
100
|
+
e) Notwithstanding the terms of any Secondary License, no
|
|
101
|
+
Contributor makes additional grants to any Recipient (other than
|
|
102
|
+
those set forth in this Agreement) as a result of such Recipient's
|
|
103
|
+
receipt of the Program under the terms of a Secondary License
|
|
104
|
+
(if permitted under the terms of Section 3).
|
|
105
|
+
|
|
106
|
+
3. REQUIREMENTS
|
|
107
|
+
|
|
108
|
+
3.1 If a Contributor Distributes the Program in any form, then:
|
|
109
|
+
|
|
110
|
+
a) the Program must also be made available as Source Code, in
|
|
111
|
+
accordance with section 3.2, and the Contributor must accompany
|
|
112
|
+
the Program with a statement that the Source Code for the Program
|
|
113
|
+
is available under this Agreement, and informs Recipients how to
|
|
114
|
+
obtain it in a reasonable manner on or through a medium customarily
|
|
115
|
+
used for software exchange; and
|
|
116
|
+
|
|
117
|
+
b) the Contributor may Distribute the Program under a license
|
|
118
|
+
different than this Agreement, provided that such license:
|
|
119
|
+
i) effectively disclaims on behalf of all other Contributors all
|
|
120
|
+
warranties and conditions, express and implied, including
|
|
121
|
+
warranties or conditions of title and non-infringement, and
|
|
122
|
+
implied warranties or conditions of merchantability and fitness
|
|
123
|
+
for a particular purpose;
|
|
124
|
+
|
|
125
|
+
ii) effectively excludes on behalf of all other Contributors all
|
|
126
|
+
liability for damages, including direct, indirect, special,
|
|
127
|
+
incidental and consequential damages, such as lost profits;
|
|
128
|
+
|
|
129
|
+
iii) does not attempt to limit or alter the recipients' rights
|
|
130
|
+
in the Source Code under section 3.2; and
|
|
131
|
+
|
|
132
|
+
iv) requires any subsequent distribution of the Program by any
|
|
133
|
+
party to be under a license that satisfies the requirements
|
|
134
|
+
of this section 3.
|
|
135
|
+
|
|
136
|
+
3.2 When the Program is Distributed as Source Code:
|
|
137
|
+
|
|
138
|
+
a) it must be made available under this Agreement, or if the
|
|
139
|
+
Program (i) is combined with other material in a separate file or
|
|
140
|
+
files made available under a Secondary License, and (ii) the initial
|
|
141
|
+
Contributor attached to the Source Code the notice described in
|
|
142
|
+
Exhibit A of this Agreement, then the Program may be made available
|
|
143
|
+
under the terms of such Secondary Licenses, and
|
|
144
|
+
|
|
145
|
+
b) a copy of this Agreement must be included with each copy of
|
|
146
|
+
the Program.
|
|
147
|
+
|
|
148
|
+
3.3 Contributors may not remove or alter any copyright, patent,
|
|
149
|
+
trademark, attribution notices, disclaimers of warranty, or limitations
|
|
150
|
+
of liability ("notices") contained within the Program from any copy of
|
|
151
|
+
the Program which they Distribute, provided that Contributors may add
|
|
152
|
+
their own appropriate notices.
|
|
153
|
+
|
|
154
|
+
4. COMMERCIAL DISTRIBUTION
|
|
155
|
+
|
|
156
|
+
Commercial distributors of software may accept certain responsibilities
|
|
157
|
+
with respect to end users, business partners and the like. While this
|
|
158
|
+
license is intended to facilitate the commercial use of the Program,
|
|
159
|
+
the Contributor who includes the Program in a commercial product
|
|
160
|
+
offering should do so in a manner which does not create potential
|
|
161
|
+
liability for other Contributors. Therefore, if a Contributor includes
|
|
162
|
+
the Program in a commercial product offering, such Contributor
|
|
163
|
+
("Commercial Contributor") hereby agrees to defend and indemnify every
|
|
164
|
+
other Contributor ("Indemnified Contributor") against any losses,
|
|
165
|
+
damages and costs (collectively "Losses") arising from claims, lawsuits
|
|
166
|
+
and other legal actions brought by a third party against the Indemnified
|
|
167
|
+
Contributor to the extent caused by the acts or omissions of such
|
|
168
|
+
Commercial Contributor in connection with its distribution of the Program
|
|
169
|
+
in a commercial product offering. The obligations in this section do not
|
|
170
|
+
apply to any claims or Losses relating to any actual or alleged
|
|
171
|
+
intellectual property infringement. In order to qualify, an Indemnified
|
|
172
|
+
Contributor must: a) promptly notify the Commercial Contributor in
|
|
173
|
+
writing of such claim, and b) allow the Commercial Contributor to control,
|
|
174
|
+
and cooperate with the Commercial Contributor in, the defense and any
|
|
175
|
+
related settlement negotiations. The Indemnified Contributor may
|
|
176
|
+
participate in any such claim at its own expense.
|
|
177
|
+
|
|
178
|
+
For example, a Contributor might include the Program in a commercial
|
|
179
|
+
product offering, Product X. That Contributor is then a Commercial
|
|
180
|
+
Contributor. If that Commercial Contributor then makes performance
|
|
181
|
+
claims, or offers warranties related to Product X, those performance
|
|
182
|
+
claims and warranties are such Commercial Contributor's responsibility
|
|
183
|
+
alone. Under this section, the Commercial Contributor would have to
|
|
184
|
+
defend claims against the other Contributors related to those performance
|
|
185
|
+
claims and warranties, and if a court requires any other Contributor to
|
|
186
|
+
pay any damages as a result, the Commercial Contributor must pay
|
|
187
|
+
those damages.
|
|
188
|
+
|
|
189
|
+
5. NO WARRANTY
|
|
190
|
+
|
|
191
|
+
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
|
|
192
|
+
PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
|
|
193
|
+
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
|
|
194
|
+
IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
|
|
195
|
+
TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
|
|
196
|
+
PURPOSE. Each Recipient is solely responsible for determining the
|
|
197
|
+
appropriateness of using and distributing the Program and assumes all
|
|
198
|
+
risks associated with its exercise of rights under this Agreement,
|
|
199
|
+
including but not limited to the risks and costs of program errors,
|
|
200
|
+
compliance with applicable laws, damage to or loss of data, programs
|
|
201
|
+
or equipment, and unavailability or interruption of operations.
|
|
202
|
+
|
|
203
|
+
6. DISCLAIMER OF LIABILITY
|
|
204
|
+
|
|
205
|
+
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
|
|
206
|
+
PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
|
|
207
|
+
SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
208
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
|
|
209
|
+
PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
210
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
211
|
+
ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
|
|
212
|
+
EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
|
|
213
|
+
POSSIBILITY OF SUCH DAMAGES.
|
|
214
|
+
|
|
215
|
+
7. GENERAL
|
|
216
|
+
|
|
217
|
+
If any provision of this Agreement is invalid or unenforceable under
|
|
218
|
+
applicable law, it shall not affect the validity or enforceability of
|
|
219
|
+
the remainder of the terms of this Agreement, and without further
|
|
220
|
+
action by the parties hereto, such provision shall be reformed to the
|
|
221
|
+
minimum extent necessary to make such provision valid and enforceable.
|
|
222
|
+
|
|
223
|
+
If Recipient institutes patent litigation against any entity
|
|
224
|
+
(including a cross-claim or counterclaim in a lawsuit) alleging that the
|
|
225
|
+
Program itself (excluding combinations of the Program with other software
|
|
226
|
+
or hardware) infringes such Recipient's patent(s), then such Recipient's
|
|
227
|
+
rights granted under Section 2(b) shall terminate as of the date such
|
|
228
|
+
litigation is filed.
|
|
229
|
+
|
|
230
|
+
All Recipient's rights under this Agreement shall terminate if it
|
|
231
|
+
fails to comply with any of the material terms or conditions of this
|
|
232
|
+
Agreement and does not cure such failure in a reasonable period of
|
|
233
|
+
time after becoming aware of such noncompliance. If all Recipient's
|
|
234
|
+
rights under this Agreement terminate, Recipient agrees to cease use
|
|
235
|
+
and distribution of the Program as soon as reasonably practicable.
|
|
236
|
+
However, Recipient's obligations under this Agreement and any licenses
|
|
237
|
+
granted by Recipient relating to the Program shall continue and survive.
|
|
238
|
+
|
|
239
|
+
Everyone is permitted to copy and distribute copies of this Agreement,
|
|
240
|
+
but in order to avoid inconsistency the Agreement is copyrighted and
|
|
241
|
+
may only be modified in the following manner. The Agreement Steward
|
|
242
|
+
reserves the right to publish new versions (including revisions) of
|
|
243
|
+
this Agreement from time to time. No one other than the Agreement
|
|
244
|
+
Steward has the right to modify this Agreement. The Eclipse Foundation
|
|
245
|
+
is the initial Agreement Steward. The Eclipse Foundation may assign the
|
|
246
|
+
responsibility to serve as the Agreement Steward to a suitable separate
|
|
247
|
+
entity. Each new version of the Agreement will be given a distinguishing
|
|
248
|
+
version number. The Program (including Contributions) may always be
|
|
249
|
+
Distributed subject to the version of the Agreement under which it was
|
|
250
|
+
received. In addition, after a new version of the Agreement is published,
|
|
251
|
+
Contributor may elect to Distribute the Program (including its
|
|
252
|
+
Contributions) under the new version.
|
|
253
|
+
|
|
254
|
+
Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
|
|
255
|
+
receives no rights or licenses to the intellectual property of any
|
|
256
|
+
Contributor under this Agreement, whether expressly, by implication,
|
|
257
|
+
estoppel or otherwise. All rights in the Program not expressly granted
|
|
258
|
+
under this Agreement are reserved. Nothing in this Agreement is intended
|
|
259
|
+
to be enforceable by any entity that is not a Contributor or Recipient.
|
|
260
|
+
No third-party beneficiary rights are created under this Agreement.
|
|
261
|
+
|
|
262
|
+
Exhibit A - Form of Secondary Licenses Notice
|
|
263
|
+
|
|
264
|
+
"This Source Code may also be made available under the following
|
|
265
|
+
Secondary Licenses when the conditions for such availability set forth
|
|
266
|
+
in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
|
|
267
|
+
version(s), and exceptions or additional permissions here}."
|
|
268
|
+
|
|
269
|
+
Simply including a copy of this Agreement, including this Exhibit A
|
|
270
|
+
is not sufficient to license the Source Code under Secondary Licenses.
|
|
271
|
+
|
|
272
|
+
If it is not possible or desirable to put the notice in a particular
|
|
273
|
+
file, then You may include the notice in a location (such as a LICENSE
|
|
274
|
+
file in a relevant directory) where a recipient would be likely to
|
|
275
|
+
look for such a notice.
|
|
276
|
+
|
|
277
|
+
You may add additional accurate notices of copyright ownership.
|
package/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# @judo/i18n
|
|
2
|
+
|
|
3
|
+
> Internationalization and localization support for JUDO UI Runtime
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Provides translation key generation, locale-aware formatting, a system message catalog, a lightweight `I18nService`, and React integration via `react-i18next` (`I18nProvider`, locale hooks, `useModelLabel`). Supports runtime locale switching, codegen-based translation key maps, and passthrough mode for non-translated setups.
|
|
8
|
+
|
|
9
|
+
## Architecture Layer
|
|
10
|
+
|
|
11
|
+
**Layer 2 (Cross-cutting)** — consumed by components and higher layers for all text localization needs.
|
|
12
|
+
|
|
13
|
+
## Dependencies
|
|
14
|
+
|
|
15
|
+
- `@judo/model-api` — model type definitions (dependency + peer)
|
|
16
|
+
- `date-fns` — date formatting and locale support (peer)
|
|
17
|
+
- `i18next` — internationalization framework (peer)
|
|
18
|
+
- `react` — React runtime (peer)
|
|
19
|
+
- `react-i18next` — React bindings for i18next (peer)
|
|
20
|
+
|
|
21
|
+
## File Structure
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
src/
|
|
25
|
+
├── index.ts # Barrel re-export (pure utils + React integration)
|
|
26
|
+
├── i18n-provider.tsx # I18nProvider, useLocale, useLocaleOptional, LocaleContextType
|
|
27
|
+
├── i18n-provider.test.tsx # Provider + hook tests
|
|
28
|
+
├── use-model-label.ts # useModelLabel hook
|
|
29
|
+
├── use-model-label.test.tsx # useModelLabel tests
|
|
30
|
+
├── i18n-service.ts # I18nService interface + createI18nService factory
|
|
31
|
+
├── i18n-service.test.ts # Service tests
|
|
32
|
+
├── translation-keys.ts # Translation key generators for model elements
|
|
33
|
+
├── translation-keys.test.ts # Translation key tests
|
|
34
|
+
├── formatters.ts # Date/number/currency/percent formatting utilities
|
|
35
|
+
├── formatters.test.ts # Formatter tests
|
|
36
|
+
├── system-messages.ts # SYSTEM_MESSAGES catalog + getSystemMessage
|
|
37
|
+
├── system-messages.test.ts # System message tests
|
|
38
|
+
└── locale-constants.ts # LOCALE_STORAGE_KEY constant (HMR-safe)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Exports Summary
|
|
42
|
+
|
|
43
|
+
### Translation Key Generators
|
|
44
|
+
|
|
45
|
+
| Function | Description |
|
|
46
|
+
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
47
|
+
| `getTranslationKey(element, property?)` | Generates `{type}.{sourceId\|name}.{property}` from a model element. Strips `ui:`/`data:` prefix, lowercases. |
|
|
48
|
+
| `getSystemMessageKey(category, key)` | Builds `system.{category}.{key}`. |
|
|
49
|
+
| `getColumnTranslationKey(column)` | Generates `column.{sourceId\|name}.label` for a table column. |
|
|
50
|
+
| `getEnumTranslationKey(enumName, value)` | Generates `enum.{enumName}.{value}` for an enum literal. |
|
|
51
|
+
| `getNavItemTranslationKey(item)` | Generates `nav.{sourceId\|name}.label` for a navigation item. |
|
|
52
|
+
|
|
53
|
+
### Formatters
|
|
54
|
+
|
|
55
|
+
| Export | Kind | Description |
|
|
56
|
+
| --------------------------------------------------- | --------- | -------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `DateFormatOptions` | interface | Options for date formatting — `dateStyle`, `timeStyle`, and custom `format` (date-fns pattern). |
|
|
58
|
+
| `NumberFormatOptions` | interface | Options for number formatting — maps to `Intl.NumberFormat` options. |
|
|
59
|
+
| `parseDate(value)` | function | Normalizes a date value (`Date`, ISO string, or timestamp) into a `Date` object. |
|
|
60
|
+
| `getDateLocale(localeCode)` | function | Resolves a locale code (e.g. `en-US`, `de`) to a date-fns `Locale` object. Supports `en`, `de`, `hu`. |
|
|
61
|
+
| `formatDate(date, localeCode, options?)` | function | Formats a date by locale. Custom date-fns pattern if provided, otherwise style-based, or default `"PP"`. |
|
|
62
|
+
| `formatNumber(value, localeCode, options?)` | function | Formats a number via `Intl.NumberFormat`. |
|
|
63
|
+
| `formatCurrency(value, localeCode, currency)` | function | Formats a currency value with currency symbol display. |
|
|
64
|
+
| `formatRelativeTime(date, localeCode)` | function | Produces a human-readable relative time string (e.g. "2 days ago"). Auto-picks the best unit. |
|
|
65
|
+
| `formatPercent(value, localeCode, fractionDigits?)` | function | Formats a value as a percentage (`0.1` → `"10%"`). |
|
|
66
|
+
|
|
67
|
+
### System Messages
|
|
68
|
+
|
|
69
|
+
| Export | Kind | Description |
|
|
70
|
+
| --------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
71
|
+
| `SYSTEM_MESSAGES` | constant (`as const`) | Deeply-nested readonly object with default English system messages organized by 12 categories: `action`, `validation`, `nav`, `session`, `loading`, `error`, `empty`, `pagination`, `table`, `dialog`, `auth`, `common`. |
|
|
72
|
+
| `SystemMessageCategory` | type | Union of top-level keys of `SYSTEM_MESSAGES`. |
|
|
73
|
+
| `SystemMessageKey` | type | Union of all flattened dot-notation paths (e.g. `"action.save.success"`, `"error.notFound"`). Compile-time safe via recursive `FlattenKeys`. |
|
|
74
|
+
| `getSystemMessage(path)` | function | Retrieves a message string by dot-notation path. Returns `undefined` if path doesn't resolve. |
|
|
75
|
+
| `getAllSystemMessageKeys()` | function | Returns all leaf keys in flat dot-notation. |
|
|
76
|
+
|
|
77
|
+
### I18n Service
|
|
78
|
+
|
|
79
|
+
| Export | Kind | Description |
|
|
80
|
+
| ------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
81
|
+
| `TranslationOptions` | interface | Options for `t()`: `defaultValue`, `count` (pluralization), plus arbitrary interpolation values. |
|
|
82
|
+
| `I18nService` | interface | Contract for i18n implementations. Methods: `getLanguage`, `setLanguage`, `getAvailableLanguages`, `t`, `exists`, `formatDate`, `formatNumber`, `formatCurrency`, `formatRelativeTime`, `formatPercent`, `onLanguageChange`. |
|
|
83
|
+
| `I18nServiceConfig` | interface | Configuration: `defaultLanguage`, `supportedLanguages`, optional `resources` map. |
|
|
84
|
+
| `interpolate(template, values)` | function | Simple `{{key}}` template interpolation. Replaces placeholders with values; leaves unresolved ones intact. |
|
|
85
|
+
| `createI18nService(config)` | function | Factory that builds a lightweight `I18nService` implementation. Manages language state, translation lookup with fallback, interpolation, and language-change subscriptions. |
|
|
86
|
+
|
|
87
|
+
### React Integration
|
|
88
|
+
|
|
89
|
+
| Export | Kind | Description |
|
|
90
|
+
| ----------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
91
|
+
| `I18nProvider` | component | Wraps `I18nextProvider`, manages i18next instance lifecycle, supports `localeLoader`, `translationKeyMap`, and `persistLocale`. |
|
|
92
|
+
| `I18nProviderProps` | interface | Props: `defaultLocale?`, `locales?`, `localeLoader?`, `translationKeyMap?`, `persistLocale?`, `children`. |
|
|
93
|
+
| `useLocale()` | hook | Access locale context (current locale, setter, available locales). Throws if used outside `I18nProvider`. |
|
|
94
|
+
| `useLocaleOptional()` | hook | Access locale context (optional). Returns `null` outside `I18nProvider`. |
|
|
95
|
+
| `LocaleContextType` | interface | Context shape: `locale`, `setLocale`, `locales`, `hasTranslations`, `i18n`, `translationKeyMap?`. |
|
|
96
|
+
| `useModelLabel(element, property?)` | hook | Resolves translated label for a model element. Uses codegen key map if available, falls back to legacy format, then to `element.label ?? element.name`. |
|
|
97
|
+
| `ModelLabelResult` | interface | Result: `label` (translated string), `translationKey` (key used for lookup). |
|
|
98
|
+
| `LOCALE_STORAGE_KEY` | constant | localStorage key (`"judo-locale"`) used by `I18nProvider` for locale persistence. |
|
|
99
|
+
|
|
100
|
+
## Key Patterns
|
|
101
|
+
|
|
102
|
+
- **Two layers**: Pure utilities (translation keys, formatters, service, system messages) have no React dependency; React integration (`I18nProvider`, hooks) requires `react`, `i18next`, `react-i18next`.
|
|
103
|
+
- **Interface + Factory**: `I18nService` is a pure interface; `createI18nService` is the default factory. Allows swapping in production implementations (e.g. `react-i18next`).
|
|
104
|
+
- **Locale-aware formatting via Intl + date-fns**: Custom format patterns use date-fns `format()`; all other formatters use native `Intl` APIs.
|
|
105
|
+
- **Translation fallback chain**: `t()` looks up in current language → falls back to `defaultLanguage` → returns `defaultValue` option → returns the raw key.
|
|
106
|
+
- **Dual-path key resolution**: `useModelLabel` prefers codegen `translationKeyMap` (xmi:id → human-readable path), falls back to legacy `getTranslationKey()` format.
|
|
107
|
+
- **Passthrough mode**: When no `localeLoader` is provided, `t(key, { defaultValue })` returns the `defaultValue` — model labels pass through unchanged.
|
|
108
|
+
- **Subscription model**: `onLanguageChange()` returns an unsubscribe function, enabling React components to re-render on language switches.
|
|
109
|
+
- **Deeply-typed system messages**: Recursive `FlattenKeys` utility type generates a union of every valid dot-notation path for compile-time safety.
|
|
110
|
+
- **Key generation convention**: All translation-key generators follow a predictable `{type}.{sourceId}` pattern derived from model element metadata.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Locale } from 'date-fns';
|
|
2
|
+
/**
|
|
3
|
+
* Options for date formatting.
|
|
4
|
+
*/
|
|
5
|
+
export interface DateFormatOptions {
|
|
6
|
+
/** Predefined format style */
|
|
7
|
+
dateStyle?: "short" | "medium" | "long" | "full";
|
|
8
|
+
timeStyle?: "short" | "medium" | "long" | "full";
|
|
9
|
+
/** Custom format string (date-fns format) */
|
|
10
|
+
format?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Options for number formatting.
|
|
14
|
+
*/
|
|
15
|
+
export interface NumberFormatOptions {
|
|
16
|
+
style?: "decimal" | "percent" | "currency";
|
|
17
|
+
minimumFractionDigits?: number;
|
|
18
|
+
maximumFractionDigits?: number;
|
|
19
|
+
useGrouping?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parse a date value into a Date object.
|
|
23
|
+
*
|
|
24
|
+
* @param date - Date value (Date, ISO string, or timestamp)
|
|
25
|
+
* @returns Parsed Date object
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseDate(date: Date | string | number): Date;
|
|
28
|
+
/**
|
|
29
|
+
* Get the date-fns locale object for a given locale code.
|
|
30
|
+
*
|
|
31
|
+
* @param localeCode - Locale code (e.g., 'en-US', 'de-DE')
|
|
32
|
+
* @returns date-fns Locale object, defaults to enUS
|
|
33
|
+
*/
|
|
34
|
+
export declare function getDateLocale(localeCode: string): Locale;
|
|
35
|
+
/**
|
|
36
|
+
* Format a date according to the specified locale and options.
|
|
37
|
+
*
|
|
38
|
+
* @param date - Date to format
|
|
39
|
+
* @param localeCode - Locale code for formatting
|
|
40
|
+
* @param options - Format options
|
|
41
|
+
* @returns Formatted date string
|
|
42
|
+
*/
|
|
43
|
+
export declare function formatDate(date: Date | string | number, localeCode: string, options?: DateFormatOptions): string;
|
|
44
|
+
/**
|
|
45
|
+
* Format a number according to the specified locale and options.
|
|
46
|
+
*
|
|
47
|
+
* @param value - Number to format
|
|
48
|
+
* @param localeCode - Locale code for formatting
|
|
49
|
+
* @param options - Format options
|
|
50
|
+
* @returns Formatted number string
|
|
51
|
+
*/
|
|
52
|
+
export declare function formatNumber(value: number, localeCode: string, options?: NumberFormatOptions): string;
|
|
53
|
+
/**
|
|
54
|
+
* Format a currency value according to the specified locale.
|
|
55
|
+
*
|
|
56
|
+
* @param value - Number to format as currency
|
|
57
|
+
* @param localeCode - Locale code for formatting
|
|
58
|
+
* @param currency - Currency code (e.g., 'USD', 'EUR')
|
|
59
|
+
* @returns Formatted currency string
|
|
60
|
+
*/
|
|
61
|
+
export declare function formatCurrency(value: number, localeCode: string, currency: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Format a relative time (e.g., "2 days ago", "in 3 hours").
|
|
64
|
+
*
|
|
65
|
+
* @param date - Date to format relative to now
|
|
66
|
+
* @param localeCode - Locale code for formatting
|
|
67
|
+
* @returns Formatted relative time string
|
|
68
|
+
*/
|
|
69
|
+
export declare function formatRelativeTime(date: Date | string | number, localeCode: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Format a percentage value.
|
|
72
|
+
*
|
|
73
|
+
* @param value - Number to format as percentage (0.1 = 10%)
|
|
74
|
+
* @param localeCode - Locale code for formatting
|
|
75
|
+
* @param fractionDigits - Number of decimal places
|
|
76
|
+
* @returns Formatted percentage string
|
|
77
|
+
*/
|
|
78
|
+
export declare function formatPercent(value: number, localeCode: string, fractionDigits?: number): string;
|
|
79
|
+
//# sourceMappingURL=formatters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAevC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,8BAA8B;IAC9B,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IACjD,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IACjD,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;IAC3C,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ5D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAmBhH;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAErG;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK1F;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAqB3F;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,SAAI,GAAG,MAAM,CAM3F"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { i18n as I18nInstance } from 'i18next';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Locale context for managing the active locale and available locales.
|
|
5
|
+
*/
|
|
6
|
+
export interface LocaleContextType {
|
|
7
|
+
/** Current active locale code (e.g., "en-US") */
|
|
8
|
+
locale: string;
|
|
9
|
+
/** Change the active locale. Triggers async translation loading if a loader is configured. */
|
|
10
|
+
setLocale: (locale: string) => Promise<void>;
|
|
11
|
+
/** Map of supported locale codes to their display labels */
|
|
12
|
+
locales: Record<string, string>;
|
|
13
|
+
/** Whether translations are available (a locale loader was provided) */
|
|
14
|
+
hasTranslations: boolean;
|
|
15
|
+
/** The i18next instance */
|
|
16
|
+
i18n: I18nInstance;
|
|
17
|
+
/**
|
|
18
|
+
* Map of element sourceId (xmi:id) to human-readable translation key path.
|
|
19
|
+
* Generated by codegen. When present, useModelLabel uses this to resolve keys.
|
|
20
|
+
* When absent, falls back to the legacy type.sourceId.property format.
|
|
21
|
+
*/
|
|
22
|
+
translationKeyMap?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
export interface I18nProviderProps {
|
|
25
|
+
/**
|
|
26
|
+
* Default locale from the Application model.
|
|
27
|
+
* Falls back to "en-US" if not specified.
|
|
28
|
+
*/
|
|
29
|
+
defaultLocale?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Supported locales. Keys are ISO locale codes, values are display labels.
|
|
32
|
+
* @example { "en-US": "English", "hu-HU": "Magyar" }
|
|
33
|
+
*/
|
|
34
|
+
locales?: Record<string, string>;
|
|
35
|
+
/**
|
|
36
|
+
* Async locale loader function. Called with the locale code, must return
|
|
37
|
+
* a flat key→value translation map compatible with i18next.
|
|
38
|
+
*
|
|
39
|
+
* If not provided, translations are skipped and model labels are used via
|
|
40
|
+
* `defaultValue` fallback in `t()` calls.
|
|
41
|
+
*/
|
|
42
|
+
localeLoader?: (locale: string) => Promise<Record<string, string>>;
|
|
43
|
+
/**
|
|
44
|
+
* Map of element sourceId (xmi:id) to human-readable translation key path.
|
|
45
|
+
* Generated by codegen (`_translation-key-map.ts`).
|
|
46
|
+
* When provided, useModelLabel() uses this map to resolve element translation keys
|
|
47
|
+
* instead of the legacy type-based format.
|
|
48
|
+
*/
|
|
49
|
+
translationKeyMap?: Record<string, string>;
|
|
50
|
+
/**
|
|
51
|
+
* When true, persists the selected locale to localStorage and restores it
|
|
52
|
+
* on subsequent visits. The stored locale is only used if it appears in the
|
|
53
|
+
* supported `locales` map; otherwise the `defaultLocale` is used.
|
|
54
|
+
*
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
persistLocale?: boolean;
|
|
58
|
+
children: ReactNode;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* I18n provider that wraps the application with react-i18next.
|
|
62
|
+
*
|
|
63
|
+
* Initializes i18next with the model's default language and loads translations
|
|
64
|
+
* via the provided `localeLoader`. Supports runtime locale switching.
|
|
65
|
+
*
|
|
66
|
+
* If no `localeLoader` is provided, i18next is initialized in a passthrough
|
|
67
|
+
* mode where `t(key, { defaultValue })` always returns the `defaultValue`,
|
|
68
|
+
* effectively using model-defined labels directly.
|
|
69
|
+
*/
|
|
70
|
+
export declare function I18nProvider({ defaultLocale, locales, localeLoader, translationKeyMap, persistLocale, children, }: I18nProviderProps): import("react/jsx-runtime").JSX.Element | null;
|
|
71
|
+
/**
|
|
72
|
+
* Hook to access locale context.
|
|
73
|
+
* Provides the current locale, a setter for changing it, and available locales.
|
|
74
|
+
*
|
|
75
|
+
* @throws If used outside I18nProvider.
|
|
76
|
+
*/
|
|
77
|
+
export declare function useLocale(): LocaleContextType;
|
|
78
|
+
/**
|
|
79
|
+
* Hook to access locale context (optional).
|
|
80
|
+
* Returns null if used outside I18nProvider.
|
|
81
|
+
*/
|
|
82
|
+
export declare function useLocaleOptional(): LocaleContextType | null;
|
|
83
|
+
//# sourceMappingURL=i18n-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n-provider.d.ts","sourceRoot":"","sources":["../src/i18n-provider.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAgB,EAAE,KAAK,IAAI,IAAI,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAgF,MAAM,OAAO,CAAC;AAmCrH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,8FAA8F;IAC9F,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,wEAAwE;IACxE,eAAe,EAAE,OAAO,CAAC;IACzB,2BAA2B;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C;AAQD,MAAM,WAAW,iBAAiB;IACjC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAEnE;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE3C;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,QAAQ,EAAE,SAAS,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,EAC5B,aAAuB,EACvB,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,aAAqB,EACrB,QAAQ,GACR,EAAE,iBAAiB,kDAiJnB;AAMD;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,iBAAiB,CAM7C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,GAAG,IAAI,CAE5D"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { DateFormatOptions, NumberFormatOptions } from './formatters';
|
|
2
|
+
/**
|
|
3
|
+
* Options for translation function.
|
|
4
|
+
*/
|
|
5
|
+
export interface TranslationOptions {
|
|
6
|
+
/** Default value if key not found */
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
/** Count for pluralization */
|
|
9
|
+
count?: number;
|
|
10
|
+
/** Interpolation values */
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* I18n service interface for internationalization.
|
|
15
|
+
* This interface defines the contract for i18n implementations.
|
|
16
|
+
*/
|
|
17
|
+
export interface I18nService {
|
|
18
|
+
/** Get current language */
|
|
19
|
+
getLanguage(): string;
|
|
20
|
+
/** Set language (triggers re-render in React context) */
|
|
21
|
+
setLanguage(lang: string): Promise<void>;
|
|
22
|
+
/** Get available languages */
|
|
23
|
+
getAvailableLanguages(): string[];
|
|
24
|
+
/** Translate a key */
|
|
25
|
+
t(key: string, options?: TranslationOptions): string;
|
|
26
|
+
/** Check if translation exists */
|
|
27
|
+
exists(key: string): boolean;
|
|
28
|
+
/** Format date according to current locale */
|
|
29
|
+
formatDate(date: Date | string | number, options?: DateFormatOptions): string;
|
|
30
|
+
/** Format number according to current locale */
|
|
31
|
+
formatNumber(value: number, options?: NumberFormatOptions): string;
|
|
32
|
+
/** Format currency */
|
|
33
|
+
formatCurrency(value: number, currency: string): string;
|
|
34
|
+
/** Format relative time */
|
|
35
|
+
formatRelativeTime(date: Date | string | number): string;
|
|
36
|
+
/** Format percentage */
|
|
37
|
+
formatPercent(value: number, fractionDigits?: number): string;
|
|
38
|
+
/** Subscribe to language changes */
|
|
39
|
+
onLanguageChange(callback: (lang: string) => void): () => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Configuration for creating an I18n service.
|
|
43
|
+
*/
|
|
44
|
+
export interface I18nServiceConfig {
|
|
45
|
+
/** Default language */
|
|
46
|
+
defaultLanguage: string;
|
|
47
|
+
/** Available languages */
|
|
48
|
+
supportedLanguages: string[];
|
|
49
|
+
/** Translation resources (language -> key -> value) */
|
|
50
|
+
resources?: Record<string, Record<string, string>>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Simple interpolation for translation strings.
|
|
54
|
+
* Replaces {{key}} patterns with provided values.
|
|
55
|
+
*
|
|
56
|
+
* @param template - Template string with {{key}} patterns
|
|
57
|
+
* @param values - Values to interpolate
|
|
58
|
+
* @returns Interpolated string
|
|
59
|
+
*/
|
|
60
|
+
export declare function interpolate(template: string, values: Record<string, unknown>): string;
|
|
61
|
+
/**
|
|
62
|
+
* Create a simple I18n service implementation.
|
|
63
|
+
* This is a lightweight implementation for testing and basic usage.
|
|
64
|
+
* In production, use react-i18next integration.
|
|
65
|
+
*
|
|
66
|
+
* @param config - I18n configuration
|
|
67
|
+
* @returns I18nService implementation
|
|
68
|
+
*/
|
|
69
|
+
export declare function createI18nService(config: I18nServiceConfig): I18nService;
|
|
70
|
+
//# sourceMappingURL=i18n-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n-service.d.ts","sourceRoot":"","sources":["../src/i18n-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAG3E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,2BAA2B;IAC3B,WAAW,IAAI,MAAM,CAAC;IAEtB,yDAAyD;IACzD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzC,8BAA8B;IAC9B,qBAAqB,IAAI,MAAM,EAAE,CAAC;IAElC,sBAAsB;IACtB,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAAC;IAErD,kCAAkC;IAClC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAE7B,8CAA8C;IAC9C,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC;IAE9E,gDAAgD;IAChD,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC;IAEnE,sBAAsB;IACtB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAExD,2BAA2B;IAC3B,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAEzD,wBAAwB;IACxB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE9D,oCAAoC;IACpC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC/D;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,uBAAuB;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,0BAA0B;IAC1B,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACnD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAKrF;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW,CAsFxE"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @judo/i18n
|
|
3
|
+
*
|
|
4
|
+
* Internationalization and localization support for JUDO UI Runtime.
|
|
5
|
+
*/
|
|
6
|
+
export { getTranslationKey, getSystemMessageKey, getColumnTranslationKey, getEnumTranslationKey, getNavItemTranslationKey, } from './translation-keys';
|
|
7
|
+
export { formatDate, formatNumber, formatCurrency, formatRelativeTime, formatPercent, parseDate, getDateLocale, type DateFormatOptions, type NumberFormatOptions, } from './formatters';
|
|
8
|
+
export { SYSTEM_MESSAGES, getSystemMessage, getAllSystemMessageKeys, type SystemMessageCategory, type SystemMessageKey, } from './system-messages';
|
|
9
|
+
export { createI18nService, interpolate, type I18nService, type I18nServiceConfig, type TranslationOptions, } from './i18n-service';
|
|
10
|
+
export { I18nProvider, useLocale, useLocaleOptional, type I18nProviderProps, type LocaleContextType, } from './i18n-provider';
|
|
11
|
+
export { LOCALE_STORAGE_KEY } from './locale-constants';
|
|
12
|
+
export { useModelLabel, type ModelLabelResult } from './use-model-label';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|