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

feat(translations): expose Button and Modal translations #1183

Merged
merged 5 commits into from Nov 22, 2021

Conversation

shortcuts
Copy link
Member

Summary

This PR exposes a new translation property to allow translating any raw text or aria-labels of the DocSearch, DocSearchButton and DocSearchModal components.

We probably miss some aria-labels or titles so don't hesitate to point them out

Next steps

Some test cases are context/state based so we need to re-configure Cypress in order to test them.

Motivations

@shortcuts shortcuts self-assigned this Nov 22, 2021
@netlify
Copy link

netlify bot commented Nov 22, 2021

✔️ Deploy Preview for docsearch ready!

🔨 Explore the source changes: 86ba124

🔍 Inspect the deploy log: https://app.netlify.com/sites/docsearch/deploys/619b868e2ae1d30008ce7bdd

😎 Browse the preview: https://deploy-preview-1183--docsearch.netlify.app

@shortcuts
Copy link
Member Author

shortcuts commented Nov 22, 2021

Oops, tests are not in the CI 🤔

edit: good

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 22, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 86ba124:

Sandbox Source
Vanilla Configuration

Copy link
Contributor

@bodinsamuel bodinsamuel left a comment

Choose a reason for hiding this comment

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

LGTM, works fine on my machine 🚀
minor comments

packages/docsearch-react/src/AlgoliaLogo.tsx Outdated Show resolved Hide resolved
...props
}: NoResultsScreenProps) {
const {
noResultsText = 'No results for',
Copy link
Contributor

Choose a reason for hiding this comment

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

Translations is hard, and there is chance that the subject will not be placed at the end of the sentence in every language.

(apply for all of them)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, this spread method does not prevent empty string (but it's an acceptable risk)

Copy link
Member Author

Choose a reason for hiding this comment

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

Translations is hard, and there is chance that the subject will not be placed at the end of the sentence in every language.

Indeed, we might need to provide functions/templates if this become needed in the future

resetButtonTitle = 'Clear the query',
resetButtonAriaLabel = 'Clear the query',
cancelButtonText = 'Cancel',
cancelButtonAriaLabel = 'Cancel',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think most of your buttons are not accessible, not sure it's a good idea to start right now with this random component

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's still good to have a starting point, this could also potentially give user the opportunity to contribute if they want to help us improve the accessibility, wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know much about that topic unfortunately, I just know that it's not as easy as it seems and it might give the wrong idea that others props might be changeable. (or maybe aria should not even be translated)
I would just note that in open issue if we want to give users the opportunity to help

packages/docsearch-react/src/__tests__/api.test.tsx Outdated Show resolved Hide resolved
packages/website/docs/api.mdx Outdated Show resolved Hide resolved
Copy link
Contributor

@bodinsamuel bodinsamuel left a comment

Choose a reason for hiding this comment

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

Let's go

@shortcuts shortcuts merged commit ef13dea into next Nov 22, 2021
@shortcuts shortcuts deleted the feat/translations branch November 22, 2021 13:24
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.

Is it possible to increase the Chinese version?
2 participants