WML doesn't know what plural means

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

WML doesn't know what plural means

Post by Helmet »

Hi.

When writing a spoken "message" delivered by a unit, if a unit type that may or may not exist any more is referenced in the message, a coder has to write code to cover the two possible situations: is the unit type there or not there? But a third possibility also needs to be considered: singular or plural.

"Is it safe for my horse?"
"Is it safe for my horses?"

To determine whether or not a word is plural requires counting the units. Ugh.

I suggest that WML be taught how to use plural as a key, so something like this would work:

Code: Select all

            [if] 
                [have_unit]
                    type=Horse
                    plural=yes
                [/have_unit]
                [then]
Another option that might work:

Code: Select all

            [if] 
                [have_unit_plural]
                    type=Horse
                [/have_unit_plural]
                [then]
Or even:

Code: Select all

            [if] 
                [filter_plural]
                    type=Horse
                [/filter_plural]
                [then]
Thanks.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
gnombat
Posts: 706
Joined: June 10th, 2010, 8:49 pm

Re: WML doesn't know what plural means

Post by gnombat »

Doesn't count do basically the same thing? (except count is more powerful)

ConditionalActionsWML#.5Bhave_unit.5D
User avatar
egallager
Posts: 583
Joined: November 19th, 2020, 7:27 pm
Location: Concord, New Hampshire
Contact:

Re: WML doesn't know what plural means

Post by egallager »

So, there's a lot to consider here when taking into account localization, since different languages have different pluralization rules. Here are some links:
https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html
https://perldoc.perl.org/Locale::Maketext::TPJ13
User avatar
octalot
General Code Maintainer
Posts: 786
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: WML doesn't know what plural means

Post by octalot »

We have support for it in Lua. There's no WML tag exposing that, but HttT's Test of the Clans scenario shows how to implement [show_countdown] which sets the WML variable units_to_slay_obj.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: WML doesn't know what plural means

Post by Helmet »

egallager wrote: December 31st, 2022, 7:08 am So, there's a lot to consider here when taking into account localization...
Wow, that article, subtitled "A Localization Horror Story: It Could Happen To You" was interesting (and funny). Within it, toward the bottom, was this quote:

"...concision means that simple common things should be expressible in very few lines...of code..."

I agree with that sentiment. This is exactly why I'd like a simpler method to code dialogue in message tags. Just make it simpler. Anything would help.
octalot wrote: December 31st, 2022, 7:35 am We have support for it in Lua. There's no WML tag exposing that, but HttT's Test of the Clans scenario shows how to implement [show_countdown] which sets the WML variable units_to_slay_obj.
Thanks for the information, and example.

Sometimes it seems to me like WML coders and Lua coders are two different kinds of people.

WML coders are the "peasants," struggling with land, trying to make their code work, milking their dairy cow, while in the adjacent village are found the Lua coders. Yes, they are also peasants struggling with land and milking their dairy cow, but they also have a goat.
gnombat wrote: December 31st, 2022, 6:18 am Doesn't count do basically the same thing? (except count is more powerful)
Oh my goodness. Does that actually work?
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
gnombat
Posts: 706
Joined: June 10th, 2010, 8:49 pm

Re: WML doesn't know what plural means

Post by gnombat »

Helmet wrote: December 31st, 2022, 3:28 pm
gnombat wrote: December 31st, 2022, 6:18 am Doesn't count do basically the same thing? (except count is more powerful)
Oh my goodness. Does that actually work?
Well, I didn't test it, but if you look in mainline campaigns you'll see it's used in a lot of places...
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: WML doesn't know what plural means

Post by Helmet »

gnombat wrote: December 31st, 2022, 3:37 pm Well, I didn't test it, but if you look in mainline campaigns you'll see it's used in a lot of places...
IT WORKS!

Thank you. I did not know about count. It's awesome. Once again, I think I have a useful idea but WML is two steps ahead of me.

Code: Select all

[event]
    name=turn 3
    [if]
        [have_unit]
            type=Nibbler
            count=1
        [/have_unit]
        [then]
            [message]
                speaker=narrator
                message="You see a Nibbler in the lake."
            [/message]
        [/then]
        [elseif]
            [have_unit]
                type=Nibbler
                count=2-100
            [/have_unit]
            [then]
                [message]
                    speaker=narrator
                    message="You see Nibblers in the lake."
                [/message]
            [/then]
        [/elseif]
        [else]
            [message]
                speaker=narrator
                message="You don't see any Nibblers in the lake."
            [/message]
        [/else]
    [/if]
[/event]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
octalot
General Code Maintainer
Posts: 786
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: WML doesn't know what plural means

Post by octalot »

A lot of ActionWML is implemented in Lua - the main difference between [show_countdown] and many other WML tags is that the Lua behind it is in the scenario file, whereas the core ones are in files in the data/lua/ directory.

With that example that's based on count, it's not going to be translatable to languages whose rules for plurals aren't "zero, one, two-or-more".
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: WML doesn't know what plural means

Post by Helmet »

octalot wrote: December 31st, 2022, 6:06 pm A lot of ActionWML is implemented in Lua - the main difference between [show_countdown] and many other WML tags is that the Lua behind it is in the scenario file, whereas the core ones are in files in the data/lua/ directory.
Ah. Thanks for the explanation.
octalot wrote: December 31st, 2022, 6:06 pm With that example that's based on count, it's not going to be translatable to languages whose rules for plurals aren't "zero, one, two-or-more".
Hmm. The obvious solution is to never have more than 1 of anything. Problem solved! :)
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Post Reply