Skip to content

Commit a2bf9f9

Browse files
authored
Merge pull request #599 from contentstack/bugfix/CMG-589
Bugfix/cmg 589
2 parents 7b0851d + 8eaa7db commit a2bf9f9

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

api/src/services/contentful.service.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -939,16 +939,16 @@ const createLocale = async (packagePath: string, destination_stack_id: string, p
939939
}
940940
const fallbackMapLocales: any = { ...project?.master_locale ?? {}, ...project?.locales ?? {} }
941941
await Promise?.all(locales?.map?.(async (localeData: any) => {
942-
const currentMapLocale = getKeyByValue?.(fallbackMapLocales, localeData?.code) ?? `${localeData.code.toLowerCase()}`;
942+
const currentMapLocale = getKeyByValue?.(fallbackMapLocales, localeData?.code) ?? `${localeData?.code?.toLowerCase?.()}`;
943943
const title = localeData?.sys?.id;
944944
const newLocale: Locale = {
945945
code: currentMapLocale,
946946
name: localeCodes?.[currentMapLocale] || "English - United States",
947947
fallback_locale: getKeyByValue(fallbackMapLocales, localeData?.fallbackCode) ?? '',
948948
uid: `${title}`,
949949
};
950-
951-
if (localeData.default === true) {
950+
const masterLocaleCode = getKeyByValue(project?.master_locale, localeData?.code);
951+
if (masterLocaleCode !== undefined) {
952952
msLocale[title] = newLocale;
953953
const message = getLogMessage(
954954
srcFunc,
@@ -957,16 +957,26 @@ const createLocale = async (packagePath: string, destination_stack_id: string, p
957957
)
958958
await customLogger(projectId, destination_stack_id, 'info', message);
959959
} else {
960-
allLocales[title] = newLocale;
961-
const message = getLogMessage(
962-
srcFunc,
963-
`Locale ${newLocale?.code} has been successfully transformed.`,
964-
{}
965-
)
966-
await customLogger(projectId, destination_stack_id, 'info', message);
960+
if (project?.locales?.[localeData?.code]) {
961+
allLocales[title] = newLocale;
962+
const message = getLogMessage(
963+
srcFunc,
964+
`Locale ${newLocale?.code} has been successfully transformed.`,
965+
{}
966+
)
967+
await customLogger(projectId, destination_stack_id, 'info', message);
968+
}
967969
}
968970
localeList[title] = newLocale;
969971
}));
972+
const masterLocaleData = Object?.values(msLocale)?.[0];
973+
if (masterLocaleData) {
974+
for (const [key, value] of Object.entries(allLocales) ?? {}) {
975+
if (value?.code === masterLocaleData?.fallback_locale) {
976+
allLocales[key].fallback_locale = masterLocaleData?.code
977+
}
978+
}
979+
}
970980
await writeFile(localeSave, LOCALE_FILE_NAME, allLocales)
971981
await writeFile(localeSave, LOCALE_MASTER_LOCALE, msLocale)
972982
await writeFile(localeSave, LOCALE_CF_LANGUAGE, localeList)

upload-api/src/config/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default {
22
plan: {
33
dropdown: { optionLimit: 100 }
44
},
5-
cmsType: 'sitecore',
5+
cmsType: 'contentful',
66
isLocalPath: true,
77
awsData: {
88
awsRegion: 'us-east-2',
@@ -13,5 +13,5 @@ export default {
1313
bucketKey: ''
1414
},
1515
// localPath: '/Users/sayali.joshi/Downloads/contentfulDummyEmbedData.json' //package 45.zip'
16-
localPath: '/Users/umesh.more/Documents/ui-migration/migration-v2-node-server/upload-api/extracted_files/package 45.zip'
16+
localPath: '/Users/umesh.more/Documents/contentful-export-4lcqjk0mwjez-master-2025-03-29T10-14-24.json'
1717
};

0 commit comments

Comments
 (0)