@forge/api 6.4.1-next.0-experimental-9065145 → 6.4.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.
package/CHANGELOG.md CHANGED
@@ -1,13 +1,21 @@
1
1
  # @forge/api
2
2
 
3
- ## 6.4.1-next.0-experimental-9065145
3
+ ## 6.4.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - 6f348d9: Updated i18n.createTranslationFunction and i18n.getTranslations in @forge/api to automatically convert input locales to Forge supported locale codes when applicable. If an unsupported locale is provided, a warning will now be logged to the browser console.
7
8
  - Updated dependencies [c7544d8]
8
9
  - Updated dependencies [7c2186c]
9
10
  - Updated dependencies [0c3a0df]
10
- - @forge/manifest@11.3.0-next.2-experimental-9065145
11
+ - Updated dependencies [bb5cb57]
12
+ - @forge/manifest@11.3.0
13
+
14
+ ## 6.4.1-next.1
15
+
16
+ ### Patch Changes
17
+
18
+ - 6f348d9: Updated i18n.createTranslationFunction and i18n.getTranslations in @forge/api to automatically convert input locales to Forge supported locale codes when applicable. If an unsupported locale is provided, a warning will now be logged to the browser console.
11
19
 
12
20
  ## 6.4.1-next.0
13
21
 
package/out/api/i18n.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { type ForgeSupportedLocaleCode, type GetTranslationsOptions, type GetTranslationsResult } from '@forge/i18n';
1
+ import { type GetTranslationsOptions, type GetTranslationsResult } from '@forge/i18n';
2
2
  export declare const resetTranslationsCache: () => void;
3
- export declare const getTranslations: (locale: ForgeSupportedLocaleCode, options?: GetTranslationsOptions) => Promise<GetTranslationsResult>;
3
+ export declare const getTranslations: (rawLocale: string, options?: GetTranslationsOptions) => Promise<GetTranslationsResult>;
4
4
  export declare type TranslationFunction = (i18nKey: string, defaultValue?: string) => string;
5
- export declare const createTranslationFunction: (locale: ForgeSupportedLocaleCode) => Promise<TranslationFunction>;
5
+ export declare const createTranslationFunction: (rawLocale: string) => Promise<TranslationFunction>;
6
6
  export declare const i18n: {
7
- createTranslationFunction: (locale: ForgeSupportedLocaleCode) => Promise<TranslationFunction>;
8
- getTranslations: (locale: ForgeSupportedLocaleCode, options?: GetTranslationsOptions) => Promise<GetTranslationsResult>;
7
+ createTranslationFunction: (rawLocale: string) => Promise<TranslationFunction>;
8
+ getTranslations: (rawLocale: string, options?: GetTranslationsOptions) => Promise<GetTranslationsResult>;
9
9
  };
10
10
  //# sourceMappingURL=i18n.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/api/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAO3B,MAAM,aAAa,CAAC;AAmDrB,eAAO,MAAM,sBAAsB,QAAO,IAGzC,CAAC;AAEF,eAAO,MAAM,eAAe,WAClB,wBAAwB,YACvB,sBAAsB,KAG9B,QAAQ,qBAAqB,CAE/B,CAAC;AAUF,oBAAY,mBAAmB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AASrF,eAAO,MAAM,yBAAyB,WAAkB,wBAAwB,KAAG,QAAQ,mBAAmB,CAO7G,CAAC;AAQF,eAAO,MAAM,IAAI;wCAfuC,wBAAwB,KAAG,QAAQ,mBAAmB,CAAC;8BAzBrG,wBAAwB,YACvB,sBAAsB,KAG9B,QAAQ,qBAAqB,CAAC;CAuChC,CAAC"}
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/api/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAQ3B,MAAM,aAAa,CAAC;AAmDrB,eAAO,MAAM,sBAAsB,QAAO,IAGzC,CAAC;AAEF,eAAO,MAAM,eAAe,cACf,MAAM,YACR,sBAAsB,KAG9B,QAAQ,qBAAqB,CAG/B,CAAC;AAUF,oBAAY,mBAAmB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AASrF,eAAO,MAAM,yBAAyB,cAAqB,MAAM,KAAG,QAAQ,mBAAmB,CAQ9F,CAAC;AAkBF,eAAO,MAAM,IAAI;2CA1B0C,MAAM,KAAG,QAAQ,mBAAmB,CAAC;iCA1BnF,MAAM,YACR,sBAAsB,KAG9B,QAAQ,qBAAqB,CAAC;CAmDhC,CAAC"}
package/out/api/i18n.js CHANGED
@@ -46,13 +46,15 @@ const resetTranslationsCache = () => {
46
46
  translationsFunctionCache.clear();
47
47
  };
48
48
  exports.resetTranslationsCache = resetTranslationsCache;
49
- const getTranslations = async (locale, options = {
49
+ const getTranslations = async (rawLocale, options = {
50
50
  fallback: true
51
51
  }) => {
52
+ const locale = doEnsureLocale(rawLocale);
52
53
  return await translationsGetter.getTranslations(locale, options);
53
54
  };
54
55
  exports.getTranslations = getTranslations;
55
- const createTranslationFunction = async (locale) => {
56
+ const createTranslationFunction = async (rawLocale) => {
57
+ const locale = doEnsureLocale(rawLocale);
56
58
  let translator = translationsFunctionCache.get(locale);
57
59
  if (!translator) {
58
60
  translator = await createTranslationFunctionImpl(locale);
@@ -61,6 +63,14 @@ const createTranslationFunction = async (locale) => {
61
63
  return translator;
62
64
  };
63
65
  exports.createTranslationFunction = createTranslationFunction;
66
+ const doEnsureLocale = (rawLocale) => {
67
+ const ensuredLocale = (0, i18n_1.ensureLocale)(rawLocale);
68
+ if (!ensuredLocale) {
69
+ console.warn(`The locale "${rawLocale}" is not supported, defaulting to the default locale.`);
70
+ return rawLocale;
71
+ }
72
+ return ensuredLocale;
73
+ };
64
74
  const createTranslationFunctionImpl = async (locale) => {
65
75
  const translator = new i18n_1.Translator(locale, translationsGetter);
66
76
  await translator.init();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/api",
3
- "version": "6.4.1-next.0-experimental-9065145",
3
+ "version": "6.4.1",
4
4
  "description": "Forge API methods",
5
5
  "author": "Atlassian",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
@@ -16,7 +16,7 @@
16
16
  "@atlassian/ari": "^2.199.0",
17
17
  "@atlassian/in-memory-metrics": "0.1.0",
18
18
  "@atlassian/metrics-interface": "4.0.0",
19
- "@forge/runtime": "6.1.1",
19
+ "@forge/runtime": "6.1.2",
20
20
  "@types/node": "20.19.1",
21
21
  "@types/node-fetch": "^2.6.12",
22
22
  "expect-type": "^0.17.3",
@@ -28,7 +28,7 @@
28
28
  "@forge/auth": "0.0.9",
29
29
  "@forge/egress": "2.3.0",
30
30
  "@forge/i18n": "0.0.7",
31
- "@forge/manifest": "^11.3.0-next.2-experimental-9065145",
31
+ "@forge/manifest": "^11.3.0",
32
32
  "@forge/storage": "2.0.3",
33
33
  "headers-utils": "^3.0.2",
34
34
  "minimatch": "^9.0.5"