TTT-2 / TTT2

Trouble in Terrorist Town 2 for Garry's Mod (gmod)
https://steamcommunity.com/sharedfiles/filedetails/?id=1357204556
177 stars 72 forks source link

It seems that Simplified Chinese and Traditional Chinese don't have automatic line breaks. #1110

Closed sbzlzh closed 9 months ago

sbzlzh commented 11 months ago

It's in English: image This is in simplified Chinese: image (1)

sbzlzh commented 11 months ago

I seem to have found the reason, it's because of the punctuation. For example, if you use a Chinese period and space it in the desired position, then it breaks the line. The fastest way is to use all English punctuation.

TimGoll commented 11 months ago

I found the reason. It's the punctuation. For example, if you use a Chinese period and space it in the desired position, then it breaks the line. The fastest way is to use all English punctuation.

that's true, but words without spaces should be broken up as well - so this is still a bug

sbzlzh commented 11 months ago

It seems that Japanese does the same thing, since it uses Chinese symbols

Racpy commented 11 months ago

I remember the translation changes I made last time, needed to change the number of lines myself within [[text]] to achieve a line break.

If this is a bug, fixing it might result in better translation format consistency, rather than forcing line breaks within [[text]] to avoid this outcome.

sbzlzh commented 11 months ago

I found the reason. It's the punctuation. For example, if you use a Chinese period and space it in the desired position, then it breaks the line. The fastest way is to use all English punctuation.

that's true, but words without spaces should be broken up as well - so this is still a bug

Should I use the English punctuation now, or do I go find them one by one and add spaces :), now that I have time to do that.

TimGoll commented 11 months ago

I found the reason. It's the punctuation. For example, if you use a Chinese period and space it in the desired position, then it breaks the line. The fastest way is to use all English punctuation.

that's true, but words without spaces should be broken up as well - so this is still a bug

Should I use the English punctuation now, or do I go find them one by one and add spaces :), now that I have time to do that.

nah, we will fix it soon

sbzlzh commented 11 months ago

I found the reason. It's the punctuation. For example, if you use a Chinese period and space it in the desired position, then it breaks the line. The fastest way is to use all English punctuation.

that's true, but words without spaces should be broken up as well - so this is still a bug

Should I use the English punctuation now, or do I go find them one by one and add spaces :), now that I have time to do that.

nah, we will fix it soon

That's good.

TimGoll commented 11 months ago

image

I tried to fix it. The problem is that chinese characters are not counted as characters. E.g. has a length of 3. I don't know how to handle it, because I tried to get individual characters.

TimGoll commented 11 months ago

@sbzlzh do you know by chance if every chinese character consists of three characters?

I tested a few and they all have three: image

TimGoll commented 11 months ago

Phew, I don't think I can solve this issue for now. If I were sure that all characters are chinese, I could just assume that every character uses 3 chars. But as soon as you mix latin characters into the text, it completely breaks. I don't know if there is a nice solution for that.

sbzlzh commented 11 months ago

Phew, I don't think I can solve this issue for now. If I were sure that all characters are chinese, I could just assume that every character uses 3 chars. But as soon as you mix latin characters into the text, it completely breaks. I don't know if there is a nice solution for that.

In utf-8, it is true that a Chinese character uses 3 characters. Another way is to replace commas, periods and other such punctuation marks with English ones first, without using Chinese ones.

sbzlzh commented 11 months ago

So I'm used to using English punctuation in my own plugins, and have to use Chinese conformity in addition to other reasons.

TimGoll commented 11 months ago

Phew, I don't think I can solve this issue for now. If I were sure that all characters are chinese, I could just assume that every character uses 3 chars. But as soon as you mix latin characters into the text, it completely breaks. I don't know if there is a nice solution for that.

In utf-8, it is true that a Chinese character uses 3 characters. Another way is to replace commas, periods and other such punctuation marks with English ones first, without using Chinese ones.

but this is only a hacky solution that still doesn't work if there are no commas/periods etc

I'd love to have a nice working solution, but the combination of english + chinese in a single string makes it really hard

TimGoll commented 11 months ago

@saibotk found a solution. I'm probably able to implement it

