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

#26114: language change for print button #388

Merged
merged 2 commits into from
Nov 6, 2023
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
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 @@ -408,6 +408,7 @@ const propsMapper = mapProps(props => {
hasDepartures: departures.length > 0,
showAddressInfo: props.showAddressInfo,
showPrintButton: props.showPrintButton,
lang: props.lang,
};
});

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

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

export default TimetableContainer;