XUnity.AutoTranslator icon indicating copy to clipboard operation
XUnity.AutoTranslator copied to clipboard

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

Open CatCars opened this issue 1 year ago • 1 comments
trafficstars

"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.)

CatCars avatar Nov 26 '23 13:11 CatCars

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

lynxbites avatar Nov 29 '23 09:11 lynxbites