PneumaticCraft: Repressurized

PneumaticCraft: Repressurized

43M Downloads

[Localization] Certain Formatting of texts is unfriendly for localization

dovisutu opened this issue · 6 comments

commented

code based on 1.16.4 branch when I wrote this, namely, at 1e0fbf2
(Somehow I managed to put the latest commit wrong...)

Problem

Some of the texts in-game are formatted just by joining 2 localized parts together, which may be difficult to localize into a language with different word orders.

For example, see here:

private void updateTrackerText() {
if (focusedTarget != null) {
blockTrackInfo.setTitle(xlate("pneumaticcraft.armor.upgrade.block_tracker"));
blockTrackInfo.setText(focusedTarget.getTitle());
} else {
blockTrackInfo.setTitle(xlate("pneumaticcraft.blockTracker.info.trackedBlocks"));
List<ITextComponent> textList = new ArrayList<>();
blockTypeCount.forEach((k, v) -> {
if (v > 0 && WidgetKeybindCheckBox.get(k).checked) {
textList.add(new StringTextComponent(v + " ").append(xlate(ArmorUpgradeRegistry.getStringKey(k))));
}
});
if (textList.isEmpty()) textList.add(xlate("pneumaticcraft.blockTracker.info.noTrackedBlocks"));
blockTrackInfo.setText(textList);
}
}

This part of code is used to generate statistics of tracked blocks in the armor HUD.
It generates sentences like 5 Hackables by joining the number 5 with a translated term. It works for langauges like English, where numerals are put before nouns, and measure words (at least in this circumstance) aren't necessary.

However, in case of a language like Chinese, where measure words are usually needed after numerals, the translation must be prefixed with a measure word, which is somewhat awkward, yet not impossible; to generate a sentence like 5 个可入侵方块(with the measure word ), the translation term should be 个可入侵方块, which tends to let one think it's wrong, while that's indeed right.

Even worse, in case of a language where numerals are put after nouns, or measure words are put before numerals, or other cases, this sentence cannot be properly translated at all, for in the current code, there's no way of switching the 2 parts. I don't have much knowledge to such language, though. It's said that Japanese is one of those langauges sometimes, but I'm not entirely sure.

Suggestion

Change the current formatting to containing parameters in the translation term itself, like %d Hackables.

commented

Yes, valid point. I can change the above code to sort that out. If you spot any other places that need fixing please let me know.

commented

Well, upon a search I find a bit more, while not as important as the one mentioned above:

Here, the code used " to mark the valuable name, while in some languages different quotations may be used (e.g. Chinese ). Not a big deal, but makes it a bit annoying (especially if a language has quotation marks that are really different).

curTooltip.add(xlate("pneumaticcraft.gui.progWidget.itemAssign.settingVariable").appendString(": \"").appendString(variable).appendString("\""));

Here, the same thing but for parentheses:

.appendString(" (" + fluidStack.getAmount() + "mB)"));

What's interesting is that while searching, I happened to find several instances of hard-coded texts, which I'd like to mention here in addition:

probeInfo.text(new StringTextComponent("Tank #" + (i + 1) + ": ")


tooltip.add(new StringTextComponent("Last message: " ).mergeStyle(TextFormatting.AQUA)

public void addInfo(List<ITextComponent> curInfo) {
super.addInfo(curInfo);
String txt = grateRange == 0 ? "Idle" : vacuum ? "Attracting" : "Repelling";
curInfo.add(new StringTextComponent("Status: ").appendString(txt).mergeStyle(TextFormatting.WHITE));
curInfo.add(new StringTextComponent("Range: ").appendString(grateRange + " blocks").mergeStyle(TextFormatting.WHITE));
if (entityFilter != null)
curInfo.add(new StringTextComponent("Entity Filter: \"").appendString(entityFilter.toString()).appendString("\"").mergeStyle(TextFormatting.WHITE));
}

public void getTooltip(List<ITextComponent> curTooltip) {
super.getTooltip(curTooltip);
curTooltip.add(new StringTextComponent("Order: ").append(new TranslationTextComponent(order.getTranslationKey())));
}

curTooltip.add(new StringTextComponent("Order: ").append(new TranslationTextComponent(order.getTranslationKey())));
if (shouldVoidExcess()) {
curTooltip.add(xlate("pneumaticcraft.gui.progWidget.liquidImport.voidExcess"));

tooltip.add(new StringTextComponent("The One Probe installed").mergeStyle(TextFormatting.BLUE));

If one of them isn't intended to be shown in-game, just ignore that one. (Since I was in a hurry when doing so...)

commented

Fixed in 2.13.3 release

commented

After looking back, I find that during the fix, key pneumaticcraft.gui.progWidget.blockCondition.debug.allBlocksMatch had been rewritten as pneumaticcraft.gui.progWidget.blockCondition..allBlocksMatch, with debug dropped. Is that intentional or accidental?

(Yeah, I know I should've posted it in a separate issue and reference this one, but I think it's too minor for one issue.)

commented

Accidental, looks like a typo crept in there. Thanks for spotting it!

commented

Should be all fixed in 2.14.5 release, feel free to reopen (or create new issue) if you spot anything else that needs fixing.