Skip to content

Commit

Permalink
Merge pull request #4764 from carlobeltrame/fix-print-language
Browse files Browse the repository at this point in the history
Fix printing in languages other than English
  • Loading branch information
carlobeltrame committed Mar 21, 2024
2 parents 290222e + 2ad05d5 commit fb3272a
Show file tree
Hide file tree
Showing 4 changed files with 1,006 additions and 25 deletions.
46 changes: 21 additions & 25 deletions frontend/src/components/print/PrintConfigurator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ import DownloadClientPdfButton from '@/components/print/print-client/DownloadCli
import { getEnv } from '@/environment.js'
import cloneDeep from 'lodash/cloneDeep'
import VueI18n from '../../plugins/i18n/index.js'
import repairConfig from './repairPrintConfig.js'
export default {
name: 'PrintConfigurator',
Expand Down Expand Up @@ -154,14 +155,12 @@ export default {
},
cnf() {
return this.repairConfig(
cloneDeep(
this.$store.getters.getLastPrintConfig(this.camp()._meta.self, {
language: this.lang,
documentName: this.camp().name,
camp: this.camp()._meta.self,
contents: this.defaultContents(),
})
)
this.$store.getters.getLastPrintConfig(this.camp()._meta.self, {
language: this.lang,
documentName: this.camp().name,
camp: this.camp()._meta.self,
contents: this.defaultContents(),
})
)
},
isDev() {
Expand Down Expand Up @@ -249,24 +248,21 @@ export default {
})
},
repairConfig(config) {
if (!config) config = {}
if (!(config.language in VueI18n.availableLocales)) config.language = 'en'
if (!config.documentName) config.documentName = this.camp().name
if (config.camp !== this.camp()._meta.self) config.camp = this.camp()._meta.self
if (typeof config.contents?.map !== 'function') {
config.contents = this.defaultContents()
}
config.contents = config.contents
.map((content) => {
if (!content.type) return null
const component = this.contentComponents[content.type]
if (!component) return null
if (typeof component.repairConfig !== 'function') return content
return component.repairConfig(content, this.camp())
})
.filter((component) => component)
const repairers = Object.fromEntries(
Object.entries(this.contentComponents).map(([componentName, component]) => [
componentName,
component.repairConfig,
])
)
return config
return repairConfig(
config,
this.camp(),
VueI18n.availableLocales,
this.lang,
repairers,
this.defaultContents()
)
},
},
}
Expand Down
Loading

0 comments on commit fb3272a

Please sign in to comment.