@fundamental-ngx/i18n 0.58.0-rc.99 → 0.58.1-rc.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/README.md CHANGED
@@ -18,36 +18,117 @@
18
18
 
19
19
  ## 1. Description
20
20
 
21
- `@fundamental-ngx/i18n` is a library that provides translation utilities for the Fundamental-ngx library.
22
- The library is tailored for the use in `fundamental-ngx` components and can be used for modifying the variety of the
23
- components' labels, hints, and descriptions.
21
+ `@fundamental-ngx/i18n` provides centralized internationalization for Fundamental-ngx components with support for 37+ languages and runtime translation switching.
24
22
 
25
- Even though the library is tailored for the use in `fundamental-ngx` components, it can be used in any Angular application,
26
- where the simple translations are needed.
23
+ ### What's Included
27
24
 
28
- The library elements are for the runtime, which gives the possibility to swap the translations on the fly, without
29
- having to refresh the pages.
25
+ - Pre-compiled translation data for 37+ languages (as `FD_LANGUAGE_*` constants)
26
+ - Translation resolver utilities (signals, observables, and synchronous APIs)
27
+ - `FdTranslatePipe` for template translations
28
+ - Type-safe translation keys via `FdLanguage` interface
29
+
30
+ ### How It Works
31
+
32
+ 1. **Source**: Translation teams provide `.properties` files (Java-style format)
33
+ 2. **Build**: NX executor converts `.properties` → TypeScript modules
34
+ 3. **Export**: Language constants (`FD_LANGUAGE_ENGLISH`, `FD_LANGUAGE_GERMAN`, etc.)
35
+ 4. **Publish**: Compiled JavaScript (not source `.properties`) published to npm
36
+ 5. **Use**: Apps import language constants and translation utilities
37
+
38
+ While designed for Fundamental-ngx components, this library works in any Angular application needing runtime-switchable translations.
39
+
40
+ ### Adding New Translation Keys
41
+
42
+ > **This guide is for adding new translation keys (labels, ARIA attributes), NOT for adding new languages.**
43
+
44
+ #### Quick Steps
45
+
46
+ 1. **Update interface**: Add key to [`FdLanguage`](src/lib/models/fd-language.ts) interface
47
+ 2. **Add to all .properties files**: Same key + English text in all 37+ language files
48
+ 3. **Run**: `nx run i18n:transform-translations`
49
+ 4. **Use**: Import and use in your component
50
+
51
+ ---
52
+
53
+ #### Step 1: Update TypeScript Interface
54
+
55
+ Add your key to `libs/i18n/src/lib/models/fd-language.ts`:
56
+
57
+ ```typescript
58
+ export interface FdLanguage {
59
+ coreYourComponent: {
60
+ /** Description */
61
+ yourNewKey: FdLanguageKey;
62
+ keyWithParams: FdLanguageKey<{ count: number }>;
63
+ };
64
+ }
65
+ ```
66
+
67
+ > **Note**: `fd-language-key-identifier.ts` is auto-generated - don't edit it manually.
68
+
69
+ #### Step 2: Add to ALL .properties Files
70
+
71
+ Add to **all** files in `libs/i18n/src/lib/translations/` (use English text everywhere):
72
+
73
+ ```properties
74
+ #XBUT: Button / #XFLD: Label / #XTIT: Title / #XACT: ARIA / #XMSG: Message
75
+ coreYourComponent.yourNewKey = Your English text
76
+ coreYourComponent.keyWithParams = Item {count}
77
+ ```
78
+
79
+ **Why all files?** TypeScript requires identical keys across all languages. Translation teams will replace English placeholders later.
80
+
81
+ #### Step 3: Generate TypeScript Files
82
+
83
+ ```bash
84
+ nx run i18n:transform-translations
85
+ ```
86
+
87
+ Auto-generates: `translations*.ts`, `fd-language-key-identifier.ts` (union type), test files
88
+
89
+ #### Step 4: Use in Components
90
+
91
+ **Template (pipe):**
92
+
93
+ ```typescript
94
+ import { FdTranslatePipe } from '@fundamental-ngx/i18n';
95
+
96
+ @Component({
97
+ imports: [FdTranslatePipe],
98
+ template: `<button>{{ 'coreYourComponent.yourNewKey' | fdTranslate }}</button>`
99
+ })
100
+ ```
101
+
102
+ **TypeScript (signal):**
103
+
104
+ ```typescript
105
+ import { resolveTranslationSignal } from '@fundamental-ngx/i18n';
106
+
107
+ protected readonly label = resolveTranslationSignal('coreYourComponent.yourNewKey');
108
+ ```
109
+
110
+ **Post-merge**: Translation teams will provide proper translations in future releases.
30
111
 
31
112
  ## 2. Requirements
32
113
 
33
- To download and use Fundamental Library i18n package, you will first need to install
34
- the [node package manager](https://www.npmjs.com/get-npm). The library is intended for use with
35
- Angular 16.2 or newer. Prior knowledge of Angular is recommended, to use it fully library.
114
+ - Node.js and npm
115
+ - Angular 16.2 or newer
116
+ - Prior Angular knowledge recommended
36
117
 
37
118
  ## 3. Versioning
38
119
 
39
- Check the [Breaking Changes](https://github.com/SAP/fundamental-ngx/wiki#breaking-changes) for the latest patches changes.
120
+ See [Breaking Changes](https://github.com/SAP/fundamental-ngx/wiki#breaking-changes) for the latest updates.
40
121
 
41
122
  ## 4. Known Issues
42
123
 
43
- Please see [Issues](https://github.com/SAP/fundamental-ngx/issues).
124
+ See [Issues](https://github.com/SAP/fundamental-ngx/issues).
44
125
 
45
126
  ## 5. Support
46
127
 
47
- If you encounter an issue, you can [create a ticket](https://github.com/SAP/fundamental-ngx/issues).
128
+ [Create a ticket](https://github.com/SAP/fundamental-ngx/issues) for issues or questions.
48
129
 
49
130
  ## 6. Contributing
50
131
 
51
- If you want to contribute, please check the [CONTRIBUTING.md](https://github.com/SAP/fundamental-ngx/blob/main/CONTRIBUTING.md) documentation for contribution guidelines. Please follow the [Angular commit message guidelines](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit).
132
+ Check [CONTRIBUTING.md](https://github.com/SAP/fundamental-ngx/blob/main/CONTRIBUTING.md) for guidelines. Follow [Angular commit message guidelines](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit).
52
133
 
53
- Check out the [NEW_COMPONENT.md](https://github.com/SAP/fundamental-ngx/blob/main/NEW_COMPONENT.md) guide on building a new component for the library and creating the necessary documentation for your new component.
134
+ See [NEW_COMPONENT.md](https://github.com/SAP/fundamental-ngx/blob/main/NEW_COMPONENT.md) for creating new components.