Files
2012-02-21 01:15:00 -05:00

1 line
5.6 KiB
JSON

[{"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303166888.959815, "message": "As in a have a numeric field indicating magnitude, and a choices field indicating type", "group_id": 81, "id": 732724}, {"user_id": 1, "stars": [], "topic_id": 20232, "date_created": 1303167076.429101, "message": "@coderanger I'm not sure but if I had to guess I'd guess you'll have to. But that being said, I have no idea what I'm talking about :)", "group_id": 81, "id": 732757}, {"user_id": 1736, "stars": [{"date_created": 1303167137.1268189, "user_id": 1}], "topic_id": 20232, "date_created": 1303167114.0156269, "message": "/me pings @jezdez - lord of the i18n", "group_id": 81, "id": 732761}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303167333.462744, "message": "Come to think of it I'm not really sure how to do it at all, I guess I have to store a bunch of lambdas around ngettext_lazy and use that to generate the choices and during the lookup", "group_id": 81, "id": 732800}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303166860.6357241, "message": "Is there any way to handle choices= + get_FOO_display() + ngettext()?", "group_id": 81, "id": 732721}, {"user_id": 1736, "stars": [{"date_created": 1303166961.714756, "user_id": 1}], "topic_id": 20232, "date_created": 1303166934.723223, "message": "Do I just have to ignore the get_FOO_display() niceness and write this myself?", "group_id": 81, "id": 732730}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303167035.441328, "message": "@ericflo Is that a star a \"yes, you have to write it yourself\"?", "group_id": 81, "id": 732749}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303167151.123543, "message": "Seems like the kind of thing that should be handled, but I'm not sure how to do it without breaking backwards compat", "group_id": 81, "id": 732765}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303166913.2315421, "message": "The labels for the types are all singular, but I want to do ngettext()-style lookups for pretty printing", "group_id": 81, "id": 732727}, {"user_id": 23244, "stars": [], "topic_id": 20232, "date_created": 1303187965.889667, "message": "Isn't it solvable by using gettext in the choices tuples?", "group_id": 81, "id": 737547}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303194867.4117169, "message": "You need to use lambdas since for the choices attribute you want to force n=1, but for other lookups you want to provide the actual number.", "group_id": 81, "id": 738665}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303194875.6095121, "message": "or at least I can't think of another way to do it", "group_id": 81, "id": 738666}, {"user_id": 213, "stars": [], "topic_id": 20232, "date_created": 1303194686.49564, "message": "@coderanger: Yeah, what @ulmus said, just use ugettext_lazy or ungettext_lazy for the label in the two-tuple.", "group_id": 81, "id": 738651}, {"user_id": 16446, "stars": [], "topic_id": 20232, "date_created": 1303195867.2728839, "message": "@ulmus is right, you should use choices = ( ('value1', _('Label 1')), ('value2', _('Label 2')),)", "group_id": 81, "id": 738773}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303196616.760349, "message": "I'll paste my code when I get to work tomorrow", "group_id": 81, "id": 738854}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303196605.1713991, "message": "That doesn't cover plural forms", "group_id": 81, "id": 738851}, {"user_id": 213, "stars": [], "topic_id": 20232, "date_created": 1303197973.7046511, "message": "@coderanger the choices options by default don't have a concept of quantity, although you could probably hack something. The Choices enumerator could be extended to do that, for example: https://github.com/carljm/django-model-utils/blob/master/model_utils/__init__.py#L64-135", "group_id": 81, "id": 739023}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303236765.0978799, "message": "Not entirely optimal since the ngettext can't change the actual format string, but it is as close as I could get", "group_id": 81, "id": 744651}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303236586.4486921, "message": "class SubscriptionPlan(Model):\n BILLING_TYPES = [\n (BILLING_TYPE_MONTH, lambda n: ungettext_lazy('month', 'months', n)),\n (BILLING_TYPE_DAY, lambda n: ungettext_lazy('day', 'days', n)),\n ]\n\n billing_period = models.PositiveIntegerField(null=True, blank=True)\n billing_period_type = models.SmallIntegerField(choices=[(k, v(1)) for k, v in BILLING_TYPES], default=BILLING_TYPE_MONTH)\n \n @property\n def billing_period_string(self):\n \"\"\"Return a pretty string of the billing period.\"\"\"\n if self.billing_period:\n for type_code, labels in self.BILLING_TYPES:\n if self.billing_period_type == type_code:\n return u'%s %s'%(self.billing_period, labels(self.billing_period))\n else:\n raise ValueError(_('Unknown billing type: %(billing_period_type)s')%{'billing_period_type': self.billing_period_type})\n else:\n return _('Non-recurring')", "group_id": 81, "id": 744620}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303236591.9408269, "message": "That is what I came up with", "group_id": 81, "id": 744624}, {"user_id": 1736, "stars": [], "topic_id": 20232, "date_created": 1303236618.2080531, "message": "The choices still works as expected, but I can also get the correctly pluralized form elsewhere.", "group_id": 81, "id": 744627}]