-
Notifications
You must be signed in to change notification settings - Fork 47
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
Validate translation word in e2e test #1141
Conversation
Code Climate has analyzed commit 080b08b and detected 0 issues on this pull request. View more on Code Climate. |
✔️ Deploy Preview for mobile-wallet-preview ready! 🔨 Explore the source changes: 080b08b 🔍 Inspect the deploy log: https://app.netlify.com/sites/mobile-wallet-preview/deploys/617253ac1eee370007fd0436 😎 Browse the preview: https://deploy-preview-1141--mobile-wallet-preview.netlify.app/ |
Codecov Report
@@ Coverage Diff @@
## main #1141 +/- ##
==========================================
+ Coverage 89.07% 89.20% +0.12%
==========================================
Files 195 195
Lines 3341 3344 +3
Branches 739 740 +1
==========================================
+ Hits 2976 2983 +7
+ Misses 363 359 -4
Partials 2 2
Continue to review full report at Codecov.
|
Build preview for DeFiChain Wallet is ready! Built with commit c75550c https://expo.io/@defichain/wallet?release-channel=pr-preview-1141 |
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
…lidate-translation-word
A while back I was trying to create a import React, { createContext, PropsWithChildren, useContext } from 'react'
import { TranslateOptions } from 'i18n-js'
import { translate } from './index'
interface TranslateProps {
text: string
scope?: string
options?: TranslateOptions
}
const TranslateContext = createContext<string>(undefined as any)
export function Translate (props: TranslateProps): JSX.Element {
const scope = useContext(TranslateContext)
return (
// TODO: add TestId
<>
{translate(props.scope ?? scope, props.text, props.options)}
</>
)
}
Translate.Context = function (props: PropsWithChildren<{ scope: string }>): JSX.Element {
return (
<TranslateContext.Provider value={props.scope}>
{props.children}
</TranslateContext.Provider>
)
}
export function useTranslate (text: string, options?: TranslateOptions): string {
const scope = useContext(TranslateContext)
return translate(scope, text, options)
} This design creates automatically scoped "Translate Context" (aka your screens/context of where it will appear) and a more natural React-based export function MainView (): JSX.Element {
function Alert (text: string): void {
// Do something with text
}
return (
<ThemedView>
<Translate.Context scope='screens/MainView'>
<Translate text='Title' />
<Translate text='Body' />
<TouchableOpacity onPress={() => {
Alert(useTranslate('Where I must use `string` text'))
}}>
<Translate text='Some Text' scope='screens/AlternativeScope' />
</TouchableOpacity>
</Translate.Context>
</ThemedView>
)
} Translation work is then contextually driven:
Side note: How can we automatically generate the translation mapping? I don't have an answer for that yet. |
Closing this for now, let's re-open another one once we're working on it again |
What kind of PR is this?:
/kind feature
What this PR does / why we need it:
Currently we have 3 language support other than english. In this PR we are laying the foundation to test the translation words. To verify translation we have added e2e test check for all languages
to use this feature here is the steps to use
for eg:
for eg:
Which issue(s) does this PR fixes?:
Fixes #855
Additional comments?:
Developer Checklist: