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

bugfix/localization-updates #197

Merged
merged 2 commits into from
Feb 12, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/assets/LocalizedStrings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface MasterStringsList extends LocalizedStringsMethods {
search_topic_placeholder: string;
links: string;
events: string;
event_search_results: string;
people: string;
council_data_project: string;
search_municipality_name: string;
Expand All @@ -71,6 +72,31 @@ export interface MasterStringsList extends LocalizedStringsMethods {
en: string;
de: string;
es: string;
date: string;
newest_first: string;
oldest_first: string;
most_relevant_first: string;
closest_match_first: string;
most_relevant: string;
search_results: string;
no_results_found: string;
show_more: string;
legislation_sponsored: string;
menu: string;
persons_voting_record: string;
contact: string;
terms: string;
committee_membership: string;
former_committee_membership: string;
committees: string;
visit_persons_website: string;
alternate: string;
councilmember: string;
member: string;
councilpresident: string;
vice_chair: string;
active: string;
inactive: string;
}

export const strings: MasterStringsList = new LocalizedStrings({
Expand Down
30 changes: 28 additions & 2 deletions src/assets/strings/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const de = {
tools_license_prefix: "Council Data Project werkzeuge sind lizenziert unter ",
styled_using_prefix: "Gestylt mit ",
artwork_provided_by_prefix: "Kunstwerk zur Verfügung gestellt von ",
passed: "Passed",
failed: "Failed",
passed: "Bestanden",
failed: "Fehlgeschlagen",
approve: "Genehmigen",
reject: "Ablehnen",
abstain_approve: "Abstain (Approve)",
Expand All @@ -60,6 +60,32 @@ const de = {
transcript: "Transkript",
agenda: "Agenda",
session: "Sitzung",
date: "Datum",
newest_first: "Neusten zuerst",
oldest_first: "Ältesten zuerst",
most_relevant_first: "Das Wichtigste zuerst",
closest_match_first: "Nächste Übereinstimmung zuerst",
most_relevant: "Relevanteste",
search_results: "Suchergebnisse",
event_search_results: "Ergebnisse der Suche nach Ereignissen",
no_results_found: "Keine Ergebnisse",
show_more: "Zeig mehr...",
legislation_sponsored: "Gesetzgebung gesponsert",
menu: "Speisekarte",
persons_voting_record: "{person_name}s Abstimmungsprotokoll",
contact: "Kontakt",
terms: "Begriffe",
committee_membership: "Ausschussmitgliedschaft",
former_committee_membership: "Ehemalige Ausschussmitgliedschaft",
committees: "Ausschüsse",
visit_persons_website: "Besuchen Sie {person_name}s Website",
alternate: "Wechseln",
councilmember: "Stadtrat/in",
member: "Mitglied",
councilpresident: "Präsident des Rates",
vice_chair: "Stellvertretender Vorsitzender",
active: "aktiv",
inactive: "inaktiv",
};

export default de;
26 changes: 26 additions & 0 deletions src/assets/strings/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,32 @@ const en = {
transcript: "Transcript",
agenda: "Agenda",
session: "Session",
date: "Date",
newest_first: "Newest First",
oldest_first: "Oldest First",
most_relevant_first: "Most relevant first",
closest_match_first: "Closest match first",
most_relevant: "Most relevant",
search_results: "Search Results",
event_search_results: "Event search results",
no_results_found: "No results found",
show_more: "Show more...",
legislation_sponsored: "Legislation Sponsored",
menu: "Menu",
persons_voting_record: "{person_name}'s Voting Record",
contact: "Contact",
terms: "Terms",
committee_membership: "Committee Membership",
former_committee_membership: "Former Committee Membership",
committees: "Committees",
visit_persons_website: "Visit {person_name}'s website",
alternate: "Alternate",
councilmember: "Councilmember",
member: "Member",
councilpresident: "Council President",
vice_chair: "Vice Chair",
active: "active",
inactive: "inactive",
};

export default en;
30 changes: 28 additions & 2 deletions src/assets/strings/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const es = {
tools_license_prefix: "Council Data Project las herramientas tienen licencia bajo ",
styled_using_prefix: "Diseñado usando ",
artwork_provided_by_prefix: "Obra proporcionada por ",
passed: "Passed",
failed: "Failed",
passed: "Pasó",
failed: "Fracasó",
approve: "Aprobar",
reject: "Rechazar",
abstain_approve: "Abstain (Approve)",
Expand All @@ -59,6 +59,32 @@ const es = {
transcript: "Transcripción",
agenda: "Agenda",
session: "Sesión",
date: "Fecha",
newest_first: "Más nuevos primero",
oldest_first: "Más viejos primero",
most_relevant_first: "Más relevante primero",
closest_match_first: "Coincidencia más cercana primero",
most_relevant: "Más relevante",
search_results: "Resultados de la Búsqueda",
event_search_results: "Resultados de Busqueda de Eventos",
no_results_found: "No hay resultados",
show_more: "Mostrar más...",
legislation_sponsored: "Legislación patrocinada",
menu: "Menú",
persons_voting_record: "Registro de votos de {person_name}",
contact: "Contacto",
terms: "Términos",
committee_membership: "Membresía del Comité",
former_committee_membership: "Membresía Anterior del Comité",
committees: "Comités",
visit_persons_website: "Visite el sitio web de {person_name}",
alternate: "Alterno/a",
councilmember: "Concejal/a",
member: "Miembro",
councilpresident: "Presidente/a del Consejo",
vice_chair: "Vicepresidente/a",
active: "activo/a",
inactive: "inactivo/a",
};

export default es;
2 changes: 1 addition & 1 deletion src/components/Cards/PersonCard/PersonCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const PersonCard: FC<PersonCardProps> = ({
<div className="mzp-c-card-content">
<h2 className="mzp-c-card-title">{personName}</h2>
<PersonStatus className={personIsActive ? "cdp-bg-neon-green" : "cdp-bg-dark-grey"}>
{personIsActive ? "active" : "inactive"}
{personIsActive ? strings.active : strings.inactive}
</PersonStatus>
<p className="mzp-c-card-desc">
{seatName} &bull; {seatElectoralArea}
Expand Down
5 changes: 3 additions & 2 deletions src/components/Filters/SelectSorting/SelectSorting.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import { ORDER_DIRECTION } from "../../../networking/constants";

import { SortOption } from "./getSortingText";
import SelectSorting, { SelectSortingProps } from "./SelectSorting";
import { strings } from "../../../assets/LocalizedStrings";

describe("SelectSorting", () => {
let selectSorting: ShallowWrapper<SelectSortingProps>;
const updateMock = jest.fn();
const onPopupCloseMock = jest.fn();
const sortOptions: SortOption[] = [
{ by: "value", order: ORDER_DIRECTION.desc, label: "Most relevant" },
{ by: "date", order: ORDER_DIRECTION.desc, label: "Newest first" },
{ by: "date", order: ORDER_DIRECTION.asc, label: "Oldest first" },
{ by: "date", order: ORDER_DIRECTION.desc, label: strings.newest_first },
{ by: "date", order: ORDER_DIRECTION.asc, label: strings.oldest_first },
];

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Header: FC<HeaderProps> = ({ municipalityName }: HeaderProps) => {
aria-controls="patterns.organisms.navigation.navigation"
onClick={() => setNavigationIsVisible((prev) => !prev)}
>
Menu
{strings.menu}
</HamburgerMenuButton>
<CDPLogo>
<a
Expand Down
18 changes: 11 additions & 7 deletions src/containers/EventsContainer/EventsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ const EventsContainer: FC<EventsContainerProps> = ({
const { firebaseConfig } = useAppConfigContext();

const dateRangeFilter = useFilter<string>({
name: "Date",
name: strings.date,
initialState: { start: "", end: "" },
defaultDataValue: "",
textRepFunction: getDateText,
});
const committeeFilter = useFilter<boolean>({
name: "Committee",
name: strings.committee,
initialState: bodies.reduce((obj, body) => {
obj[body.id as string] = initialSelectedBodies[body.id as string] || false;
return obj;
Expand All @@ -59,7 +59,11 @@ const EventsContainer: FC<EventsContainerProps> = ({
});
const sortFilter = useFilter<string>({
name: "Sort",
initialState: { by: "event_datetime", order: ORDER_DIRECTION.desc, label: "Newest first" },
initialState: {
by: "event_datetime",
order: ORDER_DIRECTION.desc,
label: strings.newest_first,
},
defaultDataValue: "",
textRepFunction: getSortingText,
});
Expand Down Expand Up @@ -134,7 +138,7 @@ const EventsContainer: FC<EventsContainerProps> = ({
} else if (state.error) {
return <FetchCardsStatus>{state.error.toString()}</FetchCardsStatus>;
} else if (state.events.length === 0) {
return <FetchCardsStatus>No events found.</FetchCardsStatus>;
return <FetchCardsStatus>{strings.no_results_found}</FetchCardsStatus>;
} else {
const cards = state.events.map((event) => {
const eventDateTimeStr = event.event_datetime?.toLocaleDateString("en-US", {
Expand Down Expand Up @@ -175,15 +179,15 @@ const EventsContainer: FC<EventsContainerProps> = ({
allBodies={bodies}
filters={[committeeFilter, dateRangeFilter, sortFilter]}
sortOptions={[
{ by: "event_datetime", order: ORDER_DIRECTION.desc, label: "Newest first" },
{ by: "event_datetime", order: ORDER_DIRECTION.asc, label: "Oldest first" },
{ by: "event_datetime", order: ORDER_DIRECTION.desc, label: strings.newest_first },
{ by: "event_datetime", order: ORDER_DIRECTION.asc, label: strings.oldest_first },
]}
handlePopupClose={handlePopupClose}
/>
{fetchEventsResult}
<ShowMoreCards isVisible={state.hasMoreEvents && !state.fetchEvents}>
<button className="mzp-c-button mzp-t-secondary mzp-t-lg" onClick={handleShowMoreEvents}>
<span>Show more events</span>
<span>{strings.show_more}</span>
<Loader inline active={state.showMoreEvents} size="tiny" />
</button>
</ShowMoreCards>
Expand Down
5 changes: 3 additions & 2 deletions src/containers/PersonContainer/ContactPerson.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import H2 from "../../components/Shared/H2";

import colors from "../../styles/colors";
import { fontSizes } from "../../styles/fonts";
import { strings } from "../../assets/LocalizedStrings";

const Contact = styled.div({
"& > address > a:nth-of-type(2)": {
Expand All @@ -33,7 +34,7 @@ const ContactPerson: FC<ContactPersonProps> = ({ person }: ContactPersonProps) =
return (
<Contact>
<H2 hasBorderBottom={true} className="mzp-u-title-xs">
Contact
{strings.contact}
</H2>
{(person.phone || person.email) && (
<address>
Expand Down Expand Up @@ -88,7 +89,7 @@ const ContactPerson: FC<ContactPersonProps> = ({ person }: ContactPersonProps) =
rel="noopener noreferrer"
href={person.website}
>
{`Visit ${person.name}'s website`}
{strings.visit_persons_website.replace("{person_name}", person.name)}
</a>
</>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/containers/PersonContainer/MattersSponsored.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import MatterSponsor from "../../models/MatterSponsor";
import Details from "../../components/Shared/Details";
import H2 from "../../components/Shared/H2";
import Ul from "../../components/Shared/Ul";
import { strings } from "../../assets/LocalizedStrings";

interface MattersSponsoredProps {
mattersSponsored: MatterSponsor[];
Expand All @@ -24,7 +25,7 @@ const MattersSponsored: FC<MattersSponsoredProps> = ({
defaultOpen={false}
summaryContent={
<H2 className="mzp-u-title-xs" isInline={true}>
Legislations Sponsored
{strings.legislation_sponsored}
</H2>
}
hiddenContent={
Expand Down
3 changes: 2 additions & 1 deletion src/containers/PersonContainer/PersonContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { PersonPageData } from "./types";

import { fontSizes } from "../../styles/fonts";
import { screenWidths } from "../../styles/mediaBreakpoints";
import { strings } from "../../assets/LocalizedStrings";

const Person = styled.div({
display: "grid",
Expand Down Expand Up @@ -107,7 +108,7 @@ const PersonContainer = ({
defaultOpen={false}
summaryContent={
<H2 className="mzp-u-title-xs" isInline={true}>
{`${person.name}'s Voting Record`}
{strings.persons_voting_record.replace("{person_name}", person.name)}
</H2>
}
hiddenContent={
Expand Down
11 changes: 6 additions & 5 deletions src/containers/PersonContainer/PersonRoles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import H2 from "../../components/Shared/H2";
import Ul from "../../components/Shared/Ul";

import { fontSizes } from "../../styles/fonts";
import { strings } from "../../assets/LocalizedStrings";

interface CommitteeMembershipProps {
hasBorderBottom: boolean;
Expand All @@ -31,7 +32,7 @@ const CommitteeMembership: FC<CommitteeMembershipProps> = ({
<Ul gap={4}>
{roles.map((role) => (
<li key={role.id}>
<strong>{`${role.title}: `}</strong>
<strong>{`${strings[role.title.toLowerCase()]}: `}</strong>
<Link
to={{
pathname: "/events",
Expand Down Expand Up @@ -77,7 +78,7 @@ const PersonRoles: FC<PersonRolesProps> = ({ councilMemberRoles, allRoles }: Per
defaultOpen={false}
title={
<H2 isInline={true} className="mzp-u-title-xs">
Committees
{strings.committees}
</H2>
}
/>
Expand All @@ -87,7 +88,7 @@ const PersonRoles: FC<PersonRolesProps> = ({ councilMemberRoles, allRoles }: Per
return (
<div>
<H2 hasBorderBottom={true} className="mzp-u-title-xs">
Terms
{strings.terms}
</H2>
<Ul gap={16}>
{termRoles.map((role) => {
Expand All @@ -114,7 +115,7 @@ const PersonRoles: FC<PersonRolesProps> = ({ councilMemberRoles, allRoles }: Per
hasBorderBottom={false}
roles={partitionedNonTermRoles[role.id][0]}
defaultOpen={isCurrentRole}
title="Committee Membership"
title={strings.committee_membership}
/>
</li>
)}
Expand All @@ -124,7 +125,7 @@ const PersonRoles: FC<PersonRolesProps> = ({ councilMemberRoles, allRoles }: Per
hasBorderBottom={false}
roles={partitionedNonTermRoles[role.id][1]}
defaultOpen={!isCurrentRole}
title="Former Committee Membership"
title={strings.former_committee_membership}
/>
</li>
)}
Expand Down