BitBoxSwiss / bitbox-wallet-app

The BitBoxApp for desktop and mobile.
https://bitbox.swiss/app
Apache License 2.0
251 stars 82 forks source link

frontend: migrate to latest i18next and react-i18next #2744

Closed thisconnect closed 2 months ago

thisconnect commented 2 months ago

i18next rewrote its types in latest versions, but defining i18n returnObjects: true does not return the correct type when only specifying a key to an object of translations.

This was used for guide entry component to point to an object that contains title and text for the guide entry.

It is possible to define a CustomTypeOptions with i18next.d.ts to globally returnObjects: true, but this breaks all regular uses of the t function that should return a string.

https://www.i18next.com/overview/typescript#custom-type-options

Added local option for each t funciton that is used for guide entries and remove the global option.

Pluralization is used for native notification of newly detected transactions.

Other changes:

Tested:

thisconnect commented 2 months ago

bundle size (make buildweb) with this change (2c977eed31b07f73ea910a72a98c6a54deb11c60):

build/assets/qr-scanner-worker.min-D85Z9gVD.js                   43.95 kB │ gzip:  10.46 kB
build/assets/index.es-CUkY1k80.js                               135.56 kB │ gzip:  42.10 kB
build/assets/index.es-B73K29DX.js                               200.53 kB │ gzip:  58.87 kB
build/assets/index-BhQ2Ul1b.js                                2,426.26 kB │ gzip: 821.08 kB

bundle size on master (d7187c6fd25492280c278665e008a9f393a51d8c)

build/assets/qr-scanner-worker.min-D85Z9gVD.js                   43.95 kB │ gzip:  10.46 kB
build/assets/index.es-X3690aZ_.js                               135.56 kB │ gzip:  42.10 kB
build/assets/index.es-DEJRUThr.js                               200.53 kB │ gzip:  58.87 kB
build/assets/index-WFghvg_o.js                                2,429.39 kB │ gzip: 820.39 kB
thisconnect commented 2 months ago

rebased

thisconnect commented 2 months ago

rebased