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

Export locales so consumers can set language without duplicating code #272

Merged
merged 2 commits into from
Jun 17, 2024

Conversation

smorton-planview
Copy link
Contributor

Consumers that want to set DocViewer language to a valid value from AvailableLanguages are currently forced to recreate an array of locales to compare against since AvailableLanguages is a union type and its values are compiled away and not available at run time.

This change aims to export the locales so that consumers can avoid duplicating the locales within their code. The goal would be to use navigator.language.split('-')[0] to produce a valid AvailableLanguages.

src/index.tsx Outdated
@@ -7,5 +7,5 @@ export default DocViewer;
export { DocViewerRenderers } from "./renderers";
export * from "./models";
export * from "./utils/fileLoaders";
export { type AvailableLanguages } from "./i18n";
export { type AvailableLanguages, locales } from "./i18n";
Copy link
Owner

Choose a reason for hiding this comment

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

Ok but with this, we export json files...
We should export smth like Object.keys() of this locales object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Point taken. I have refactored the PR accordingly.

@cyntler cyntler merged commit 7098f53 into cyntler:main Jun 17, 2024
1 check passed
@cyntler
Copy link
Owner

cyntler commented Jun 17, 2024

@smorton-planview Has been merged! Will be delivered with the next release. Thanks!

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.

2 participants