elegantchaos/localization
[comment]: <> (Header Generated by ActionStatus 2.0.6 - 494)
String.localized
We add a read-only localized property to String. Calling it will give you the localized version of the string, if there is one.
String.localized(…)
We also add a localized function to String which allows for simple argument substitution in the localized string.
Pass in a dictionary of keys and substitutions, and any instances of {key} in the localized text will be replaced with the substitution value.
String.localized(count: …)
This variation of the localized function uses one of three variations of the source string as the key when looking up the localized value. Which of the three is used is determined by the value of the count:
- 0: uses key.none - 1: uses key.singular - 2: uses key.plural
This will not be sophisticated enough for all situations, but suffices for many that I've encountered.
Package Metadata
Repository: elegantchaos/localization
Default branch: main
README: README.md