saibotk commented 11 months ago

For reference: string.len only handles byte sequences and we just need to use the utf8 library for this:

https://wiki.facepunch.com/gmod/utf8.len

TimGoll commented 11 months ago

Fixed in dev, thanks for the report!

sbzlzh commented 10 months ago

Wouldn't that close the issue?

TimGoll commented 10 months ago

as soon as the PR is finished and merged, this issue is closed

sbzlzh commented 10 months ago

Okay, then I'll close this.

TimGoll commented 10 months ago

Okay, then I'll close this.

no, this is close us as soon as it is done

sbzlzh commented 10 months ago

Okay :)

sbzlzh commented 10 months ago

How is this progressing, is there something missing.

TimGoll commented 10 months ago

How is this progressing, is there something missing.

Yes. @saibotk wants me to implement these kinds of line breaks for other languages as well. But I don't have the time to implement that right now

sbzlzh commented 10 months ago

How is this progressing, is there something missing.

Yes. @saibotk wants me to implement these kinds of line breaks for other languages as well. But I don't have the time to implement that right now

ok

sbzlzh commented 9 months ago

Is the problem in the body search screen the same problem as in F1. image

TimGoll commented 9 months ago

yes, we will ship the fix with the 0.12 release in the coming few days. It will fix the issue for all UIs

sbzlzh commented 9 months ago

That's great.

sbzlzh commented 9 months ago

image image

image Why does it look a little different to you? It's weird.

TimGoll commented 9 months ago

image

@saibotk This is indeed still broken. It was working on my last iteration before you took over. Do you know what caused it?

saibotk commented 9 months ago

Why this looks perfectly fine on your screenshot

Ah nvm had to zoom in

TimGoll commented 9 months ago

image no, the linebreak is missing

sbzlzh commented 9 months ago

Same effect. Mine's basically the same as his.

TimGoll commented 9 months ago

Well I guess it is not missing, but too late. I had a tolerance of 20% where it started checking for every chararacter. How do you do it?

sbzlzh commented 9 months ago

image

saibotk commented 9 months ago

Will look at that later

TimGoll commented 9 months ago

@sbzlzh Just to be clear, because I can't read Chinese: There is a linebreak there that wasn't there before this PR. It is just too late and a few characters are missing?

sbzlzh commented 9 months ago

@sbzlzh Just to be clear, because I can't read Chinese: There is a linebreak there that wasn't there before this PR. It is just too late and a few characters are missing?

There are other Chinese characters that are not shown in the picture.

sbzlzh commented 9 months ago

image no, the linebreak is missing

For example, your first circle in the picture. The arrow in the picture I sent jumps straight to several words. image

TimGoll commented 9 months ago

Alright, thank you, this is really helpful!

saibotk commented 9 months ago

image Yeah i messed up, this looks alright

Is this correct @sbzlzh ?

Ignore missing chars, seems to be a gmod linux font issue

sbzlzh commented 9 months ago

image Yeah i messed up, this looks alright

Is this correct @sbzlzh ?

Ignore missing chars, seems to be a gmod linux font issue

Here's the thing, the graphic shows no missing or omitted strings.

TimGoll commented 9 months ago

image Yeah i messed up, this looks alright Is this correct @sbzlzh ? Ignore missing chars, seems to be a gmod linux font issue

Here's the thing, it shows no missing.

on the left, there are the missing chars

sbzlzh commented 9 months ago

How come there's gibberish on the left side though.

TimGoll commented 9 months ago

What is this mess though.

likely a linux issue I will test it on my windows machine in a moment

sbzlzh commented 9 months ago

What is this mess though.

likely a linux issue I will test it on my windows machine in a moment

thank you

sbzlzh commented 9 months ago

Is it a problem with the linux system? I see some of the fonts are different sizes yeah

image

saibotk commented 9 months ago

Yes just ignore this

TimGoll commented 9 months ago

image works on windows, just ignore it

sbzlzh commented 9 months ago

image works on windows, just ignore it

It works great. It's great. So if you are using Debian or ubuntu can you show the same as in the picture

sbzlzh commented 9 months ago

It's solved, and it works well.