Skip to content

Commit

Permalink
better handling of language selection when interacting with TEIGarage…
Browse files Browse the repository at this point in the history
… API. Fixes #154
  • Loading branch information
raffazizzi committed Jul 23, 2024
1 parent 5c4dfd0 commit d9358eb
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 22 deletions.
5 changes: 3 additions & 2 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ export function exportOdd() {
}
}

export function exportSchema(format) {
export function exportSchema(format, lang) {
return {
type: EXPORT_SCHEMA,
format
format,
lang
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/DownloadButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class DownloadButton extends Component {
infoHeader: i18n('Generating the Customization'),
infoBody: i18n('geninfo')
})
this.props.downloadSchema(format)
this.props.downloadSchema(format, this.props.language)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/containers/Download.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const mapDispatchToProps = (dispatch) => {
// you don't want it to fire before the customization update is completed.
dispatch(exportOdd())
},
downloadSchema: (type) => {
downloadSchema: (type, lang) => {
console.log(type)
dispatch(updateCustomizationOdd())
dispatch(exportSchema(type))
dispatch(exportSchema(type, lang))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/containers/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const mapDispatchToProps = (dispatch) => {
dispatch(fetchOdd(url)).then((odd) => {
// 1. Convert to JSON via TEIGarage
dispatch(setLoadingStatus(i18n('2/3 Importing customization ODD...')))
dispatch(postToTEIGarage(odd.xml, teigarage.compile_json)).then(() => {
dispatch(postToTEIGarage(odd.xml, teigarage.compile_json(lang))).then(() => {
dispatch(setLoadingStatus(i18n('3/3 Importing full specification source...')))
// 2. Get p5subset.
dispatch(fetchLocalSource(`${datasource}/p5subset.json`))
Expand Down
4 changes: 2 additions & 2 deletions src/containers/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ const mapDispatchToProps = (dispatch) => {
}
},
getNewDocForLang: (data, lang) => {
dispatch(compileWithTEIGarage(data, teigarage['compiled.odd'])).then((compiledOdd) => {
dispatch(postToTEIGarage(compiledOdd, teigarage.json.replace('%3Een%3C', `%3E${lang}%3C`)))
dispatch(compileWithTEIGarage(data, teigarage['compiled.odd'](lang))).then((compiledOdd) => {
dispatch(postToTEIGarage(compiledOdd, teigarage.json(lang)))
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function odd(state = {}, action) {
try {
filename = state.customization.settings.filename
} catch (e) { e }
postToTEIGarage(state.customization.updatedXml, teigarage[action.format])
postToTEIGarage(state.customization.updatedXml, teigarage[action.format](action.lang))
.then((res) => {
const ext = action.format !== 'rnc' ? action.format : 'zip'
fileSaver.saveAs(new Blob([res], {'type': 'text\/xml'}), `${filename}.${ext}`)
Expand Down
28 changes: 15 additions & 13 deletions src/utils/teigarage.js

Large diffs are not rendered by default.

0 comments on commit d9358eb

Please sign in to comment.