@digitaldefiance/i18n-lib 1.0.6 → 1.0.8

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
@@ -110,3 +110,7 @@ const statusText = i18n.translateEnum(Status, Status.Active, MyLanguages.Spanish
110
110
  ## License
111
111
 
112
112
  MIT
113
+
114
+ ## Repository
115
+
116
+ [https://github.com/Digital-Defiance/i18n-lib](https://github.com/Digital-Defiance/i18n-lib)
@@ -1,8 +1,8 @@
1
1
  import { I18nConfig, I18nContext, EnumLanguageTranslation } from './types';
2
- export declare class I18nEngine<TStringKey extends string, TLanguage extends string> {
2
+ export declare class I18nEngine<TStringKey extends string, TLanguage extends string, TConstants = Record<string, string | number>> {
3
3
  private config;
4
4
  private enumRegistry;
5
- constructor(config: I18nConfig<TStringKey, TLanguage>);
5
+ constructor(config: I18nConfig<TStringKey, TLanguage, TConstants>);
6
6
  translate(key: TStringKey, context: I18nContext<TLanguage>, vars?: Record<string, string | number>, language?: TLanguage, fallbackLanguage?: TLanguage): string;
7
7
  translateEnum<TEnum extends string | number>(enumObj: Record<string, TEnum>, value: TEnum, language: TLanguage): string;
8
8
  registerEnum<TEnum extends string | number>(enumObj: Record<string, TEnum> | Record<string | number, string | number>, translations: EnumLanguageTranslation<TEnum, TLanguage>, enumName: string): void;
package/dist/types.d.ts CHANGED
@@ -4,13 +4,11 @@ export type StringsCollection<TStringKey extends string> = Partial<Record<TStrin
4
4
  export type MasterStringsCollection<TStringKey extends string, TLanguage extends string> = Partial<Record<TLanguage, StringsCollection<TStringKey>>>;
5
5
  export type LanguageCodeCollection<TLanguage extends string> = Partial<Record<TLanguage, string>>;
6
6
  export type EnumTranslationMap<TEnum extends string | number, TLanguage extends string> = Partial<Record<TLanguage, Partial<Record<TEnum, string>>>>;
7
- export interface I18nConfig<TStringKey extends string, TLanguage extends string> {
7
+ export interface I18nConfig<TStringKey extends string, TLanguage extends string, TConstants = Record<string, string | number>> {
8
8
  strings: MasterStringsCollection<TStringKey, TLanguage>;
9
9
  defaultLanguage: TLanguage;
10
10
  languageCodes: LanguageCodeCollection<TLanguage>;
11
- constants?: Record<string, string | number> | {
12
- [key: string]: string | number | RegExp | bigint;
13
- };
11
+ constants?: TConstants;
14
12
  }
15
13
  export interface I18nContext<TLanguage extends string> {
16
14
  language: TLanguage;
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- export declare function replaceVariables(str: string, vars?: Record<string, string | number>, constants?: Record<string, string | number> | {
2
- [key: string]: string | number | RegExp | bigint;
3
- }): string;
1
+ export declare function replaceVariables(str: string, vars?: Record<string, string | number>, constants?: any): string;
4
2
  export declare function isTemplate(key: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/i18n-lib",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Generic i18n library with enum translation support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",