Fix format for i18n files in storybook build (#31992)
* fix: correct format for i18n files in storybook build * refactor: rename `json` var to `jsonStr`
This commit is contained in:
@@ -55,12 +55,12 @@ function prepareLangFiles(): LangFileMap {
|
|||||||
function createHashFromFile(lang: string): [filename: string, json: string] {
|
function createHashFromFile(lang: string): [filename: string, json: string] {
|
||||||
const translationsPath = `${I18N_BASE_PATH}${lang}.json`;
|
const translationsPath = `${I18N_BASE_PATH}${lang}.json`;
|
||||||
|
|
||||||
const json = JSON.stringify(fs.readFileSync(translationsPath).toString(), null, 4);
|
const jsonStr = fs.readFileSync(translationsPath).toString();
|
||||||
const jsonBuffer = Buffer.from(json);
|
const jsonBuffer = Buffer.from(jsonStr);
|
||||||
const digest = createHash("sha256").update(jsonBuffer).digest("hex").slice(0, 7);
|
const digest = createHash("sha256").update(jsonBuffer).digest("hex").slice(0, 7);
|
||||||
const filename = `${lang}.${digest}.json`;
|
const filename = `${lang}.${digest}.json`;
|
||||||
|
|
||||||
return [filename, json];
|
return [filename, jsonStr];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user