Skip to content

Instantly share code, notes, and snippets.

@bezysoftware
Last active September 9, 2018 08:21
Show Gist options
  • Select an option

  • Save bezysoftware/b9079dc919b7c89a79ac7381f4ff9331 to your computer and use it in GitHub Desktop.

Select an option

Save bezysoftware/b9079dc919b7c89a79ac7381f4ff9331 to your computer and use it in GitHub Desktop.
Plurals designer sample
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