MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
11.95k stars 4.89k forks source link

[Feat]: Support i18n placeholder input in Storybook | Fix [object Object] translations #21405

Open digiwand opened 12 months ago

digiwand commented 12 months ago

Describe the bug

i18n placeholder input is not supported in Storybook which results in translations outputting "[Object object]" when placeholder inputs are provided. Supporting this feature will help us have a more accurate representation of the rendered components.

Expected behavior

Current behavior: Storybook TokenAllowance page displays "Spending cap behavior for [object Object]"

Expected behavior: Storybook TokenAllowance page displays "Spending cap behavior for TST"

Screenshots

Screenshot 2023-10-17 at 2 36 32 PM Screenshot 2023-10-17 at 2 55 52 PM Screenshot 2023-10-17 at 2 55 55 PM

Steps to reproduce

  1. run storybook yarn storybook
  2. open a page that passes a second parameter to the t, translation function (placeholder input)
  3. observe "[object Object]" displays instead of expected content

Error messages or log output

No response

Version

11.2.0

Build type

None

Browser

Chrome

Operating system

MacOS

Hardware wallet

No response

Additional context

No response

Severity

No response

garrettbear commented 7 months ago

Looks like this was working as of Jan 23 and then some other changes were made moving around test data. Doesn't appear to be an issue with i18n

digiwand commented 6 months ago

I believe I found the issue. In prod, join is a function. In storybook, it is undefined so we call parts.join('') in storybook which coerces the substitution object into [object Object] and joins this together with the other parts

storybook: Screenshot 2024-04-02 at 6 54 15 PM

screenshot of substitution object in both storybook and prod:

Screenshot 2024-04-02 at 6 34 30 PM