Cubitect / cubiomes-viewer

An efficient graphical Minecraft seed finder and map viewer.
GNU General Public License v3.0
1.02k stars 60 forks source link

added zh_CN translation #241

Closed SunnySlopes closed 1 year ago

SunnySlopes commented 1 year ago

In order to display Chinese characters on the screen correctly, I've added an open source simplified Chinese font into the origin DejaVuSans, -mono and -bold, which increased the volume of the program by about 6MB for all. I've added the link to the font in AboutDialog in my translation (since it's only used in that translation).

Almost all the words except the following part were translated: 1.Biomes can't be translated (since it's in cubiomes). 2.Description/Notes part controlled in conditionalDialog.cpp can't be translated. 3.Start pieces controlled in cutil.h doesn't act correctly after translation, so I had to roll back this section.

Sorry for HUGE pr.

Cubitect commented 1 year ago

Thank you for all your work.

For the fonts, where are you getting the Chinese characters from? Are you adding the characters directly into the DejaVu fonts? I will have to check the licenses, but I suspect all changes have to be clearly noted.

Maybe we could use a reduced number of symbols to decrease the filesize? - but that's just an idea. The monospace variant is used to display user texts, so reducing that might not be ideal.

Regarding the biome names, the starting piece names and the structure names in struct2str(), these are minecraft resource ids. I don't think it makes sense to translate these.

Also I want to give you a heads up that I have a relatively large number of changes to commit for v3.4, which adds a headless mode for the tool. I don't think the headless mode will need any translations, since using the tool in a terminal would be more of an advanced use case and terminals often have issues with non-ASCII characters.

Your use of QApplication::translate in the switch-cases in cutils.h and layerdialog.cpp will cause a memory access after free, and has to be done differently. Also avoid toUtf8() as it bypasses the locale settings.

I will also check why the translation for the description/notes aren't working...

I can merge this now and make these corrections myself and then commit my changes after, but I had to refactor all the warning messages, which may affect some of the translations.

SunnySlopes commented 1 year ago

"For the fonts, where are you getting the Chinese characters from?"

From a website https://www.maoken.com/freefonts/5275.html

"I will have to check the licenses, but I suspect all changes have to be clearly noted."

The font is under OFL license (as shown on the website), which is free for business use.

image

The first box of the last lane shows the license information. Besides, I've searched some other websites, all of which says it is free for business use. However, since it's a less known font, I failed to find its official website, and the website seems to be the main website of the font.

"Are you adding the characters directly into the DejaVu fonts?"

Yes, I used fontforge to inject 6763 Chinese characters into the existing font files. If any better ways are supported, I would switch to it as well.

"Maybe we could use a reduced number of symbols to decrease the filesize? - but that's just an idea. The monospace variant is used to display user texts, so reducing that might not be ideal."

I'm afraid that I've tried my best to throw away less-used characters. As the origin file takes up 8MB spaces, I've downsized it to 2MB each. However, I had to copy it 3 times in normal/bold/mono font, which takes up total 6MB spaces (PS: I've used 2 different weights of the font to keep in pace with the bold font you're using. Mono is now using the same weight as the normal one.)

"Regarding the biome names, the starting piece names and the structure names in struct2str(), these are minecraft resource ids. I don't think it makes sense to translate these." "Your use of QApplication::translate in the switch-cases in cutils.h and layerdialog.cpp will cause a memory access after free, and has to be done differently. Also avoid toUtf8() as it bypasses the locale settings."

Well, If you don't think it's a good idea to translate those names, I can rollback my changes on these two files as well as translations. However, as I know, many of users around me may find it hard to connect those resource ids with the real biomes as they know little English, and I'll try my best to help them. PS: I tried to use toUtf8() because if I use toSubString(), sometimes the character could not show properly on the screen. After all I'm going to rollback those changes first.

"Also I want to give you a heads up that I have a relatively large number of changes to commit for v3.4, which adds a headless mode for the tool. I don't think the headless mode will need any translations, since using the tool in a terminal would be more of an advanced use case and terminals often have issues with non-ASCII characters."

OK, I see it. But translations may be outdated at any time, I'll try my best to keep it updated. However, since I'm busy with my daily works, and I had to take the use of the Dragon Boat Festival in China to work with so much translations at once, sometimes I may find it hard to keep it updated as long as you've updated a new version, so maybe the newest updates of the programs may be left untranslated for some period of time before I check the GitHub again.

