Skip to content

Commit

Permalink
apps/livequestions apps/plans: fixed missing translations by moving t…
Browse files Browse the repository at this point in the history
…ranslation strings into variables at top of files in all affected jsx files

Fixes Issues #4150 and #4149 as caused by PR #4126
  • Loading branch information
sabinammm authored and fuzzylogic2000 committed Jan 17, 2022
1 parent d721cd7 commit 05b2a2f
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 50 deletions.
7 changes: 5 additions & 2 deletions meinberlin/apps/livequestions/assets/CategorySelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import django from 'django'
import React from 'react'
import $ from 'jquery' // FIXME needed to run test but file should be refactored to not include jquery

const affiliationStr = django.gettext('Affiliation')
const answeredQuestionsStr = django.gettext('Answered questions will be displayed in the statistics according to the chosen affiliation.')

export default class SelectCategory extends React.Component {
componentDidMount () {
const select = $('#categorySelect')
Expand All @@ -13,9 +16,9 @@ export default class SelectCategory extends React.Component {
<div>
{Object.keys(this.props.category_dict).length > 0 &&
<div className="live_questions__select u-spacer-bottom">
<label htmlFor="categorySelect">{django.gettext('Affiliation')}*</label>
<label htmlFor="categorySelect">{affiliationStr}*</label>
<div className="form-hint">
{django.gettext('Answered questions will be displayed in the statistics according to the chosen affiliation.')}
{answeredQuestionsStr}
</div>
<select
name="categorySelect"
Expand Down
18 changes: 12 additions & 6 deletions meinberlin/apps/livequestions/assets/QuestionBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import InfoBox from './InfoBox'
import Filters from './Filters'
import StatisticsBox from './StatisticsBox'

const selectAffiliationStr = django.gettext('select affiliation')
const informationStr = django.gettext('Information')
const questionsStr = django.gettext('Questions')
const statisticsStr = django.gettext('Statistics')
const displayStr = django.gettext('display on screen')

export default class QuestionBox extends React.Component {
constructor (props) {
super(props)
Expand All @@ -18,7 +24,7 @@ export default class QuestionBox extends React.Component {
filteredQuestions: [],
answeredQuestions: [],
category: '-1',
categoryName: django.gettext('select affiliation'),
categoryName: selectAffiliationStr,
displayNotHiddenOnly: false,
displayOnShortlist: false,
orderedByLikes: false,
Expand Down Expand Up @@ -46,7 +52,7 @@ export default class QuestionBox extends React.Component {
}

setCategory (category) {
const newName = (category === '-1') ? django.gettext('select affiliation') : category
const newName = (category === '-1') ? selectAffiliationStr : category
this.setState({
filterChanged: true,
categoryName: newName,
Expand Down Expand Up @@ -182,7 +188,7 @@ export default class QuestionBox extends React.Component {
aria-controls="tabpanel-information"
aria-expanded="false"
>
{django.gettext('Information')}
{informationStr}
</a>
<a
id="tab-questions"
Expand All @@ -193,7 +199,7 @@ export default class QuestionBox extends React.Component {
aria-controls="tabpanel-questions"
aria-expanded="true"
>
{django.gettext('Questions')}
{questionsStr}
</a>
<a
id="tab-statistics"
Expand All @@ -204,7 +210,7 @@ export default class QuestionBox extends React.Component {
aria-controls="tabpanel-statistics"
aria-expanded="false"
>
{django.gettext('Statistics')}
{statisticsStr}
</a>
</nav>
</div>
Expand Down Expand Up @@ -268,7 +274,7 @@ export default class QuestionBox extends React.Component {
<i className="fas fa-tv fa-stack-2x" aria-label="hidden"> </i>
<i className="fas fa-arrow-up fa-stack-1x" aria-label="hidden"> </i>
</span>
{django.gettext('display on screen')}
{displayStr}
</a>
</div>}
</div>
Expand Down
16 changes: 11 additions & 5 deletions meinberlin/apps/livequestions/assets/QuestionForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import React from 'react'
import { updateItem } from '../../contrib/assets/helpers.js'
import CategorySelect from './CategorySelect'

const askQuestionStr = django.gettext('Here you can ask your question')
const questionStr = django.gettext('Question')
const yourQuestionStr = django.gettext('Your question')
const charsStr = django.gettext(' characters')
const postStr = django.gettext('Post')

export default class QuestionForm extends React.Component {
constructor (props) {
super(props)
Expand Down Expand Up @@ -61,14 +67,14 @@ export default class QuestionForm extends React.Component {
return (
<div className="container">
<form id="id-comment-form" action="" onSubmit={this.addQuestion.bind(this)}>
<h2>{django.gettext('Here you can ask your question')}</h2>
<h2>{askQuestionStr}</h2>
<CategorySelect
onSelect={this.selectCategory.bind(this)}
category_dict={this.props.category_dict}
/>
<label htmlFor="questionTextField">{django.gettext('Question')}*</label>
<label htmlFor="questionTextField">{questionStr}*</label>
<textarea
placeholder={django.gettext('Your question')}
placeholder={yourQuestionStr}
id="questionTextField"
className="form-control"
name="questionTextFieldName"
Expand All @@ -78,15 +84,15 @@ export default class QuestionForm extends React.Component {
value={this.state.question}
maxLength="1000"
/>
<label htmlFor="id-comment-form" className="live_questions__char-count">{this.state.questionCharCount}/1000{django.gettext(' characters')}</label>
<label htmlFor="id-comment-form" className="live_questions__char-count">{this.state.questionCharCount}/1000{charsStr}</label>

<div className="form-check">
<label className="form-check__label">
<input type="checkbox" name="data_protection" id="data_protection_check" required="required" />
{this.getPrivacyPolicyLabelWithLinks()}
</label>
</div>
<input type="submit" value={django.gettext('Post')} className="submit-button" />
<input type="submit" value={postStr} className="submit-button" />
</form>
</div>
)
Expand Down
25 changes: 16 additions & 9 deletions meinberlin/apps/plans/assets/FilterSecondary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ const Typeahead = require('react-bootstrap-typeahead').Typeahead
const FilterRadio = require('./FilterRadio')
const React = require('react')

const searchTitleStr = django.gettext('Search title')
const orgaStr = django.gettext('Organisation')
const enterOrgaNameStr = django.gettext('Enter the name of the organisation')
const participationStr = django.gettext('Participation')
const projectStatStr = django.gettext('Project status')
const showProjectsStr = django.gettext('show projects')

class FilterSecondary extends React.Component {
constructor (props) {
super(props)
Expand Down Expand Up @@ -78,7 +85,7 @@ class FilterSecondary extends React.Component {
className="input-group__input filter-bar__search"
type="text"
id="id-title-search"
placeholder={django.gettext('Search title')}
placeholder={searchTitleStr}
value={this.state.titleSearchChoice}
onChange={this.changeTitleSearch.bind(this)}
/>
Expand All @@ -89,13 +96,13 @@ class FilterSecondary extends React.Component {
>
<i className="fa fa-search" aria-hidden="true" />
</button>
<span className="visually-hidden">{django.gettext('Search title')}
<span className="visually-hidden">{searchTitleStr}
</span>
</label>
{this.props.organisationFilterOnTop &&
<div className="form-group">
<div className="typeahead__input-label">
<h2 className="u-no-margin">{django.gettext('Organisation')}</h2>
<h2 className="u-no-margin">{orgaStr}</h2>
</div>
<span className="typeahead__input-group">
<span className="typeahead__input-group-prepend">
Expand All @@ -111,15 +118,15 @@ class FilterSecondary extends React.Component {
multiple={false}
options={this.props.organisations}
selected={this.state.organisationChoice}
placeholder={django.gettext('Enter the name of the organisation')}
placeholder={enterOrgaNameStr}
/>
</span>
</div>}
<div className="filter-bar__menu-radio-group">
<div className="filter-bar__menu-radio-part">
<FilterRadio
filterId="par"
question={django.gettext('Participation')}
question={participationStr}
chosen={this.state.participationChoice}
choiceNames={this.props.participationNames}
onSelect={this.clickParticipation.bind(this)}
Expand All @@ -128,7 +135,7 @@ class FilterSecondary extends React.Component {
<div className="filter-bar__menu-radio-proj">
<FilterRadio
filterId="sta"
question={django.gettext('Project status')}
question={projectStatStr}
chosen={this.state.statusChoice}
choiceNames={this.props.statusNames}
onSelect={this.clickStatus.bind(this)}
Expand All @@ -138,7 +145,7 @@ class FilterSecondary extends React.Component {
{!this.props.organisationFilterOnTop &&
<div className="form-group">
<div className="typeahead__input-label">
<h2 className="u-no-margin">{django.gettext('Organisation')}</h2>
<h2 className="u-no-margin">{orgaStr}</h2>
</div>
<span className="typeahead__input-group">
<span className="typeahead__input-group-prepend">
Expand All @@ -154,7 +161,7 @@ class FilterSecondary extends React.Component {
multiple={false}
options={this.props.organisations}
selected={this.state.organisationChoice}
placeholder={django.gettext('Enter the name of the organisation')}
placeholder={enterOrgaNameStr}
/>
</span>
</div>}
Expand All @@ -163,7 +170,7 @@ class FilterSecondary extends React.Component {
type="submit"
onClick={this.submitSecondaryFilters.bind(this)}
>
{django.gettext('show projects')}
{showProjectsStr}
</button>
</form>
)
Expand Down
15 changes: 8 additions & 7 deletions meinberlin/apps/plans/assets/PlansList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
const React = require('react')
const Moment = require('moment')

const remainingStr = django.gettext('remaining')
const moreThanStr = django.gettext('More than 1 year remaining')
const participationProjectsStr = django.gettext('Participation projects: ')
const futureParticipationStr = django.gettext('Participation: from ')
const endedParticipationStr = django.gettext('Participation ended. Read result.')
const statusStr = django.gettext('Status: ')
const nothingStr = django.gettext('Nothing to show')

class LazyBackground extends React.Component {
constructor (props) {
super(props)
Expand Down Expand Up @@ -79,8 +87,6 @@ class PlansList extends React.Component {
}

getTimespan (item) {
const remainingStr = django.gettext('remaining')
const moreThanStr = django.gettext('More than 1 year remaining')
const timeRemaining = item.active_phase[1].split(' ')
const daysRemaining = parseInt(timeRemaining[0])
if (daysRemaining > 365) {
Expand Down Expand Up @@ -130,10 +136,6 @@ class PlansList extends React.Component {

renderListItem (item, i) {
const statusClass = (item.participation_active === true) ? 'participation-tile__status-active' : 'participation-tile__status-inactive'
const participationProjectsStr = django.gettext('Participation projects: ')
const futureParticipationStr = django.gettext('Participation: from ')
const endedParticipationStr = django.gettext('Participation ended. Read result.')
const statusStr = django.gettext('Status: ')
return (
<li
className={this.props.isHorizontal ? 'participation-tile__horizontal' : 'participation-tile__vertical'}
Expand Down Expand Up @@ -249,7 +251,6 @@ class PlansList extends React.Component {

renderList () {
const list = []
const nothingStr = django.gettext('Nothing to show')
this.props.items.forEach((item, i) => {
list.push(this.renderListItem(item, i))
})
Expand Down
19 changes: 13 additions & 6 deletions meinberlin/apps/plans/assets/PlansMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import { withCookies } from 'react-cookie'
import PopUp from './PopUp'
import { maps } from 'adhocracy4'
import 'leaflet.markercluster'

const addressSearchStr = django.gettext('Address search')
const addressSearchCapStr = django.gettext('Address Search')
const nothingStr = django.gettext('Nothing to show')
const closeInfoBoxStr = django.gettext('Close information box')
const projectsNotShownStr = django.gettext('Projects without spacial reference are not shown on the map. Please have a look at the project list.')

const L = window.L
const $ = window.$

Expand Down Expand Up @@ -264,10 +271,10 @@ class PlansMap extends Component {
name="search"
type="search"
id="id-map-search"
placeholder={django.gettext('Address Search')}
placeholder={addressSearchCapStr}
/>
<button className="input-group__after input-group__after--search btn btn--light" type="submit" title={django.gettext('Address search')}>
<i className="fas fa-search" aria-label={django.gettext('Address search')} />
<button className="input-group__after input-group__after--search btn btn--light" type="submit" title={addressSearchStr}>
<i className="fas fa-search" aria-label={addressSearchStr} />
</button>
</label>

Expand All @@ -290,15 +297,15 @@ class PlansMap extends Component {

{this.state.displayError &&
<ul aria-labelledby="id_filter_address" className="map-list-combined__map__search__error">
<li>{django.gettext('Nothing to show')}</li>
<li>{nothingStr}</li>
</ul>}

</form>
</div>
{this.state.showInfoBox &&
<div className="map-infobox">
<button className="infobox__close" id="close" aria-label={django.gettext('Close information box')} onClick={this.closeInfoBox.bind(this)}><i className="fa fa-times" /></button>
<i className="fa fa-info-circle" aria-hidden="true" /><span>{django.gettext('Projects without spacial reference are not shown on the map. Please have a look at the project list.')}</span>
<button className="infobox__close" id="close" aria-label={closeInfoBoxStr} onClick={this.closeInfoBox.bind(this)}><i className="fa fa-times" /></button>
<i className="fa fa-info-circle" aria-hidden="true" /><span>{projectsNotShownStr}</span>
</div>}
</div>
)
Expand Down
22 changes: 15 additions & 7 deletions meinberlin/apps/plans/assets/PopUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ const React = require('react')
const $ = require('jquery')
const Moment = require('moment')

const moreThanStr = django.gettext('More than 1 year remaining')
const remainingStr = django.gettext('remaining')
const futureParticipationStr = django.gettext('Participation: from ')
const endedParticipationStr = django.gettext('Participation ended. Read result.')
const superordProjectStr = django.gettext('Superordinate project: ')
const participationProjectsStr = django.gettext('Participation projects: ')
const participationStr = django.gettext('Participation: ')

class PopUp extends React.Component {
escapeHtml (unsafe) {
return $('<div>').text(unsafe).html()
Expand All @@ -17,19 +25,19 @@ class PopUp extends React.Component {
const daysRemaining = parseInt(timeRemaining[0])
if (daysRemaining > 365) {
return (
<span>{django.gettext('More than 1 year remaining')}</span>
<span>{moreThanStr}</span>
)
} else {
return (
<span>{django.gettext('remaining')} {this.props.item.active_phase[1]}</span>
<span>{remainingStr} {this.props.item.active_phase[1]}</span>
)
}
}

getTranslation () {
let newDate = Date.parse(this.props.item.future_phase.replace(/ /g, 'T'))
newDate = Moment(newDate).format('DD.MM.YYYY')
return django.gettext('Participation: from ') + newDate
return futureParticipationStr + newDate
}

renderTopics () {
Expand Down Expand Up @@ -65,11 +73,11 @@ class PopUp extends React.Component {
</div>}
{this.props.item.past_phase && !this.props.item.active_phase && !this.props.item.future_phase &&
<div className="maplist-item-popup__status status-bar__past">
<span className="maplist-item-popup__status">{django.gettext('Participation ended. Read result.')}</span>
<span className="maplist-item-popup__status">{endedParticipationStr}</span>
</div>}
{this.props.item.plan_url &&
<div className="maps-popups-popup-name maplist-item-popup__proj-plan">
<span className="maplist-popup-item__roofline">{django.gettext('Superordinate project: ')}</span>
<span className="maplist-popup-item__roofline">{superordProjectStr}</span>
<br />
<a href={this.props.item.plan_url}>{this.props.item.plan_title}</a>
</div>}
Expand All @@ -85,11 +93,11 @@ class PopUp extends React.Component {
</div>
<div className="maplist-popup-item__stats">
<span className="maplist-item-popup__proj-count">
<i className="fas fa-th" />{django.gettext('Participation projects: ')}
<i className="fas fa-th" />{participationProjectsStr}
</span>
<span>{this.props.item.published_projects_count}</span>
<br />
<span className="maplist-item-popup__status"><i className="fas fa-clock" />{django.gettext('Participation: ')}</span>
<span className="maplist-item-popup__status"><i className="fas fa-clock" />{participationStr}</span>
<span className={statusClass}>{this.props.item.participation_string}</span>
</div>
</div>
Expand Down
Loading

0 comments on commit 05b2a2f

Please sign in to comment.