ID:1997205
 
I like when strings look pretty. I especially like it when strings detailing amounts of items can discern whether or not to use the plural form of the noun, such as goose vs geese, or die vs dice.

Most people have strings set up that look something like:
"You have [n] octopi in your bag."

Which, to be fair, 99% of the time will be perfectly okay, but what about that handful of times where n is a 1? "You have 1 octopi in your bag." sounds really weird, so let me show you a very simple way to conjugate plurals dynamically without adding any more lines of code.

This trick uses the inline conditional statement format [condition ? true : false]. A lot of people already know this, but there are likely others out there who don't who might find this interesting injection enlightening and useful.

Now, let's put that into the previous string. These conditionals can fall between braces like any normal variables and expressions.

Now the string becomes: "You have [n] [n == 1 ? "octopus" : "octopi"] in your bag."

And ta-da! Literally the simplest way to make text output more dynamic. I know a short snippet tutorial like this is intended for beginners, but still, as long as someone learns something.
How do I turn off public notifications?
I mean, not to crap on your incredible well-written and generally useful post, but there are text macros, lol.

"You have [n] item\s in your inventory." will accomplish the same thing.

Just... y'know... saying.

I feel mean now.

Here's a flower, I guess.

In response to Rushnut
Well shit. For some reason I couldn't get the \s macro to work, which is why I even used this to begin with.

I guess it's less useful for that than it would be to reconjugate words into their plural forms though, like in my "octopus" to "octopi" example.

Weird why \s wasn't working before. I just tested it again and it's working fine. That just had me super confused.
I have since adjusted it for that exact purpose, actually, where it seems to have actual.
In response to Kats
Kats wrote:
I guess it's less useful for that than it would be to reconjugate words into their plural forms though, like in my "octopus" to "octopi" example.

Well, "octopi" is a completely artificial pluralization in English, anyways. It's unheard of for words to conjugate in a particular language based on the language they're from*. And even if that were the case, octopus comes from Ancient Greek oktṓpous meaning the expected plural would be octopodes from the Ancient Greek nominative plural oktṓpodes.

*Well, this isn't entirely true, but when words do conjugate differently if they're loanwords, usually no distinction is made based on the language they're from.
In response to Popisfizzy
I am so done. Lol.
I have a lib for this that covers most of the general cases.
For what it's worth, the general structure and wording of the tutorial was very well done, and it was very easy to read.

Throw a dart, find a different topic, and please do write another one!
Lol. Thanks Rush. At least I know it's well written, even if not very useful.
Octopussi
In response to Doohl
Doohl wrote:
Octopussi

For the love of God, please. No one Google this trying to search for clever hentai jokes. You don't want any of it! Save yourselves!
In response to Kats
Well it was a tough one, I'll admit, but I still found a way to masturbate to this.