Skip to content

Conversation

@MengLeiFudge
Copy link

In some cases, we deliberately set the translated string to an empty string (common for adding a Tutorial proto), but currently CommonAPI does not allow empty strings. So I modified the logic accordingly:

  1. The parameter key cannot be null or empty.
  2. When the parameter trans is null, if the language is EN, it will be changed to key; otherwise, no translation will be added.
  3. when parameter trans is empty string, add it normally.

@limoka
Copy link
Owner

limoka commented Oct 8, 2025

Can you explain why tutorial protos require this kind of thing?

Otherwise the code looks ok.

@MengLeiFudge
Copy link
Author

MengLeiFudge commented Oct 8, 2025

Ofcourse. Look this picture. Green=Title, Red=Text before video, Orange=Text after video

image

This is the first tutorial for vanilla game. As we all know, the tutorials can be divided into two categories:
1.One kind is without Video, which is shown in the picture above, 'Text before' is translated and displayed on the right side, and 'Text after' is translated as an empty string.
2.The other is the one with Video, 'Text before' is translated and displayed on the top of the video, and 'Text after' is translated and displayed on the bottom of the video.

Meanwhile, I noticed one thing: even in the current version, you can use RegisterTranslation(key, dic) to add empty strings. However, I must emphasise that it doesn't avoid adding cases where the translation result is null, which should be avoided.

@limoka
Copy link
Owner

limoka commented Oct 8, 2025

I see. What happenes if the post text in the proto is empty?

I do think the null option is odd. In my opinion such translations shouldn't be added either.

Also that is my opinion, but translation keys should only be English identifiers, not a Chinese text(which I view as a translation). Thus avoiding the need to have key and value being the same.

@MengLeiFudge
Copy link
Author

Well, if post text is null, it equals empty string - everything will be ok. Post text in picture transate in English is also empty string.
You know, DSP is a Chinese-developed game, so the original strings that were translated in the vanilla game were all in Chinese. But that's not the point, in CommonAPI we just need to make sure that the English translation must be present. For the key, we don't care if it's English or Chinese - that's up to the player who wrote the mod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants