@forge/cli-shared 8.15.2-next.3-experimental-72ccdfa → 8.15.2-next.3-experimental-812ca41

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,15 +1,16 @@
1
1
  # @forge/cli-shared
2
2
 
3
- ## 8.15.2-next.3-experimental-72ccdfa
3
+ ## 8.15.2-next.3-experimental-812ca41
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - df6d793: Improve show containers data table view
8
8
  - 7af27e8: Updated wording for install list to match dev console
9
+ - 812ca41: Include dynamic prefixed translation keys in i18n resource bundling
9
10
  - Updated dependencies [beddb18]
10
11
  - Updated dependencies [561036a]
11
12
  - Updated dependencies [b248c8f]
12
- - @forge/manifest@12.1.1-next.1-experimental-72ccdfa
13
+ - @forge/manifest@12.1.1-next.1-experimental-812ca41
13
14
 
14
15
  ## 8.15.2-next.3
15
16
 
@@ -15,6 +15,7 @@ export declare class I18nResourceBundlingService {
15
15
  private createI18nInfoFile;
16
16
  private createI18nInfo;
17
17
  private loadTranslationLookup;
18
+ private extractAllKeysFromTranslationLookup;
18
19
  bundle(modules?: Modules, i18nConfig?: Translations): Promise<I18nResourceBundle>;
19
20
  createFileAccessor(i18nConfig: Translations): I18nResourceFileAccessor;
20
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"i18n-resource-bundling-service.d.ts","sourceRoot":"","sources":["../../src/service/i18n-resource-bundling-service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAOjG,oBAAY,kBAAkB,GAC1B;IACE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;CACd,GACD;IACE,MAAM,EAAE,KAAK,CAAC;CACf,CAAC;AAEN,eAAO,MAAM,0BAA0B,EAAE,kBAAsC,CAAC;AAIhF,aAAK,wBA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,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAWvF,kBAAkB,CAAC,UAAU,EAAE,YAAY,GAAG,wBAAwB;CAuB9E"}
@@ -24,8 +24,12 @@ class I18nResourceBundlingService {
24
24
  }));
25
25
  }
26
26
  async createI18nInfoFile(bundleDirPath, i18nConfig, modules) {
27
- const i18nKeys = (0, i18n_1.extractI18nKeysFromModules)(modules);
27
+ const manifestKeys = (0, i18n_1.extractI18nKeysFromModules)(modules);
28
28
  const translationLookup = await this.loadTranslationLookup(i18nConfig);
29
+ const DYNAMIC_MODULE_I18N_PREFIX = 'dynamic.';
30
+ const allLocaleKeys = this.extractAllKeysFromTranslationLookup(translationLookup);
31
+ const dynamicKeys = allLocaleKeys.filter((key) => key.startsWith(DYNAMIC_MODULE_I18N_PREFIX));
32
+ const i18nKeys = [...new Set([...manifestKeys, ...dynamicKeys])].sort();
29
33
  const i18nInfo = this.createI18nInfo(i18nConfig, i18nKeys, translationLookup);
30
34
  const i18nInfoFilePath = (0, path_1.join)(bundleDirPath, i18n_1.I18N_INFO_FILE_NAME);
31
35
  await fs_1.promises.writeFile(i18nInfoFilePath, JSON.stringify(i18nInfo));
@@ -66,6 +70,29 @@ class I18nResourceBundlingService {
66
70
  }));
67
71
  return Object.fromEntries(results);
68
72
  }
73
+ extractAllKeysFromTranslationLookup(translationLookup) {
74
+ const allKeys = new Set();
75
+ const extractKeys = (obj, prefix = '') => {
76
+ if (!obj || typeof obj !== 'object') {
77
+ return;
78
+ }
79
+ for (const [key, value] of Object.entries(obj)) {
80
+ const fullKey = prefix ? `${prefix}.${key}` : key;
81
+ if (typeof value === 'string') {
82
+ allKeys.add(fullKey);
83
+ }
84
+ else if (typeof value === 'object' && value !== null) {
85
+ extractKeys(value, fullKey);
86
+ }
87
+ }
88
+ };
89
+ for (const localeTranslations of Object.values(translationLookup)) {
90
+ if (localeTranslations && typeof localeTranslations === 'object') {
91
+ extractKeys(localeTranslations);
92
+ }
93
+ }
94
+ return Array.from(allKeys);
95
+ }
69
96
  async bundle(modules, i18nConfig) {
70
97
  if (!modules || !i18nConfig) {
71
98
  return exports.EMPTY_I18N_RESOURCE_BUNDLE;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/cli-shared",
3
- "version": "8.15.2-next.3-experimental-72ccdfa",
3
+ "version": "8.15.2-next.3-experimental-812ca41",
4
4
  "description": "Common functionality for Forge CLI",
5
5
  "author": "Atlassian",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
@@ -12,7 +12,7 @@
12
12
  "generate-graphql-types": "graphql-codegen --config src/graphql/codegen.yml"
13
13
  },
14
14
  "dependencies": {
15
- "@forge/manifest": "12.1.1-next.1-experimental-72ccdfa",
15
+ "@forge/manifest": "12.1.1-next.1-experimental-812ca41",
16
16
  "@forge/util": "2.0.1",
17
17
  "@forge/i18n": "0.0.7",
18
18
  "@sentry/node": "7.106.0",