IllusionMods / BepisPlugins

A collection of essential BepInEx plugins for games made by Illusion.
GNU General Public License v3.0
371 stars 79 forks source link

Translation Plugin Enhancements #2

Closed DarkPulse closed 4 years ago

DarkPulse commented 6 years ago

Some To-Dos regarding the translation plugin, in order of general "need."

DeathWeasel1337 commented 6 years ago

It seems the issue with Suit and others not being translated is related to their names containing a trailing space. For example スーツ=Suit does not work, but スーツ =Suit (that's a space before the equals) does work. I've noticed the same for Lace Bustier and the two Leotards as well.

DarkPulse commented 6 years ago

@DeathWeasel1337 Thanks for finding that, that's exactly what the problem was. We can nuke that issue off this list now, since it's not the plugin's fault at all, but Illusion's lousy quality control.

ghost commented 6 years ago

I think regex are a terrible idea. They completely ruin performance of the game because you cannot make a dictionary lookup. If I remember correctly in CM3D2, the authors of the translation plugin strongly recommended against using regex for this exact reason.

And if it is just the populate a string with a "variable" value from like 1-100 or the likes, then there are solutions that can solve this through "directives" in your translation file, and then simply populating the dictionary with 100 values for each variation.

Also I would not worry about having a large dictionary, they are basically always super performant.

I also recommend enabling newlines simply by encoding and decoding the character "\n" and/or "\r", as is suggested here.

Also, I would like to see the alternate language support through the use of "en", "ja", etc. somewhere in the path of the translation file as suggested above. I do not think it makes sense to include the country in that (en-US).

DarkPulse commented 6 years ago

@leakim1336 I'm not sure who said that. Usagirei was behind the UnityInjector translator plugin, and I did the customizer translation - both of which were plenty fast with regex, even when we torture-tested it by doing replacements with 1000 ridiculously long strings (which would never happen in the game) we're talking fractions of a millisecond. We've even still got the results from the benchmark Usagirei wrote up when someone else complained about the speed of regex. Suffice to say, the speed concerns of Regex are greatly exaggerated.

As for what it's needed for, part of it would indeed be that case (Type 1, Type 2, Type 3...) but part of it would also be due to the Studio - Illusion Studios append numbers to characters, items, etc. so that if you use multiples of them, there is still a way to uniquely identify a given one. And short of coming up with tables of 100+ numbers, regex is the only way to catch them all - and will generally be faster than having to parse an array of hundreds of numbers.

ghost commented 6 years ago

@DarkPulse I hear you man. :)

My point was simply if you use "directives" in the translation file to populate the dictionary with 100 values during startup where you would otherwise need a regex, it would be tonnes faster, because a dictionary lookup is basically always O(1), even if there are a 1000000 entries in the dictionary.

I also think it is easier to implement, and that was really my main point, and you keep the game loop really snappy by basically only doing a basic dictionary lookup when it really matters. :)

Now, obviously, it matters less here given that the Illusion, thankfully, don't use IMGUI. But I certainly feel it is a consideration that is worth taking.

ghost commented 6 years ago

You could of course, also make use of regex + directives to populate the dictionaries during initialization. In that case you would not need to come up with your own syntax. You could probably just use named groups.

LordGinger commented 6 years ago

One other suggestion: lines shouldn't be replaced if there's nothing after the equals sign/after the tab/whatever method you choose. So, for example, if I have カメラエフェクト=, the line shouldn't be replaced with an empty string. I can't imagine where replacing with an empty string would be useful anyway.

LordGinger commented 6 years ago

Also, Dark Pulse did mention overflow, but there should also be a way to override text alignment. So far I've encountered places in the options menu where it could be used.

dearmochi commented 6 years ago

Not sure if this is the best place for this, but I've been fiddling around with a translation of my own and a string containing the protagonist's name came up (bolded).

壮亮くん、おはよー。よく寝てたから先に出るぞ

As far as I understand, if I wanted to make a translation for this string, it would only work for this string only (aka only if the protagonist's name is 壮亮くん). As soon as I choose a protagonist with a different name, it'll count as a different string and thus my translation will not work. I don't really have a solution for this, or perhaps I've been doing this wrong, but I'm hoping there's a way to solve this issue. It's my first time writing translations for a game so I'm not quite sure how to tackle this.

LordGinger commented 6 years ago

We don't currently have a way to solve that problem. My suggestion is putting a comment above lines which have your character's name so that your translation is still usable when we make the switch to a new system.

enkephalin07 commented 6 years ago

Another suggestion to shorten regex searches, esp in global files, is to specify a subsection either by filename or labelled section of translations. For example, you could specify an exclusive search for names to use only ones in "translation_eng.names.txt", and if not found in the file, terminate search and pass the string untranslated. Or you could have section headers to identify a series of firstnames, lastnames, or nicknames, and search them in the order they're most likely to appear.

DeathWeasel1337 commented 4 years ago

Closing this as DynamicTranslationLoader will no longer be supported. In the future, all translations will be done through XUnity.AutoTranslator. XUA has grown extremely powerful, incorporating nearly every feature of DTL and is actively developed and maintained, while DTL has nearly no activity.

https://github.com/bbepis/XUnity.AutoTranslator