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
[here example of changes](https://github.com/ln-12/moko-resources-issue-99/pull/2/files)
148
+
124
149
## Usage
125
150
### Example 1 - simple localization string
126
151
The first step is a create a file `strings.xml` in `commonMain/resources/MR/base` with the following content:
@@ -154,6 +179,33 @@ let string = getMyString().localized()
154
179
```
155
180
Note: `StringDesc` is a multiple-source container for Strings: in StringDesc we can use a resource, plurals, formatted variants, or raw string. To convert `StringDesc` to `String` on Android call `toString(context)` (a context is required for the resources usage), on iOS - call `localized()`.
156
181
182
+
#### MR directly from native side
183
+
Android:
184
+
```kotlin
185
+
val string =MR.strings.my_string.desc().toString(context =this)
186
+
```
187
+
iOS:
188
+
```swift
189
+
let string = MR.strings.my_string.desc().localized()
190
+
```
191
+
192
+
#### Get resourceId for Jetpack Compose / SwiftUI
193
+
Android:
194
+
```kotlin
195
+
val resId =MR.strings.my_string.resourceId
196
+
```
197
+
for example in Compose:
198
+
```kotlin
199
+
text = stringResource(id =MR.strings.email.resourceId)
200
+
```
201
+
202
+
iOS:
203
+
```swift
204
+
LocalizedStringKey(MR.strings.email.resourceId)
205
+
```
206
+
207
+
Note: more info in issue [#126](https://github.com/icerockdev/moko-resources/issues/126).
208
+
157
209
### Example 2 - formatted localization string
158
210
In `commonMain/resources/MR/base/strings.xml` add:
159
211
```xml
@@ -326,6 +378,65 @@ We got autogenerated `MR.fonts.Raleway.italic`, `MR.fonts.Raleway.regular`, `MR.
0 commit comments