-
Notifications
You must be signed in to change notification settings - Fork 827
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(i18n): add i18n support #951
Merged
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
ca53310
feat(i18n): add i18n support
f4cdec4
feat(i18n): extending language files
d3d039b
feat(i18n): calendar-header
36aada3
Merge branch 'master' into feat/i18n
gergelyke 42ad35f
docs(i18n): add cta
4c0d09e
feat(i18n): co-locate locale files
d8ef6b2
Merge branch 'master' into feat/i18n
gergelyke bdb6726
fix(i18n): remove unused import
f7ac2f3
feat(i18n): breadcrumb and accordion
03d1973
feat(i18n): buttongrup
2ba26bb
fix(i18n): breadcrumb prop
d72da0d
Merge branch 'master' into feat/i18n
gergelyke f541e2e
feat(i18n): file-uploader
635028d
feat(i18n): modal
b9ff5c9
feat(i18n): pagination
bf02490
feat(i18n): select
46d561c
feat(i18n): toast
4ef8859
Merge branch 'master' into feat/i18n
gergelyke 41e1b78
Merge branch 'master' into feat/i18n
gergelyke 029d327
Merge branch 'master' into feat/i18n
gergelyke cffbcb9
feat(i18n): fix ButtonGroup tests
tajo bd7fb02
Merge branch 'master' into feat/i18n
gergelyke f07ffcd
Merge branch 'master' into feat/i18n
gergelyke 2f971f9
fix(i18n): breadcrumbs
083752e
fix(i18n): test coverage
6ef7e2e
fix(i18n): flow types
a040d5f
docs(i18n): add example
b2c2cff
fix(i18n): update snapshots
c21f011
Merge branch 'master' into feat/i18n
gergelyke 6a0c288
Merge branch 'master' into feat/i18n
gergelyke c353798
fix(i18n): pagination
a2ab15d
docs(i18n): more docs
4ee5e45
Merge branch 'master' into feat/i18n
gergelyke 290357f
Update src/button-group/button-group.js
chasestarr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Copyright (c) 2018 Uber Technologies, Inc. | ||
|
||
This source code is licensed under the MIT license found in the | ||
LICENSE file in the root directory of this source tree. | ||
*/ | ||
// @flow | ||
import * as React from 'react'; | ||
import Code from './code.js'; | ||
|
||
type PropsT = { | ||
src: string, | ||
}; | ||
|
||
const JSONViewer = (props: PropsT) => ( | ||
<Code language="javascript">{JSON.stringify(props.src, null, 2)}</Code> | ||
); | ||
|
||
export default JSONViewer; |
31 changes: 31 additions & 0 deletions
31
documentation-site/pages/getting-started/internationalization.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!-- | ||
Copyright (c) 2018 Uber Technologies, Inc. | ||
|
||
This source code is licensed under the MIT license found in the | ||
LICENSE file in the root directory of this source tree. | ||
--> | ||
|
||
import Example from '../../components/example'; | ||
import Layout from '../../components/layout'; | ||
import JSON from '../../components/json'; | ||
import en_US from 'baseui/locale/en_US.js'; | ||
|
||
import InternationalizationExample from 'examples/internationalization/example.js'; | ||
|
||
export default Layout; | ||
|
||
# Internationalization | ||
|
||
Base UI supports English as the default language. Following the instructions below, you | ||
can use other languages too. | ||
|
||
<Example title="Internationalization example" path="examples/internationalization/example.js"> | ||
<InternationalizationExample /> | ||
</Example> | ||
|
||
## The shape of the locale file | ||
|
||
<JSON src={en_US} /> | ||
|
||
If you'd like to contribute a locale, please send a Pull Request based | ||
on the [en_US](https://github.com/uber-web/baseui/tree/master/src/locale) locale. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
documentation-site/static/examples/internationalization/example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import {LocaleProvider} from 'baseui'; | ||
import {StatefulPagination} from 'baseui/pagination'; | ||
|
||
const localeOverrideHu = { | ||
pagination: { | ||
next: 'Következő', | ||
prev: 'Előző', | ||
preposition: ' ', | ||
}, | ||
}; | ||
|
||
export default () => ( | ||
<LocaleProvider locale={localeOverrideHu}> | ||
<StatefulPagination numPages={10} /> | ||
</LocaleProvider> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Copyright (c) 2018 Uber Technologies, Inc. | ||
This source code is licensed under the MIT license found in the | ||
LICENSE file in the root directory of this source tree. | ||
*/ | ||
// @flow | ||
|
||
export type AccordionLocaleT = {| | ||
collapse: string, | ||
expand: string, | ||
|}; | ||
|
||
const locale = { | ||
collapse: 'Collapse', | ||
expand: 'Expand', | ||
}; | ||
|
||
export default locale; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
Copyright (c) 2018 Uber Technologies, Inc. | ||
This source code is licensed under the MIT license found in the | ||
LICENSE file in the root directory of this source tree. | ||
*/ | ||
// @flow | ||
|
||
export type BreadcrumbLocaleT = {| | ||
ariaLabel: string, | ||
|}; | ||
|
||
const locale = { | ||
ariaLabel: 'Breadcrumbs navigation', | ||
}; | ||
|
||
export default locale; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could context consumer be placed here rather than in the wrapper component? not sure why locale needs to be provided through props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, sadly enyzme does not fully support contexts, so sadly the test framework affected our production code :(
is this correct @tajo ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, this is a workaround for Enzyme. It can't shallow render the
renderProp
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we simply
mount
and avoid the indirection? i've found that code bases grow in puzzling ways when ad hoc refactoring to enable test patternsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, 100%.
We've tried that too, it won't work - I think Vojtech will want to bring up the issues with enzyme, and start a chat on what we can do about it
for now, would you be ok with it as is, and fix it once we figure out what to do with enzyme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for sure - i would personally prefer to remove the test than add the additional indirection, but up to you