Author Topic: Color SetShort + plural english  (Read 3286 times)

Offline Astrum

  • Acquaintance
  • *
  • Posts: 6
    • View Profile
Color SetShort + plural english
« on: July 21, 2007, 02:54:56 pm »
Issue :
knife when using color in the SetShort becomes knifes when grouped

Thoughts:
It looks like this is normally resolved in /secure/sefun/english.c with

234                  case "ff": case "fe":
235                    words[ind] = sprintf("%sves", str[0..x-3]);
236                    return implode(words, " ");

I assume % as the beginning character is causing problems again.
Maybe something like case "\%fe" would help? Or is there another
standard way of resolving this that I'm not aware of?


Offline Tricky

  • BFF
  • ***
  • Posts: 189
  • I like what I code and I code what I like!
    • View Profile
Re: Color SetShort + plural english
« Reply #1 on: July 21, 2007, 05:35:20 pm »
Not quite. %s in the sprintf function is replaced by the variable str[0..x-3]

The problem you are experiencing is because the string being passed to the sefun pluralize is encapsulated within colour tags. For pluralize to work here requires a bit of code voodoo to remove the colour tags, pluralize the string and then replace the colour tags. Not easy.

That is how I analyze the code anyway. :p

Tricky

Offline cecilkilmer

  • Acquaintance
  • *
  • Posts: 24
    • View Profile
    • Minerva
Re: Color SetShort + plural english
« Reply #2 on: July 21, 2007, 06:45:48 pm »
I would have to agree with Tricky on this one.  Specifically, it's looking at the last 2 characters of the string for "ff" or "fe", but it's not finding those, probably because your short ends with "%^RESET%^" so the last 2 characters it sees are "%^" and falls through to the default pluralize case of just tacking on an s to the string (I'm betting the pluralized version you're seeing doesn't have the 's' colored like the rest of the word?

Tricky is correct that to fix it, you will need to remove colors for processing the string, pluralize it, then tack the codes back on.  I'll note this down as an issue to look into fixing for myself and email a patch to Crat.

Offline Astrum

  • Acquaintance
  • *
  • Posts: 6
    • View Profile
Re: Color SetShort + plural english
« Reply #3 on: July 21, 2007, 07:11:05 pm »
Yes, that is right about the ending s being another color. If you leave off the %^RESET%^ it functions correctly aside from the bleeding color. I wonder if the following replacement might work.

                  return implode(words, " ");

                  return implode(words, " " + "%^RESET%^");

Offline cecilkilmer

  • Acquaintance
  • *
  • Posts: 24
    • View Profile
    • Minerva
Re: Color SetShort + plural english
« Reply #4 on: July 21, 2007, 08:48:54 pm »
That's not a good work around, because you'd have to leave the %^RESET%^ off of the short name, so you'll get bleed-through color anytime it's a single object (and extra %^RESET%^'s on strings that don't need them).  I'll take a look into this, along with the bug of strings starting with a color trying to capitalize the % character. :)

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Color SetShort + plural english
« Reply #5 on: July 21, 2007, 09:33:50 pm »
Before anyone starts ripping hair out, please be aware that the pluralize()
sefun is actually commented out of english.c. That code is not what is at
issue. pluralize() in stock DS is actually an efun, and the code for it is in
the driver.

I'll play around a bit with the pluralize() sefun this weekend to see about
a workaround.

-Crat