-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 增加runtimeLocale函数 对Modal,Pagination,RichEditor,VideoViewer完成多语言改造
- Loading branch information
1 parent
8f0c374
commit 691c72b
Showing
15 changed files
with
812 additions
and
611 deletions.
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 |
---|---|---|
@@ -1,14 +1,32 @@ | ||
import React from 'react' | ||
|
||
import { Provider } from './Context'; | ||
import { getLocale } from './Consumer'; | ||
|
||
let runtimeLocale = {}; | ||
|
||
export function getRuntimeLocale(componentName) { | ||
return runtimeLocale[componentName] || {}; | ||
} | ||
|
||
// 部分组件如Modal 可以通过函数式调用 所以需要runtimeLocale提供支撑 | ||
export function changeRuntimeLocale(LocaleValue = 'en_US') { | ||
runtimeLocale = getLocale(LocaleValue); | ||
}; | ||
|
||
export default (props: { | ||
value: { | ||
Locale: string, | ||
} | ||
children?: React.ReactNode | ||
}) => { | ||
const renderProvider = () => { | ||
changeRuntimeLocale(props.value && props.value.Locale); | ||
return props.children | ||
} | ||
return <Provider value={props.value}> | ||
{props.children} | ||
{ | ||
renderProvider() | ||
} | ||
</Provider> | ||
}; |
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
Oops, something went wrong.