Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix printing in languages other than English #4764

Merged
merged 6 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading