Skip to content

Commit 3de8a5c

Browse files
authored
fix: compatible with lower version node (#732)
1 parent 105e0fd commit 3de8a5c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

utils/getLanguage.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ function getLocale() {
107107
}
108108

109109
async function loadLanguageFile(filePath: string): Promise<Language> {
110-
return (await import(pathToFileURL(filePath).toString(), { with: { type: 'json' } })).default
110+
return await fs.promises.readFile(filePath, 'utf-8').then((data) => {
111+
const parsedData = JSON.parse(data)
112+
if (parsedData) {
113+
return parsedData
114+
}
115+
})
111116
}
112117

113118
export default async function getLanguage(localesRoot: string) {

0 commit comments

Comments
 (0)