Skip to content

Commit d127683

Browse files
✨ feat(format): Modify formatJSON function for i18n workflow
This commit introduces changes to the format.mjs file. The formatJSON function has been modified to handle the i18n workflow. The changes involve setting values in the rawData object based on selectors and checking for the existence of rawData before executing certain code. Changes made: - Modifications to the formatJSON function for i18n workflow The purpose of these changes is to improve the functionality and performance of the i18n workflow in the formatJSON function.
1 parent 51e55ce commit d127683

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

scripts/format.mjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ const formatJSON = async (fileName, checkType) => {
2727
}
2828

2929
// i18n workflow
30-
if (typeof plugin.meta.title === 'string' && typeof plugin.meta.description === 'string') {
31-
let rawData = {};
30+
let rawData = {};
3231

33-
for (const key of config.selectors) {
34-
set(rawData, key, get(plugin, key));
35-
}
32+
for (const key of config.selectors) {
33+
const rawValue = get(plugin, key);
34+
if (rawValue) set(rawData, key, rawValue);
35+
}
3636

37+
if (rawData) {
3738
if (plugin.locale && plugin.locale !== config.entryLocale) {
3839
if (config.outputLocales.includes(plugin.locale)) {
3940
writeFileSync(

0 commit comments

Comments
 (0)