[RPGXP] ForeverZer0's Localization script compatible with choices + \n code in files.

ForeverZer0'S Localization script is an awesome script that replaces correctly the text to a translated version with a code, the only two problems are though that choices windows aren't compatible with it, and the \n command in the translation files doesn't work, forcing me to create a different translation code for each line.

So, yeah. Is it possible to add those features?
Are you using some custom message script? Choices work for me. I can imagine if the choices are drawn character-by-character that the localization script wouldn't work.

I'd have to take another look at the newline character for Show Message. I apparently had implemented a snippet for a user in that thread, but it was for VXA. In XP, newlines help the event interpreter know how many lines the message will take in the message box. This lets it know whether it has enough space to fit choices or a number input alongside the previous message.

Outside of that though, it should be as simple as replacing with
Code:
  def self.localize(string)
    if string != nil
      s = string.gsub(/\\[Ll][Oo][Cc]\[(.+)\]/) { self.read($1) }
      s.gsub!("\\n", "\n")
      s
    end
  end
Are you using some custom message script? Choices work for me. I can imagine if the choices are drawn character-by-character that the localization script wouldn't work.

I'd have to take another look at the newline character for Show Message. I apparently had implemented a snippet for a user in that thread, but it was for VXA. In XP, newlines help the event interpreter know how many lines the message will take in the message box. This lets it know whether it has enough space to fit choices or a number input alongside the previous message.

Outside of that though, it should be as simple as replacing with
Code:
  def self.localize(string)
    if string != nil
      s = string.gsub(/\\[Ll][Oo][Cc]\[(.+)\]/) { self.read($1) }
      s.gsub!("\\n", "\n")
      s
    end
  end

It works, thanks! (I mean, only the \n thing, I still need help with the choices.) Also yeah, I use UMS. I forgot to mention that.
Bump, I still need a method to allow UMS's choices to be compatible with the Localizations script.
Can you try putting this below UMS
Code:
class Game_Temp
  def choices=(strings)
    strings.map! { |s| Localization.localize(s) }
    @choices = strings
  end
end
Can you try putting this below UMS
Code:
class Game_Temp
  def choices=(strings)
    strings.map! { |s| Localization.localize(s) }
    @choices = strings
  end
end

It worked! Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/rpgxp-foreverzer0s-localization-script-compatible-with-choices-n-code-in-files.126266/