Last active
September 9, 2018 08:21
-
-
Save bezysoftware/b9079dc919b7c89a79ac7381f4ff9331 to your computer and use it in GitHub Desktop.
Plurals designer sample
This file contains hidden or 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
| public string OrangesOne => ResourceManager.GetString("oranges_one", this.resourceCulture); | |
| public string OrangesFew => ResourceManager.GetString("oranges_few", this.resourceCulture); | |
| public string OrangesOther => ResourceManager.GetString("oranges_other", this.resourceCulture); | |
| public string OrangesWithCount(int count) { | |
| var key = ""; | |
| switch (count) | |
| { | |
| case 1: | |
| // one orange | |
| key = "oranges_one"; | |
| break; | |
| case var c when (c < 5): | |
| // 2 - 4 oranges | |
| key = "oranges_few"; | |
| break; | |
| default: | |
| // 5+ oranges | |
| key = "oranges_other"; | |
| break; | |
| }; | |
| return string.Format(ResourceManager.GetString(key, this.resourceCulture), count); | |
| } | |
| // usage | |
| var text = AppResources.Instance.OrangesWithCount(4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment