bbepis / XUnity.AutoTranslator

MIT License
1.99k stars 293 forks source link

How to split the "\n" newline character and save the sentences separately? #446

Open CatCars opened 11 months ago

CatCars commented 11 months ago

"PersistRichTextMode=Fragment" It is known that text can be split to make it easier to match.

Example {

Attack!<color\=#00000000>=Attack!<color\=#00000000>

<color\=#a71edf>Expert Offers=<color\=#a71edf>Expert Offers

Movement Speed: <color\=#4BBE42>+18=移动速度: <color\=#4BBE42>+18 } Effect {

Attack!=Attack!

Expert=Expert

Offers=Offers

Movement Speed:=Movement Speed:

{{A}}={{A}} } May I ask if a similar split operation can be performed on the \n newline character?

Example {

Unlock Condition: 25 With a single blow\n\nUnlock a Sign: The Sign of The Tornado=Unlock Condition: 25 With a single blow\n\nUnlock a Sign: The Sign of The Tornado

Unlock Condition: Win an attempt at 5 Difficulty\n\nYou acquire a Defender's shield.=Unlock Condition: Win an attempt at 5

Difficulty\n\nYou acquire a Defender's shield.

} Expected Result {

Unlock Condition: 25 With a single blow=Unlock Condition: 25 With a single blow

nUnlock a Sign: The Sign of The Tornado=nUnlock a Sign: The Sign of The Tornado

Unlock Condition: Win an attempt at 5 Difficulty=Unlock Condition: Win an attempt at 5 Difficulty

You acquire a Defender's shield.=You acquire a Defender's shield.

} Because the text obtained by unpacking the "resources.assets" file lacks newline symbols such as \n, it cannot match the text automatically generated by "XUnity.AutoTranslator." (My English is not very good; this is the text I translated using ChatGPT. I hope it doesn't affect readability.)

lynxbites commented 11 months ago

sr:"^([\s\S]+)(\\n)+([\s\S]+)$"=$1$2$3 This will split any string with \n in the middle in two and translate them separately You can test regular expressions here