Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

WIP: Default translations in app #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
17 changes: 15 additions & 2 deletions client/src/components/HandMarkedPaperBallot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ import {
VotesDict,
withLocale,
YesNoContest,
LocaleMap,
} from '@votingworks/ballot-encoder'

import defaultBallotTranslationStrings from '../data/defaultBallotTranslationStrings.json'

import AppContext from '../contexts/AppContext'

import { DEFAULT_LOCALE } from '../config/globals'
Expand All @@ -38,6 +41,10 @@ import Prose from './Prose'
import Text from './Text'
import HorizontalRule from './HorizontalRule'

const defaultBallotStrings = defaultBallotTranslationStrings as LocaleMap<{
[key: string]: string
}>

const localeDateLong = (dateString: string, locale: string) =>
moment(new Date(dateString)).locale(locale).format('LL')

Expand Down Expand Up @@ -393,9 +400,15 @@ const HandMarkedPaperBallot = ({
const localeElection: OptionalElection = secondaryLocaleCode
? withLocale(election, secondaryLocaleCode)
: undefined
i18n.addResources(DEFAULT_LOCALE, '', election.ballotStrings)
i18n.addResources(DEFAULT_LOCALE, 'translation', {
...defaultBallotStrings[DEFAULT_LOCALE],
...election.ballotStrings,
})
if (localeElection) {
i18n.addResources(secondaryLocaleCode, '', localeElection.ballotStrings)
i18n.addResources(secondaryLocaleCode, 'translation', {
...defaultBallotStrings[secondaryLocaleCode],
...localeElection.ballotStrings,
})
}
const primaryPartyName = getPartyFullNameFromBallotStyle({
ballotStyleId,
Expand Down
52 changes: 52 additions & 0 deletions client/src/data/defaultBallotTranslationStrings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"en-US": {
"Official Ballot": "Official Ballot",
"TEST BALLOT": "TEST BALLOT",
"Yes": "Yes",
"No": "No",
"Precinct": "Precinct",
"Style": "Style",
"Page": "Page",
"Pages": "Pages",
"{{primaryPartyName}} {{electionTitle}}": "{{primaryPartyName}} {{electionTitle}}",
"write-in": "write-in",
"Vote for 1": "Vote for 1",
"Vote for not more than {{ seats }}": "Vote for not more than {{ seats }}",
"voteYesOrNo": "Vote <strong>Yes</strong> or <strong>No</strong>",
"Instructions": "Instructions",
"To vote, use a black pen to completely fill in the oval to the left of your choice.": "To vote, use a black pen to completely fill in the oval to the left of your choice.",
"To Vote for a Write-In": "To Vote for a Write-In",
"To vote for a person not on the ballot, completely fill in the oval to the left of the “write-in” line and print the person’s name on the line.": "To vote for a person not on the ballot, completely fill in the oval to the left of the “write-in” line and print the person’s name on the line.",
"To correct a mistake": "To correct a mistake",
"To make a correction, please ask for a replacement ballot. Any marks other than filled ovals may cause your ballot not to be counted.": "To make a correction, please ask for a replacement ballot. Any marks other than filled ovals may cause your ballot not to be counted.",
"Thank you for voting.": "Thank you for voting.",
"You have reached the end of the ballot. Please review your ballot selections.": "You have reached the end of the ballot. Please review your ballot selections."
},
"es-US": {
"Official Ballot": "Boleta Oficial",
"TEST BALLOT": "BOLETA DE PRUEBA",
"Yes": "Sí",
"No": "No",
"Precinct": "Recinto",
"Style": "Estilo",
"Page": "Página",
"Pages": "Paginas",
"{{primaryPartyName}} {{electionTitle}}": "{{electionTitle}} del {{primaryPartyName}}",
"write-in": "voto por",
"Vote for 1": "Voto por 1",
"Vote for not more than {{ seats }}": "Voto por no más de {{ seats }}",
"voteYesOrNo": "Voto <strong>Sí</strong> o <strong>No</strong>",
"Instructions": "Instrucciones",
"To vote, use a black pen to completely fill in the oval to the left of your choice.": "Para votar, use un bolígrafo negro para rellenar completamente el óvalo a la izquierda de su selección.",
"To Vote for a Write-In": "Para asignar un voto",
"To vote for a person not on the ballot, completely fill in the oval to the left of the “write-in” line and print the person's name on the line.": "Para votar para una persona que no figura en la boleta electoral, rellena completamente el óvalo a la izquierda de la línea de “voto por” y escriba el nombre de la persona en la línea.",
"To correct a mistake": "Para corregir un error",
"To make a correction, please ask for a replacement ballot. Any marks other than filled ovals may cause your ballot not to be counted.": "Para hacer una corrección, solicite una boleta nueva. Cualquier marca que no sea óvalos llenos puede hacer que su boleta no se cuente.",
"Thank you for voting.": "Gracias por votar.",
"You have reached the end of the ballot. Please review your ballot selections.": "Ha llegado al final de la votación. Por favor revise las opciones seleccionadas en su boleta."
},
"other": {
"write-in (description)": "voto por",
"write-in (action)": "Nomino y voto por"
}
}