From 74bee6ea6e15e82469cc3bb157ed1fefda907dcf Mon Sep 17 00:00:00 2001 From: Beau Smith Date: Tue, 30 Jun 2020 12:07:03 -0700 Subject: [PATCH 1/2] feat: Default translations. --- .../src/components/HandMarkedPaperBallot.tsx | 17 ++++++- .../data/defaultBallotTranslationStrings.json | 48 +++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 client/src/data/defaultBallotTranslationStrings.json diff --git a/client/src/components/HandMarkedPaperBallot.tsx b/client/src/components/HandMarkedPaperBallot.tsx index a8fb945..d8ccd6b 100644 --- a/client/src/components/HandMarkedPaperBallot.tsx +++ b/client/src/components/HandMarkedPaperBallot.tsx @@ -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' @@ -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') @@ -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, diff --git a/client/src/data/defaultBallotTranslationStrings.json b/client/src/data/defaultBallotTranslationStrings.json new file mode 100644 index 0000000..830d3fb --- /dev/null +++ b/client/src/data/defaultBallotTranslationStrings.json @@ -0,0 +1,48 @@ +{ + "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 Yes or No", + "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": "Vote por 1", + "Vote for not more than {{ seats }}": "Vote por no más de {{ seats }}", + "voteYesOrNo": "Vote o No", + "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 completar completamente el óvalo a la izquierda de su elección.", + "To Vote for a Write-In": "Para escribir 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 por una persona que no figura en la boleta electoral, complete por completo el óvalo a la izquierda de la línea de “voto por” e imprima 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 de reemplazo. Cualquier marca que no sean ó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.": "Has llegado al final de la votación. Por favor revise sus selecciones de boleta." + } +} From 75b7af7201db16f9b8ace02770644ef122f6470f Mon Sep 17 00:00:00 2001 From: Beau Smith Date: Tue, 30 Jun 2020 12:48:44 -0700 Subject: [PATCH 2/2] update spanish translations --- .../data/defaultBallotTranslationStrings.json | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/client/src/data/defaultBallotTranslationStrings.json b/client/src/data/defaultBallotTranslationStrings.json index 830d3fb..06f5d43 100644 --- a/client/src/data/defaultBallotTranslationStrings.json +++ b/client/src/data/defaultBallotTranslationStrings.json @@ -25,7 +25,7 @@ "es-US": { "Official Ballot": "Boleta Oficial", "TEST BALLOT": "BOLETA DE PRUEBA", - "Yes": "Sî", + "Yes": "Sí", "No": "No", "Precinct": "Recinto", "Style": "Estilo", @@ -33,16 +33,20 @@ "Pages": "Paginas", "{{primaryPartyName}} {{electionTitle}}": "{{electionTitle}} del {{primaryPartyName}}", "write-in": "voto por", - "Vote for 1": "Vote por 1", - "Vote for not more than {{ seats }}": "Vote por no más de {{ seats }}", - "voteYesOrNo": "Vote o No", + "Vote for 1": "Voto por 1", + "Vote for not more than {{ seats }}": "Voto por no más de {{ seats }}", + "voteYesOrNo": "Voto o No", "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 completar completamente el óvalo a la izquierda de su elección.", - "To Vote for a Write-In": "Para escribir 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 por una persona que no figura en la boleta electoral, complete por completo el óvalo a la izquierda de la línea de “voto por” e imprima el nombre de la persona en la línea.", + "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 de reemplazo. Cualquier marca que no sean óvalos llenos puede hacer que su boleta no se cuente.", + "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.": "Has llegado al final de la votación. Por favor revise sus selecciones de boleta." + "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" } }