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

Internationalize commondatabuilder. #1383

Merged
merged 2 commits into from
May 6, 2020
Merged

Conversation

toolness
Copy link
Collaborator

@toolness toolness commented May 6, 2020

This internationalizes commondatabuilder, allowing us to easily translate strings in Django choices by supplying an internationalizeLabels: true option for entries in common-data/config.ts. It sets this flag for the US State choices and translates New Mexico to Spanish to ensure that it works as expected.

@@ -127,15 +131,23 @@ export function createDjangoChoicesTypescriptFiles(
});
}

function createInternationalizedStringLiteral(value: string): string {
const backtickedValue = "`" + JSON.stringify(value).slice(1, -1) + "`";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhh hopefully this works? We're only ever doing this with trusted data so it shouldn't be a security hazard; if it ever breaks we'll know ASAP and can fix it quickly.

@toolness toolness merged commit a7a4a0f into master May 6, 2020
@toolness toolness deleted the i18n-commondatabuilder branch May 6, 2020 11:06
@toolness toolness mentioned this pull request May 6, 2020
33 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant