Skip to content

Commit

Permalink
#26114: language change for print button (#388)
Browse files Browse the repository at this point in the history
* #26114: Add language choices into the print button on timetable rendering
  • Loading branch information
e-halinen authored Nov 6, 2023
1 parent fd17a6b commit 090a6f9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/components/timetable/timetable.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,21 @@ const getNotes = (notes, symbols) => {
return parsedNotes;
};

const PrintButton = props => (
<div className={styles.noPrint}>
<button className={styles.printBtn} type="button" onClick={window.print}>
TULOSTA AIKATAULU
</button>
</div>
);
const PrintButton = lang => {
const PRINT_TEXT = {
fi: 'TULOSTA AIKATAULU',
sv: 'SKRIV UT TIDTABEL',
en: 'PRINT SCHEDULE',
};

return (
<div className={styles.noPrint}>
<button className={styles.printBtn} type="button" onClick={window.print}>
{PRINT_TEXT[lang.lang]}
</button>
</div>
);
};

class Timetable extends Component {
constructor(props) {
Expand Down Expand Up @@ -134,7 +142,7 @@ class Timetable extends Component {
<PlatformSymbol platform={this.props.platform} />
)}
</div>
{this.props.showPrintButton ? <PrintButton /> : ''}
{this.props.showPrintButton ? <PrintButton lang={this.props.lang} /> : ''}
</div>
)}
{this.props.showValidityPeriod && (
Expand Down Expand Up @@ -233,6 +241,7 @@ Timetable.defaultProps = {
addressFi: null,
showAddressInfo: true,
showPrintButton: false,
lang: 'fi',
};

Timetable.propTypes = {
Expand Down Expand Up @@ -264,6 +273,7 @@ Timetable.propTypes = {
showAddressInfo: PropTypes.bool,
showPrintButton: PropTypes.bool,
combinedDays: PropTypes.object.isRequired,
lang: PropTypes.string,
};

export default Timetable;
3 changes: 3 additions & 0 deletions src/components/timetable/timetableContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ const propsMapper = mapProps(props => {
hasDepartures: departures.length > 0,
showAddressInfo: props.showAddressInfo,
showPrintButton: props.showPrintButton,
lang: props.lang,
};
});

Expand All @@ -449,6 +450,7 @@ TimetableContainer.defaultProps = {
showStopInformation: false,
showAddressInfo: true,
showPrintButton: false,
lang: 'fi',
};

TimetableContainer.propTypes = {
Expand All @@ -469,6 +471,7 @@ TimetableContainer.propTypes = {
showAddressInfo: PropTypes.bool,
showPrintButton: PropTypes.bool,
combinedDays: PropTypes.object,
lang: PropTypes.string,
};

export default TimetableContainer;

0 comments on commit 090a6f9

Please sign in to comment.