This commit is contained in:
Kevin Sawicki 2016-06-07 15:36:08 -07:00
parent 84960af793
commit d54de73e03

View file

@ -2,11 +2,16 @@ const {ipcRenderer} = require('electron')
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const getExtensionMetadata = () => {
return ipcRenderer.sendSync('CHROME_I18N_MANIFEST', chrome.runtime.id)
}
const getMessagesPath = (language) => { const getMessagesPath = (language) => {
const manifest = ipcRenderer.sendSync('CHROME_I18N_MANIFEST', chrome.runtime.id) const {srcDirectory, default_locale} = getExtensionMetadata()
let messagesPath = path.join(manifest.srcDirectory, '_locales', language, 'messages.json') const localesDirectory = path.join(srcDirectory, '_locales')
let messagesPath = path.join(localesDirectory, language, 'messages.json')
if (!fs.statSyncNoException(messagesPath)) { 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 return messagesPath
} }