@revenuecat/purchases-js 1.23.0 → 1.23.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.
@@ -56,6 +56,13 @@ export declare interface BrandingAppearance {
56
56
  show_product_description: boolean;
57
57
  }
58
58
 
59
+ declare interface BuildVariablesPerPackageOptions {
60
+ selectedLocale?: string;
61
+ fallbackLocale?: string;
62
+ customTranslations?: CustomTranslations;
63
+ translator?: Translator;
64
+ }
65
+
59
66
  /**
60
67
  * Type containing all information regarding the customer.
61
68
  * @public
@@ -139,6 +146,8 @@ declare type CustomTranslations = {
139
146
  };
140
147
  };
141
148
 
149
+ declare type EmptyString = "";
150
+
142
151
  /**
143
152
  * This object gives you access to all the information about the status
144
153
  * of a user's entitlements.
@@ -350,6 +359,18 @@ export declare interface IdentifyResult {
350
359
  readonly wasCreated: boolean;
351
360
  }
352
361
 
362
+ declare class LocaleTranslations {
363
+ readonly labels: Record<string, string>;
364
+ readonly localeKey: string;
365
+ constructor(labels: Record<string, string> | undefined, localeKey: string);
366
+ private replaceVariables;
367
+ translate(labelId: LocalizationKeys | EmptyString, variables?: TranslationVariables): string | undefined;
368
+ translatePeriod(amount: number, period: PeriodUnit, options?: TranslatePeriodOptions): string | undefined;
369
+ translatePeriodUnit(period: PeriodUnit, options?: TranslatePeriodOptions): string | undefined;
370
+ translatePeriodFrequency(amount: number, period: PeriodUnit, options?: TranslateFrequencyOptions): string | undefined;
371
+ translateDate(date: Date, options?: Intl.DateTimeFormatOptions): string | undefined;
372
+ }
373
+
353
374
  declare enum LocalizationKeys {
354
375
  PeriodsWeek = "periods.week",
355
376
  PeriodsMonth = "periods.month",
@@ -1167,6 +1188,7 @@ export declare class Purchases {
1167
1188
  * @experimental
1168
1189
  * */
1169
1190
  static setPlatformInfo(platformInfo: PlatformInfo): void;
1191
+ /* Excluded from this release type: buildVariablesPerPackage */
1170
1192
  /* Excluded from this release type: getPlatformInfo */
1171
1193
  /**
1172
1194
  * Get the singleton instance of Purchases. It's preferred to use the instance
@@ -1826,6 +1848,58 @@ export declare class Purchases {
1826
1848
  properties?: EventProperties;
1827
1849
  }
1828
1850
 
1851
+ declare interface TranslateFrequencyOptions {
1852
+ useMultipleWords?: boolean;
1853
+ }
1854
+
1855
+ declare interface TranslatePeriodOptions {
1856
+ noWhitespace?: boolean;
1857
+ short?: boolean;
1858
+ }
1859
+
1860
+ /**
1861
+ * Translation variables to be used in the translation.
1862
+ * This class allows you to pass variables to the translate method.
1863
+ * @public
1864
+ * @example Given a label with id `periods.monthPlural` and value `{{amount}} months`. This example will replace the variable `{{amount}}` with the value `10`.
1865
+ * ```typescript
1866
+ * translator.translate('periods.monthPlural', { amount: 10 });
1867
+ * // Output: 10 months
1868
+ * ```
1869
+ */
1870
+ declare type TranslationVariables = Record<string, string | number | undefined | null>;
1871
+
1872
+ declare class Translator {
1873
+ readonly selectedLocale: string;
1874
+ readonly defaultLocale: string;
1875
+ readonly locales: Record<string, LocaleTranslations>;
1876
+ static fallback(): Translator;
1877
+ constructor(customTranslations?: CustomTranslations, selectedLocale?: string, defaultLocale?: string);
1878
+ override(customTranslations: CustomTranslations): void;
1879
+ formatPrice(priceInMicros: number, currency: string): string;
1880
+ /**
1881
+ * Returns the locale in a format that is compatible with other JS libraries.
1882
+ * This is particularly important for zh_Hans and zh_Hant that are instead
1883
+ * represented as zh-Hans and zh-Hant in Intl.DateTimeFormat.
1884
+ */
1885
+ get bcp47Locale(): string;
1886
+ /**
1887
+ * Returns the fallback locale in a format that is compatible with other JS
1888
+ * libraries.
1889
+ * This is particularly important for zh_Hans and zh_Hant that are instead
1890
+ * represented as zh-Hans and zh-Hant in Intl.DateTimeFormat.
1891
+ */
1892
+ get fallbackBcp47Locale(): string;
1893
+ private getLanguageCodeString;
1894
+ private getLocaleInstance;
1895
+ translate(key: LocalizationKeys | EmptyString, variables?: TranslationVariables): string;
1896
+ formatCountry(countryCode: string): string;
1897
+ translatePeriod(amount: number, period: PeriodUnit, options?: TranslatePeriodOptions): string | undefined;
1898
+ translatePeriodUnit(period: PeriodUnit, options?: TranslatePeriodOptions): string | undefined;
1899
+ translatePeriodFrequency(amount: number, period: PeriodUnit, options?: TranslateFrequencyOptions): string | undefined;
1900
+ translateDate(date: Date, options?: Intl.DateTimeFormatOptions): string | undefined;
1901
+ }
1902
+
1829
1903
  /**
1830
1904
  * Error indicating that the SDK was accessed before it was initialized.
1831
1905
  * @public