#if DEBUG
Prontalize.instance.debugModus = true
#endif
Prontalize.instance.setup(
apiToken: "api-token",
projectID: "projectID"
)
Always make sure you have a fallback / default localization present in your app's bundle. Especially for strings that are visible on the first screen of your app.
To reload / refresh the bundle:
Prontalize.instance.refresh()
If for some reason you want to disable the live-loaded bundle
Prontalize.instance.isEnabled = false
Or clear the latest downloaded bundle
Prontalize.instance.clearCache()
This text will not update live or on refresh. Only when the view is completely (re)loaded.
struct ContentView: View {
var body: some View {
VStack {
Text("welcome", bundle: .prontalize)
}
}
}
Or just use it somewhere else
let string = NSLocalizedString("welcome", bundle: .prontalize, comment: "")
Using ProntalizeText
will automatically refresh the text value upon refresh
VStack {
ProntalizeText("welcome")
}
If you want to keep using Text
, then add this function to your codebase:
public func Text(_ string: String, pluralCount: Int? = nil) -> ProntalizedText {
return ProntalizedText(string, pluralCount: pluralCount)
}
So this will also work:
VStack {
Text("welcome")
}
For plurals if you want to use live reloading:
VStack {
Text("apples", pluralCount: 3)
// -- or --
PluralText("apples", pluralCount: 3)
}
Using Radon and automatically refreshing the text values.
Run this command after you've updated your localization files
#!/bin/sh
sed -i '' 's/bundle: .module/bundle: .prontalize/g' ./Modules/Common/Sources/Generated/Radon+strings.swift