Author Topic: Adding new line support to the localization script  (Read 1210 times)

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Adding new line support to the localization script
« on: March 04, 2014, 04:16:51 AM »
It's probably relatively simple to implement, but I'm not sure how to. I have hundreds of long multi-line strings in my project, and putting localization files together was a bit of a pain with the way language file syntax works at the moment. As an example, I'd like to do away with this:

  1. L1.Scene1.Window1.Label1, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. \n\nDonec faucibus nisl a orci pulvinar laoreet. Pellentesque eu condimentum dui. Nunc quis justo tortor. Fusce quis massa ut enim pellentesque semper vitae eget elit. Phasellus ut turpis egestas augue tempor laoreet.\n\nPraesent suscipit commodo ligula eu dignissim. Morbi at arcu eu quam ornare vehicula. Duis mollis sem in lorem fringilla, porta lobortis justo suscipit. Vivamus venenatis ullamcorper diam quis mattis.\n\nAliquam ante dolor, ultrices et vestibulum vel, dignissim ut magna. Donec tempus lacus at sapien fermentum fermentum. Morbi convallis eleifend arcu, vel imperdiet libero varius aliquet. Aenean justo metus, dignissim nec nisl vitae, lobortis vulputate sapien. Donec quis tortor sit amet tortor pulvinar lacinia. Vivamus interdum massa ut venenatis facilisis. Morbi lacinia fermentum ipsum, at ornare massa posuere ac. Duis tempus mi nec leo semper vulputate. In fermentum ac lacus vel interdum. Pellentesque et hendrerit nulla. Sed tristique dignissim hendrerit. Praesent id rhoncus nibh. Nunc nec egestas nisi. Morbi et tincidunt magna. Nam ut velit nec ligula feugiat ultrices.\n\nPraesent lacinia vestibulum nulla vitae mollis. Aenean dolor lectus, porttitor quis rutrum eu, scelerisque non augue. Donec in nunc eros. Morbi adipiscing vitae felis condimentum pellentesque."

And use something like this in my files:

  1. L1.Scene1.Window1.Label1 =
  2. "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  3.  
  4. Donec faucibus nisl a orci pulvinar laoreet. Pellentesque eu condimentum dui. Nunc quis justo tortor. Fusce quis massa ut enim pellentesque semper vitae eget elit. Phasellus ut turpis egestas augue tempor laoreet.
  5.  
  6. Praesent suscipit commodo ligula eu dignissim. Morbi at arcu eu quam ornare vehicula. Duis mollis sem in lorem fringilla, porta lobortis justo suscipit. Vivamus venenatis ullamcorper diam quis mattis.
  7.  
  8. Aliquam ante dolor, ultrices et vestibulum vel, dignissim ut magna. Donec tempus lacus at sapien fermentum fermentum. Morbi convallis eleifend arcu, vel imperdiet libero varius aliquet. Aenean justo metus, dignissim nec nisl vitae, lobortis vulputate sapien. Donec quis tortor sit amet tortor pulvinar lacinia. Vivamus interdum massa ut venenatis facilisis. Morbi lacinia fermentum ipsum, at ornare massa posuere ac. Duis tempus mi nec leo semper vulputate. In fermentum ac lacus vel interdum. Pellentesque et hendrerit nulla. Sed tristique dignissim hendrerit. Praesent id rhoncus nibh. Nunc nec egestas nisi. Morbi et tincidunt magna. Nam ut velit nec ligula feugiat ultrices.
  9.  
  10. Praesent lacinia vestibulum nulla vitae mollis. Aenean dolor lectus, porttitor quis rutrum eu, scelerisque non augue. Donec in nunc eros. Morbi adipiscing vitae felis condimentum pellentesque."

At the moment the parser expects every single new line to begin with a key name, which renders this impossible. Obviously it would be nicer to somehow change that so that it will e.g. recognize only the contents of the lines starting without " and ending with = as valid key names, and all the rest inside the following "..." blocks as assigned values. Particular syntax doesn't matter, though, I'll be more than happy with something like that too:

  1. <key name="KeyName1">
  2. <value>TextLine1InEnglish
  3. TextLine2InEnglish
  4.  
  5. TextLine3InEnglish
  6. TextLine4InEnglish</value>
  7. <value>TextLine1InGerman
  8. TextLine2InGerman
  9.  
  10. TextLine3InGerman
  11. TextLine4InGerman</value>
  12. </key>

Or with any other setup that makes sense and allows you to use new lines freely. How should I go about modifying Localization.cs and ByteReader.cs to achieve that?
Most likely I need to change how ReadCSV() in the ByteReader works.
« Last Edit: March 04, 2014, 05:00:53 AM by bac9 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Adding new line support to the localization script
« Reply #1 on: March 05, 2014, 05:31:28 AM »
Hmm... Multi-line support is something that works natively in CSV but I see I didn't add support for it in the CSV import. I will fix for for the next release.

Edit: Done. It's in the Pro repository now.
« Last Edit: March 05, 2014, 05:54:38 AM by ArenMook »