This repository was archived by the owner on Nov 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 182
This repository was archived by the owner on Nov 18, 2024. It is now read-only.
fbt.plural manifest is wrong in --react-native-mode #401
Copy link
Copy link
Open
Description
🐛 Bug Report
Only reproes with:
fbt.plural
withshowCount: 'no'
, other plurals will work--react-native-mode
enabled
Running yarn translate-fbts
will throw with
yarn run v1.22.19
$ fbt-translate --translations translations/*.json --jenkins > src/translatedFbts.json
/Users/bumbu/Development/fbt/node_modules/nullthrows/nullthrows.js:9
throw error;
^
Error: Expect `token` to not be null as the metadata has variation mask.
at nullthrows (/Users/bumbu/Development/fbt/node_modules/nullthrows/nullthrows.js:7:15)
at new TranslationBuilder (/Users/bumbu/Development/fbt/packages/babel-plugin-fbt/dist/translate/TranslationBuilder.js:109:23)
at /Users/bumbu/Development/fbt/packages/babel-plugin-fbt/dist/bin/translateUtils.js:113:53
at Array.map (<anonymous>)
at processTranslations (/Users/bumbu/Development/fbt/packages/babel-plugin-fbt/dist/bin/translateUtils.js:113:38)
at /Users/bumbu/Development/fbt/packages/babel-plugin-fbt/dist/bin/translateUtils.js:46:12
at Array.map (<anonymous>)
at processFiles (/Users/bumbu/Development/fbt/packages/babel-plugin-fbt/dist/bin/translateUtils.js:44:45)
at Object.<anonymous> (/Users/bumbu/Development/fbt/packages/babel-plugin-fbt/dist/bin/translate.js:147:15)
at Module._compile (node:internal/modules/cjs/loader:1254:14) {
framesToPop: 1
}
Node.js v18.16.0
To Reproduce
Steps to reproduce the behavior:
- In demo-app/package.json add
--react-native-mode
tocollect-fbts
script - In Example.react.js add
fbt(fbt.plural('has', 1, {many: 'have',showCount: 'no'}),'example')
- Run
yarn install
in main folderyarn collect-fbts
in demo-appyarn translate-fbts
in demo-app
Expected behavior
Should work
Issue
Running yarn collect-fbts
will output following json:
{
"hashToLeaf": {
"7VzaqByBO7Pb/+HbPfOSwg==": {
"text": "have",
"desc": "example"
},
"AdZhIiwu5YM4eTswNtofDQ==": {
"text": "has",
"desc": "example"
}
},
"filepath": "src/example/Example.react.js",
"line_beg": 332,
"col_beg": 19,
"line_end": 338,
"col_end": 7,
"project": "fbt-demo-project",
"jsfbt": {
"t": {
"*": {
"desc": "example",
"text": "have"
},
"_1": {
"desc": "example",
"text": "has"
}
},
"m": [
{
"type": 2 // <<<<<< this is the issue
}
]
}
}
And then inside of TranslationBuilder
we expect that if manifest has a type, is should also have the token. Imho in this case the type shouldn't be added at all , so the issue is in the yarn collect-fbts
step.
Metadata
Metadata
Assignees
Labels
No labels