Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FbtTranslations: add support for modifying registered translations (#208
) Summary: This change adds a new function `getRegisteredTranslations` into `FbtTranslations` which allows us to retrieve registered translations. For convenience, it also adds a new `mergeTranslations` function that allows us to append the translations. Use-case: I have an application with FBT and a design system with its own FBT as well. Unfortunately, registering translations overwrites any translations previously registered so the design system (or the application) cannot register their own translations without conflicting with the other part. One solution could be to get already registered translations and re-register them modified. Another solution is to merge these two translations together. There are many other possible solutions so I am open to suggestions how to make it better. Pull Request resolved: #208 Test Plan: ``` $ yarn jest Translations Using Yarn from /data/users/jwatson/www/scripts/third-party/yarn/yarn yarn run v1.9.0-20180706.1003 $ /data/users/jwatson/www/scripts/intl/js/oss-fbt/__github__/node_modules/.bin/jest Translations PASS fbt-runtime packages/fbt/lib/__tests__/FbtTranslations-test.js ✓ can register and get back translations (8ms) ✓ merges translations with the same locale as expected (3ms) ✓ merges translations with different locales as expected (1ms) ✓ merges translations with the same hash as expected (1ms) Test Suites: 1 passed, 1 total Tests: 4 passed, 4 total Snapshots: 4 passed, 4 total Time: 1.383s Ran all test suites matching /Translations/i. Done in 2.38s. ``` ``` $ yarn 'flow:check' Using Yarn from /data/users/jwatson/www/scripts/third-party/yarn/yarn yarn run v1.9.0-20180706.1003 $ flow check --show-all-errors Found 0 errors Done in 10.50s. ``` Reviewed By: kayhadrin Differential Revision: D27741516 Pulled By: jrwats fbshipit-source-id: 5b89a48157965cf69611e8a004666d6c0daac359
- Loading branch information