-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bbf11a
commit fa08a60
Showing
4 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/src/main/java/org/sirekanyan/outline/ext/LocalizedString.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.sirekanyan.outline.ext | ||
|
||
import android.content.Context | ||
import androidx.annotation.PluralsRes | ||
import androidx.annotation.StringRes | ||
|
||
fun Context.getString(resource: LocalizedString): String = | ||
when (resource) { | ||
is StringResource -> | ||
resources.getString(resource.id) | ||
is PluralsResource -> | ||
resources.getQuantityString(resource.id, resource.quantity, resource.quantity) | ||
} | ||
|
||
sealed class LocalizedString | ||
|
||
class StringResource(@StringRes val id: Int) : LocalizedString() | ||
|
||
class PluralsResource(@PluralsRes val id: Int, val quantity: Int) : LocalizedString() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters