🎨
This commit is contained in:
parent
84960af793
commit
d54de73e03
1 changed files with 8 additions and 3 deletions
|
@ -2,11 +2,16 @@ const {ipcRenderer} = require('electron')
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const getExtensionMetadata = () => {
|
||||
return ipcRenderer.sendSync('CHROME_I18N_MANIFEST', chrome.runtime.id)
|
||||
}
|
||||
|
||||
const getMessagesPath = (language) => {
|
||||
const manifest = ipcRenderer.sendSync('CHROME_I18N_MANIFEST', chrome.runtime.id)
|
||||
let messagesPath = path.join(manifest.srcDirectory, '_locales', language, 'messages.json')
|
||||
const {srcDirectory, default_locale} = getExtensionMetadata()
|
||||
const localesDirectory = path.join(srcDirectory, '_locales')
|
||||
let messagesPath = path.join(localesDirectory, language, 'messages.json')
|
||||
if (!fs.statSyncNoException(messagesPath)) {
|
||||
messagesPath = path.join(manifest.srcDirectory, '_locales', manifest.default_locale, 'messages.json')
|
||||
messagesPath = path.join(localesDirectory, default_locale, 'messages.json')
|
||||
}
|
||||
return messagesPath
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue