+
Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.
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

@bumbu

Description

@bumbu

🐛 Bug Report

Only reproes with:

  • fbt.plural with showCount: '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 to collect-fbts script
  • In Example.react.js add fbt(fbt.plural('has', 1, {many: 'have',showCount: 'no'}),'example')
  • Run
    • yarn install in main folder
    • yarn collect-fbts in demo-app
    • yarn 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载