-
Notifications
You must be signed in to change notification settings - Fork 13
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
Implement translations #5
Comments
@felixb-wix does that mean we need to explicitly call |
@felixb-wix all keys are uniq across artifact? |
TL;DR Full answer |
No, we are going to inject that through a higher-order function, which will wrap the default export of the bundle, like this: import { FooEntryPoint } from 'package-foo'
import { BarEntryPoint } from 'package-bar'
import translationsJson from './translations.json'
export default injectTranslations(translationsJson, {
FooEntryPoint,
BarEntryPoint
}) |
Design proposal
All translations will be done through a translation function, which will receive a string key and optional placeholder values, and return formatted translation:
Since retrieval of translated texts is widely used, it should be as laconic as possible.
Consumption
There will be three ways to obtain the translation function:
Pure components connected through
connectWithShell
will get it in props, under the namet
:Directly from the
Shell
object:Through
ShellContext
(useful in a non-connected component):Injection
Assumptions
Proposal
Translation data will be scoped per
Shell
(which means per Entry Point)If translation data is of default structure (defined below), default translation function can be used. For data of custom structure, custom translation function must be used.
myTranslationFunc
must be bound to its dataDefault structure of translation data
The text was updated successfully, but these errors were encountered: