2.1.2 • Published 10 months ago
@preply/react-intl-copycat v2.1.2
1st iteration of Copycat project
See docs for Copycat project (what's Copycat) (from business perspective)
What it does under the hood:
- In Crowdin copywriters replace regular translation with the one with the needed format (see docs above), that is made of tags from rich text formatting
- When PR with translations is opened - we run test, that verifies the correct format of translations with experiments (
/src/translations/trans-with-experiment.test.ts
) In build time,
babel-plugin-react-intl-auto-values-for-copy-with-exp
adds values forvalues
prop toFormattedMessage
React component (defineMessages
way is not supported - it will just use A version), that should handle tags in defined format in runtime. It does it by- adding
import
statement to the file (whereFormattedMessage
is used) from file, where those values are defined, what is specific to each project (at least in 1st iteration of Copycat). Fornode-ssr
it'ssrc/utils/formattedMessageAbTestValues.tsx
. - passing named import to
values
prop (see unit tests for more details) That ☝️allows us to customize per project basis, how - flags are fetched, tracked and passed to needed component
- translation visibility is defined (polyfill is loaded)
- error are logged to Sentry
and don't blow up bundles size (since webpack reuses same source code)
- adding
Runtime requirements
- Have
IntersectionObserver
- natively supported or polyfilled. When polyfilling, it's not mandatory to wait for downloading polyfill to renderFormattedMessage
s in your app - Copycat will wait until'IntersectionObserver' in window
and just then will observe elements and log DWH events.
- polyfilling can be done with
intersection-observer
pkg
Further improvements
- Enhance
FormattedMessage
with values from babel plugin forvalues
prop only for cases where specific translation have experiment. - create flags from prod on stages as well
Scale Copycat to project todo list
- Install package
- Extract flag names from messages
- Fetch all flags for Copycat
- Wrap app with Copycat context (with flag values)
- Polyfill
- IntersectionObserver
- if it's SSR - also DOMParser
- Add babel plugin to build system
- Add tests for translations
0.0.0-beta-2e2dfc8545ec2a95c7130d4341fd709cecce6363
10 months ago
0.0.0-beta-0c7d7ee4ed5046bc914a8dcd4667441c5820e194
10 months ago
0.0.0-beta-70afdbb9086d63f8063b885afabcff904087d33e
11 months ago
2.1.2
4 years ago
2.1.1
4 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.2.2
5 years ago
1.2.1
5 years ago
1.2.0
5 years ago
1.1.4
5 years ago
1.1.3
5 years ago
1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.1
5 years ago