feat: locales availability + IE display mode
This commit is contained in:
@@ -28,21 +28,30 @@ module.exports = async (localeCode) => {
|
||||
let lcObj = {}
|
||||
_.forEach(strings, row => {
|
||||
if (_.includes(row.key, '::')) { return }
|
||||
if (_.isEmpty(row.value)) { row.value = row.key }
|
||||
if (_.isEmpty(row.value)) {
|
||||
row.value = row.key
|
||||
}
|
||||
_.set(lcObj, row.key.replace(':', '.'), row.value)
|
||||
})
|
||||
|
||||
const locales = await WIKI.cache.get('locales')
|
||||
if (locales) {
|
||||
const currentLocale = _.find(locales, ['code', localeCode]) || {}
|
||||
await WIKI.models.locales.query().delete().where('code', localeCode)
|
||||
await WIKI.models.locales.query().insert({
|
||||
code: localeCode,
|
||||
strings: lcObj,
|
||||
isRTL: currentLocale.isRTL,
|
||||
name: currentLocale.name,
|
||||
nativeName: currentLocale.nativeName
|
||||
})
|
||||
const existingLocale = await WIKI.models.locales.query().where('code', localeCode)
|
||||
if (existingLocale) {
|
||||
await WIKI.models.locales.query().patch({
|
||||
strings: lcObj
|
||||
}).where('code', localeCode)
|
||||
} else {
|
||||
await WIKI.models.locales.query().insert({
|
||||
code: localeCode,
|
||||
strings: lcObj,
|
||||
isRTL: currentLocale.isRTL,
|
||||
name: currentLocale.name,
|
||||
nativeName: currentLocale.nativeName,
|
||||
availability: currentLocale.availability
|
||||
})
|
||||
}
|
||||
} else {
|
||||
throw new Error('Failed to fetch cached locales list! Restart server to resolve this issue.')
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ module.exports = async () => {
|
||||
query: `{
|
||||
localization {
|
||||
locales {
|
||||
availability
|
||||
code
|
||||
name
|
||||
nativeName
|
||||
@@ -54,7 +55,9 @@ module.exports = async () => {
|
||||
let lcObj = {}
|
||||
_.forEach(strings, row => {
|
||||
if (_.includes(row.key, '::')) { return }
|
||||
if (_.isEmpty(row.value)) { row.value = row.key }
|
||||
if (_.isEmpty(row.value)) {
|
||||
row.value = row.key
|
||||
}
|
||||
_.set(lcObj, row.key.replace(':', '.'), row.value)
|
||||
})
|
||||
|
||||
@@ -63,7 +66,8 @@ module.exports = async () => {
|
||||
strings: lcObj,
|
||||
isRTL: localeInfo.isRTL,
|
||||
name: localeInfo.name,
|
||||
nativeName: localeInfo.nativeName
|
||||
nativeName: localeInfo.nativeName,
|
||||
availability: localeInfo.availability
|
||||
}).where('code', currentLocale)
|
||||
|
||||
WIKI.logger.info(`Pulled latest locale updates for ${localeInfo.name} from Graph endpoint: [ COMPLETED ]`)
|
||||
|
Reference in New Issue
Block a user