"Replies" text is plural when there's one reply
-
Literally unusable in this state
-
-
@hungrier said in "Replies" text is plural when there's one reply:
Literally unusable in this state
@accalia said:
/set sev 6
@server said
Issue severity set to "6 - Pendant"
Issue autoclosed due to issue tracker rules.
Issue autodeleted due to atwood rules.
Have a nice day.
-
I'm glad someone posted about this, because I was going to if nobody else had...
-
@ben_lubar can the text just be changed (back? wasn't it like this before?) to
Replies: {n}
instead of{n} Replies
? Then it'd be correct...(en-us and en-gb would both need to be changed, I'd imagine)
-
@hungrier fun fact: every language has different rules how the noun changes with the count. English is simple - just two cases, 1 and not 1 - but most other languages have way more complicated rules. For example, in Polish, there's one form for 1, another for numbers ending with 2, 3 or 4 except 12, 13 and 14, and another for everything else (including 12, 13 and 14). Have fun localizing that for every supported language!
-
@Gąska said in "Replies" text is plural when there's one reply:
most other languages have way more complicated rules
Most other languages? The various Romance languages don't. Neither does German. Japanese doesn't do number modifiers at all IIRC.
-
@lolwhat said in "Replies" text is plural when there's one reply:
Japanese doesn't do number modifiers at all IIRC.
I believe that's true of all CJK languages
-
@Gąska English has rules about that complex for whether you should add
st
,nd
,rd
orth
to numbers.
-
@lolwhat said in "Replies" text is plural when there's one reply:
@Gąska said in "Replies" text is plural when there's one reply:
most other languages have way more complicated rules
Most other languages? The various Romance languages don't. Neither does German. Japanese doesn't do number modifiers at all IIRC.
All Slavic languages do. Assuming no other Germanic or CJK language has them, it's like 18:10 so far, and we have yet to count Africa, Middle East, India and most other Asian countries.
Maybe it's not most languages. But it's still quite a few. Of course, they aren't a significant userbase of any NodeBB forum, and they're used to their languages being added as an afterthought after all the bikeshedding about shades of grey stops, but still.
-
@Gąska I have a friend who speaks Arabic, and he tells me that it has three rules for plurals: two for male nouns, one for female nouns.
-
@anotherusername said in "Replies" text is plural when there's one reply:
@Gąska English has rules about that complex for whether you should add
st
,nd
,rd
orth
to numbers.Public Shared Function GetOrdinal(ByVal Number As Integer) As String # Accepts an integer, returns the ordinal suffix # Handles special case three digit numbers ending # with 11, 12 or 13 - ie, 111th, 112th, 113th, 211th, et al If CType(Number, String).Length > 2 Then Dim intEndNum As Integer = CType(CType(Number, String). _ Substring(CType(Number, String).Length - 2, 2), Integer) If intEndNum >= 11 And intEndNum <= 13 Then Select Case intEndNum Case 11, 12, 13 Return "th" End Select End If End If If Number >= 21 Then # Handles 21st, 22nd, 23rd, et al Select Case CType(Number.ToString.Substring( Number.ToString.Length - 1, 1), Integer) Case 1 Return "st" Case 2 Return "nd" Case 3 Return "rd" Case 0, 4 To 9 Return "th" End Select Else # Handles 1st to 20th Select Case Number Case 1 Return "st" Case 2 Return "nd" Case 3 Return "rd" Case 4 To 20 Return "th" End Select End If # All cases are covered, but Visual Studio can't detect that due to the weird implementation. Add a return in here to remove the erroneous warning # TODO: create tests and redo this method to be more readable Return "" End Function
that last comment and return were added by me when trying to reduce the number of "not all code paths return a value" warnings that were stopping me from seeing any useful ones
-
@Jaloopa said in "Replies" text is plural when there's one reply:
that last comment and return were added by me when trying to reduce the number of "not all code paths return a value" warnings
Either adding a default case to all of the selects (
// should never happen
, and throw an error or something) or changing their last case to a default case would've also worked, you know.
-
@Jaloopa said in "Replies" text is plural when there's one reply:
All cases are covered, but Visual Studio can't detect that due to the weird implementation.
It could, but given it would involve solving the Halting Problem, I can understand why it doesn't
-
@Jaloopa I just tried a quick one in dotnetfiddle; seems to work without any "not all code paths"
public static string GetOrdinal(int num) { var lastTwo = num % 100; if (lastTwo <= 10 || lastTwo > 20) { var lastOne = lastTwo % 10; switch (lastOne) { case 1: return "st"; case 2: return "nd"; case 3: return "rd"; default: return "th"; } } else { return "th"; } }
Are post streaming and the "Replies" indicator not working so well for anyone else today?
-
@hungrier Has post streaming ever worked properly?
-
@RaceProUK I seem to recall it working pretty well. At least, it was rare to see bunches of posts only stream in after posting a reply, inserted before the reply, but today it seems to be happening all the time.
-
@anotherusername said in "Replies" text is plural when there's one reply:
@Jaloopa said in "Replies" text is plural when there's one reply:
that last comment and return were added by me when trying to reduce the number of "not all code paths return a value" warnings
Either adding a default case to all of the selects (
// should never happen
, and throw an error or something) or changing the last case to a default case would've also worked, you know.Yeah, but I came across that in the middle of a couple of hundred methods I was fixing and was in the mindset of just adding a default return to everything, in part to minimise the chances of changing behaviour in a highly brittle application
-
@RaceProUK said in "Replies" text is plural when there's one reply:
@Gąska I have a friend who speaks Arabic, and he tells me that it has three rules for plurals: two for male nouns, one for female nouns.
What about... ah, fuck it. We don't need any more ...
-
@anotherusername said in "Replies" text is plural when there's one reply:
@Gąska English has rules about that complex for whether you should add
st
,nd
,rd
orth
to numbers.Those are just the last two letters of the ordinal number, so if you can say the word it's easy.
Polish has never seen a complex rule it didn't like.
-
- ending in 1 (except ending in 11):
st
- ending in 2 (except ending in 12):
nd
- ending in 3 (except ending in 13):
rd
- everything else (ending in 0, 4-9, or 11-13):
th
- ending in 1 (except ending in 11):
-
And when you set the Unread pages filter to "new", it still says "there are no unread posts" which is a blatant lie.
-
-
@anotherusername said in "Replies" text is plural when there's one reply:
- ending in 1 (except ending in 11):
st
- ending in 2 (except ending in 12):
nd
- ending in 3 (except ending in 13):
rd
- everything else (ending in 0, 4-9, or 11-13):
th
Yes, I know :)
They come from the ordinal numbers: first, second, third, fourth, etc. so as long as you aren't trying to pronounce it twelvecond or something odd you should be okay.
- ending in 1 (except ending in 11):
-
@coldandtired But I want my elevenst place award!
-
@coldandtired said in "Replies" text is plural when there's one reply:
Polish has never seen a complex rule it didn't like.
But at least pronunciation is straght forward.
-
@Jaloopa said in "Replies" text is plural when there's one reply:
@anotherusername said in "Replies" text is plural when there's one reply:
@Gąska English has rules about that complex for whether you should add
st
,nd
,rd
orth
to numbers.Public Shared Function GetOrdinal(ByVal Number As Integer) As String # Accepts an integer, returns the ordinal suffix # Handles special case three digit numbers ending # with 11, 12 or 13 - ie, 111th, 112th, 113th, 211th, et al If CType(Number, String).Length > 2 Then Dim intEndNum As Integer = CType(CType(Number, String). _ Substring(CType(Number, String).Length - 2, 2), Integer) If intEndNum >= 11 And intEndNum <= 13 Then Select Case intEndNum Case 11, 12, 13 Return "th" End Select End If End If If Number >= 21 Then # Handles 21st, 22nd, 23rd, et al Select Case CType(Number.ToString.Substring( Number.ToString.Length - 1, 1), Integer) Case 1 Return "st" Case 2 Return "nd" Case 3 Return "rd" Case 0, 4 To 9 Return "th" End Select Else # Handles 1st to 20th Select Case Number Case 1 Return "st" Case 2 Return "nd" Case 3 Return "rd" Case 4 To 20 Return "th" End Select End If # All cases are covered, but Visual Studio can't detect that due to the weird implementation. Add a return in here to remove the erroneous warning # TODO: create tests and redo this method to be more readable Return "" End Function
that last comment and return were added by me when trying to reduce the number of "not all code paths return a value" warnings that were stopping me from seeing any useful ones
I didn't know you could do #-comments in VB. Then again, why wouldn't you? You could kill a puppy with VB.
-
@kt_ # comments also work in PHP, somewhat inexplicably.
-
@Arantor said in "Replies" text is plural when there's one reply:
@kt_ # comments also work in PHP, somewhat inexplicably.
#!/usr/bin/php
-
@ben_lubar oh, that makes sense. TIL.
-
@Arantor said in "Replies" text is plural when there's one reply:
@ben_lubar oh, that makes sense. TIL.
No it doesn't. That line is still a special case - it is a comment (and does not generate output) when outside the
<?php ?>
tag.
-
@PleegWat true, I hadn't connected the two together but yeah... the first line is extra special except when it is otherwise special.
The shebang is a voodoo I do not like.
-
@kt_ said in "Replies" text is plural when there's one reply:
I didn't know you could do #-comments in VB
You can't, but the code thing on here doesn't recognise VB even with specific type hints and having individual
'
characters really messes up the syntax highlighting so I replaced them with#
I just rewrote the function because it was pissing me off
If Number Mod 100 >= 11 AndAlso Number Mod 100 <= 13 Then Return "th" End If Select Case Number Mod 10 Case 1 Return "st" Case 2 Return "nd" Case 3 Return "rd" Case Else Return "th" End Select
Ran some tests from 1 to 10000, confirmed the results were all the same, did each test 10000 times and got the average execution time
average time of old method (ms) 9.9897 average time of new method (ms) 0.0054
Kind of micro optimisation reducing the time from <10ms for 10k runs, but look how much faster it is when you don't fuck around with casting to string, taking a substring and casting back to a number
-
@Jaloopa said in "Replies" text is plural when there's one reply:
You can't, but the code thing on here doesn't recognise VB even with specific type hints
I was gonna suggest using
vbscript
, but that activates Markdown mode.And I'm like
-
@Jaloopa said in "Replies" text is plural when there's one reply:
Ran some tests from 1 to 10000, confirmed the results were all the same
Out of morbid curiosity, I tested from -1 to -10000. Three results out of every hundred match between the two methods, those ending in 11, 12 or 13. Everything else is "" in the old method. Everything in the new method is "th", because Mod in VB returns a negative for a negative input (
-102 Mod 10
returns -2), so everything hits theElse
case)both wrong in different ways, however since this is only ever used to get the ordinal of a date (so 1-31), I'm not too worried
-
@Jaloopa said in "Replies" text is plural when there's one reply:
so 1-31
Array lookup! Don't overcomplicate things with code!