"I will also check why the translation for the description/notes aren't working..."

OK, thanks for your help.

"I can merge this now and make these corrections myself and then commit my changes after, but I had to refactor all the warning messages, which may affect some of the translations."

The warning message in Linguist? Oh..., I've avoided almost all of the warnings except for the ending punctuations, since "!" is the same as "!", except for the former one is only used in China, Korea and Japan to take up 1 full character (instead of half). As a result, I've directly turned off the check, so there could be a lot of problems of that kind.

SunnySlopes commented 1 year ago

Well, it's a little harder to get rid of the bold and the mono characters since there's a lot of places using them, and they're not controlled in translation files.

Cubitect commented 1 year ago

OFL 1.1 seems fine, if the font merge is made clear. Google tells me the Latin transcription of the font name is "Jiangcheng Heiti", can you confirm this?

Yes, I used fontforge to inject 6763 Chinese characters into the existing font files. If any better ways are supported, I would switch to it as well.

It may be desirable to be able to switch fonts dynamically, as well as on option to use a system font. I think this will involve a fair number of code changes, but it's something I can look into.

However, as I know, many of users around me may find it hard to connect those resource ids with the real biomes as they know little English, and I'll try my best to help them.

I can add a new mapping for translatable display names in places where it makes sense.

But translations may be outdated at any time

I don't plan to put too much effort into maintaining the translations, and I don't expect it from you either. Its going to be a whenever-there-is-time-and-motivation thing, as is the whole project. I fully expect translations to be incomplete and out-of-date most of the time. It's something users will have to deal with.

SunnySlopes commented 1 year ago

OFL 1.1 seems fine, if the font merge is made clear. Google tells me the Latin transcription of the font name is "Jiangcheng Heiti", can you confirm this?

Yes, I confirm.

It may be desirable to be able to switch fonts dynamically, as well as on option to use a system font. I think this will involve a fair number of code changes, but it's something I can look into.

The subset version of the font is attached below, 400w - normal, 700w - bold jiangchengheiti-subset.zip

I can add a new mapping for translatable display names in places where it makes sense. I don't plan to put too much effort into maintaining the translations, and I don't expect it from you either. Its going to be a whenever-there-is-time-and-motivation thing, as is the whole project. I fully expect translations to be incomplete and out-of-date most of the time. It's something users will have to deal with.

OK, I got it. If there's anything I could help you, just email me and I would deal with them when I'm free.

Cubitect commented 1 year ago

I have pushed my progress for the v3.4 release and I've made some changes to the fonts and I believe I got user selected fonts to work. Shipping with a font is therefore no longer really necessary I think, and I have removed them for now. (Adding one font to another with different licenses is also not something I'm particularly comfortable with, even if they are permissive licenses.)

I also just learned that a mix of Chinese and Latin glyphs will not vertically align with a monospace font. My method of dealing with this is a bit hacky, I might need to address this again at some point.

Regarding the translations I have added translatable biome names, so most places will now use those instead of the biome resource ids.

Also a minor thing I noticed with your translations, is that you removed the ellipses (...) from the menu entries. I'm not sure if there is a different convention for Chinese application, but usually ellipses indicate that the menu entry opens another dialog.

SunnySlopes commented 1 year ago

I have pushed my progress for the v3.4 release and I've made some changes to the fonts and I believe I got user selected fonts to work. Shipping with a font is therefore no longer really necessary I think, and I have removed them for now. (Adding one font to another with different licenses is also not something I'm particularly comfortable with, even if they are permissive licenses.)

It's truly a better way to deal with the fonts, and I'm to ignorant to achieve it. Thanks.

I also just learned that a mix of Chinese and Latin glyphs will not vertically align with a monospace font. My method of dealing with this is a bit hacky, I might need to address this again at some point.

Truly it's hard to deal with monospace fonts in Chinese, the only way I know is that one Chinese character equals 2 Latin glyphs, and only a few fonts achieved this and explained it in its introduction as far as I know. So, for the time being, using the normal font with monospace ones just work fine.

Regarding the translations I have added translatable biome names, so most places will now use those instead of the biome resource ids.

Thank you so much. I'll deal with those extra translation work later.

Also a minor thing I noticed with your translations, is that you removed the ellipses (...) from the menu entries. I'm not sure if there is a different convention for Chinese application, but usually ellipses indicate that the menu entry opens another dialog.

OK, I got it. Maybe I'm going to add it back in the future.