You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-13Lines changed: 46 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,29 +128,54 @@ let nameAndAge = Tolgee.shared.translate("My name is %@ and I'm %lld years old",
128
128
129
129
### 🔧 SwiftUI Integration
130
130
131
-
Tolgee is designed to work great with SwiftUI and SwiftUI previews.
131
+
Tolgee works great with SwiftUI, including previewing views in different localizations using SwiftUI previews.
132
132
133
+
You can use the `TolgeeText` component which will automatically use the injected locale on iOS 18.4+
133
134
```swift
134
135
importSwiftUI
135
136
importTolgee
136
137
137
138
structContentView: View {
138
-
@Stateprivatevar userName ="Alice"
139
-
@Stateprivatevar itemCount =5
139
+
var body: some View {
140
+
TolgeeText("welcome_title")
141
+
}
142
+
}
143
+
144
+
#Preview("English") {
145
+
ContentView()
146
+
.environment(\.locale, Locale(identifier: "en"))
147
+
}
148
+
149
+
#Preview("Czech") {
150
+
ContentView()
151
+
.environment(\.locale, Locale(identifier: "cs"))
152
+
}
153
+
```
154
+
155
+
or use a version of the `translate` method that accepts `locale` param on iOS 18.4 and newer. The older implementation will fall back to the system language.
Tolgee optionally supports swizzling of `Bundle.localizedString`, which is being used by `NSLocalizedString` function. In order to enable swizzling, set enviromental variable `TOLGEE_ENABLE_SWIZZLING=true` in your scheme settings. Refer to our UIKit example.
211
+
Tolgee optionally supports swizzling of `Bundle.localizedString`, which is being used by `NSLocalizedString` function. In order to enable swizzling, set enviromental variable `TOLGEE_ENABLE_SWIZZLING=true` in your scheme settings. Refer to our UIKit example to see it in action.
187
212
213
+
Following calls will then be backed by the Tolgee SDK:
0 commit comments