Anyone found a replacement for react-native-fbt for both iOS and Android
#62
-
|
As pointed out here, it is essential to have the JSON locale files on the native side for both Android and iOS. I'm looking to replace We have an Android version here, but for iOS, have you had any luck finding one? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
The article says that bundling locales leads to increased app size, slower app startup and higher memory usage. This was certainly true in the past when using JSC with React Native. However, with Hermes this is no longer true for app startup and memory usage. If you import translations via ESM, they will be stored in the bundle using a random access/lazy memory layout and will only be loaded into memory and affect app startup if you actually load them. If you lazy load them in JS, they will not affect app startup or memory usage. They do lead to increased app size, which is not usually a concern for most apps unless your app is large and you have many locales. In that case, my recommendation is to do what we do on web: fetch translations lazily from a CDN. That way you don't need any native integration. However, I recognize that there is a need for some apps to support native localization providers. fbtee is happy to provide APIs to support such integrations, but we will not be building them ourselves. |
Beta Was this translation helpful? Give feedback.
In the end, as you said, using
require()loads only the current locale's JSON file. I'll surely do some profiling later, but it sounds less problematic than expected.For iOS, I was fortunate since we already had something similar to react-native-fbt here in our code, so I copied the exact translation from the JS to xx-XX.lproj folders. In other words, I adapted this FBT script to use the fbtee translation command with
--jenkins(I encountered a problem with stdout, issue incoming...).For me, the case is closed!
Thanks for your quick feedback!