ud-components 0.6.0 → 0.6.2

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.
@@ -0,0 +1,32 @@
1
+ import { TranslateLoader } from '@ngx-translate/core';
2
+ /**
3
+ * Wraps a consumer's TranslateLoader so the library's own strings are there
4
+ * without every app copying them into its en.json.
5
+ *
6
+ * Layered rather than merged after the fact: the app's loader is asynchronous,
7
+ * and racing setTranslation against an HTTP response is how precedence bugs are
8
+ * born. Here the order is structural — the library is the base, the app's
9
+ * translations are laid over it — so an app override wins by construction
10
+ * whenever the app's file happens to arrive.
11
+ *
12
+ * The app always wins. `actions.save` and `names.phone` are generic enough that
13
+ * an app may legitimately want its own wording, and a library that could not be
14
+ * overridden would be reserving six namespaces across every consumer.
15
+ *
16
+ * ```ts
17
+ * TranslateModule.forRoot({
18
+ * loader: {
19
+ * provide: TranslateLoader,
20
+ * useFactory: (http: HttpClient) =>
21
+ * withUdComponentsTranslations(new TranslateHttpLoader(http)),
22
+ * deps: [HttpClient],
23
+ * },
24
+ * })
25
+ * ```
26
+ */
27
+ export declare function withUdComponentsTranslations(appLoader: TranslateLoader): TranslateLoader;
28
+ /**
29
+ * For an app with no translation files of its own — the library's strings and
30
+ * nothing else. Mostly useful in tests and in the explorer.
31
+ */
32
+ export declare function udComponentsOnlyTranslateLoader(): TranslateLoader;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Every string the library renders, in every language it ships.
3
+ *
4
+ * These are defaults, not overrides. A consuming app's own translations win —
5
+ * see `withUdComponentsTranslations` — so an app that wants different wording
6
+ * for a generic key like `actions.save` simply keeps defining it.
7
+ *
8
+ * They live here as constants rather than as JSON assets on purpose: an asset
9
+ * would need every consumer to add a glob to angular.json, which is more setup
10
+ * than the duplication it replaces. A constant is an import, versioned with the
11
+ * code that reads it.
12
+ *
13
+ * Keys are grouped by the namespace the components actually ask for. Adding a
14
+ * key to a component means adding it here in the same change, or the string
15
+ * ships as a raw key to every app that has not guessed it — which is exactly
16
+ * what happened when the table gained its clear-filters control and three apps
17
+ * had to be edited to catch up.
18
+ */
19
+ export interface UdTranslations {
20
+ [namespace: string]: unknown;
21
+ }
22
+ /** Languages the library ships strings for. */
23
+ export declare const UD_COMPONENTS_TRANSLATIONS: Record<string, UdTranslations>;
24
+ /**
25
+ * The library's strings for one language.
26
+ *
27
+ * Falls back to the base tag, so `fr-CA` gets the French strings rather than
28
+ * none. An unknown language returns nothing at all: shipping English under a
29
+ * label that says otherwise is worse than a visible missing key, because it
30
+ * looks translated.
31
+ */
32
+ export declare function udComponentsTranslationsFor(lang: string): UdTranslations;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ud-components",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "peerDependencies": {
5
5
  "@angular/cdk": ">=19",
6
6
  "@angular/common": ">=19",
package/public-api.d.ts CHANGED
@@ -34,6 +34,8 @@ export * from './lib/button-toggle/button-toggle.component';
34
34
  export * from './lib/preview-container/preview-container.component';
35
35
  export * from './lib/toggle/toggle.component';
36
36
  export * from './lib/toggle-option/toggle-option.component';
37
+ export * from './i18n/ud-components.translations';
38
+ export * from './i18n/ud-components-translate-loader';
37
39
  export * from './enums/feature-flag-key.enum';
38
40
  export * from './enums/loading-status.enum';
39
41
  export * from './enums/application-status.enum';