Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite3db3de

Browse files
committed
fix: handle windows import paths;fixes#727
1 parentf9eae0c commite3db3de

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎utils/getLanguage.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import*asfsfrom'node:fs'
22
import*aspathfrom'node:path'
3+
import{pathToFileURL}from'node:url'
34

45
interfaceLanguageItem{
56
hint?:string
@@ -105,15 +106,20 @@ function getLocale() {
105106
returnlinkLocale(shellLocale.split('.')[0].replace('_','-'))
106107
}
107108

109+
asyncfunctionloadLanguageFile(filePath:string):Promise<Language>{
110+
return(awaitimport(pathToFileURL(filePath).toString(),{with:{type:'json'}})).default
111+
}
112+
108113
exportdefaultasyncfunctiongetLanguage(localesRoot:string){
109114
constlocale=getLocale()
110115

111116
constlanguageFilePath=path.resolve(localesRoot,`${locale}.json`)
112-
constdoesLanguageExist=fs.existsSync(languageFilePath)
117+
constfallbackPath=path.resolve(localesRoot,'en-US.json')
113118

119+
constdoesLanguageExist=fs.existsSync(languageFilePath)
114120
constlang:Language=doesLanguageExist
115-
?(awaitimport(languageFilePath,{with:{type:'json'}})).default
116-
:(awaitimport(path.resolve(localesRoot,'en-US.json'),{with:{type:'json'}})).default
121+
?awaitloadLanguageFile(languageFilePath)
122+
:awaitloadLanguageFile(fallbackPath)
117123

118124
returnlang
119125
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp