Refactor I18N
Currently we use a mixin to alter the I18n class to fall back to English and to use named placeholders. English fall-back is vanilla behaviour and named placeholders should be implemented in a wrapper as to avoid interfering with other mods, therefore the I18n mixin should be removed.
Additionally, most strings use String.format()-style placeholders which can be unclear to translators and they are used unindexed which makes it impossible for translators to reorder. Named placeholders should be used everywhere.
It worth note that, the NamedFormatter I made, to format strings like {foo} at {bar}, this type of string will be marked by IntelliJ MC dev plugin, says its format is illegal (invalid). That paused my step to replace every i18n text to that format.
It worth note that, the NamedFormatter I made, to format strings like
{foo} at {bar}, this type of string will be marked by IntelliJ MC dev plugin, says its format is illegal (invalid). That paused my step to replace every i18n text to that format.
I don't see any warnings in mine, where does it show you that warning?
I don't see any warnings in mine, where does it show you that warning?
See in IDE
https://github.com/minecraft-access/minecraft-access/blob/ac9a286c752aa164bdbd03e1474ff611023f5d21/common/src/main/java/org/mcaccess/minecraftaccess/utils/NarrationUtils.java#L121
https://github.com/minecraft-access/minecraft-access/blob/ac9a286c752aa164bdbd03e1474ff611023f5d21/common/src/main/java/org/mcaccess/minecraftaccess/utils/NarrationUtils.java#L68
I don't see any warnings in mine, where does it show you that warning?
See in IDE
minecraft-access/common/src/main/java/org/mcaccess/minecraftaccess/utils/NarrationUtils.java
Line 121 in ac9a286
text = I18n.get("minecraft_access.other.entity_with_equipments", values); minecraft-access/common/src/main/java/org/mcaccess/minecraftaccess/utils/NarrationUtils.java
Line 68 in ac9a286
type = I18n.get("minecraft_access.other.animal_variant_format", map);
I'm not getting that warning for some reason, though looking at it I would expect to see a warning there. I suspect the warning is just the plugin not understanding our mixin though, any new system wouldn't use a mixin and thus won't suffer the same downfall.
I'm not getting that warning for some reason, though looking at it I would expect to see a warning there. I suspect the warning is just the plugin not understanding our mixin though, any new system wouldn't use a mixin and thus won't suffer the same downfall.
Sure... I'll try to post my screen later
Proposed API from Discord:
public class Key {
public static @Notnull Key of(@Notnull String key);
@Contract("_ -> this", mutates = "this")
public @Notnull Key set(@Notnull String variable, @Notnull String value);
@Contract("_ -> this", mutates = "this")
public @Notnull Key set(@Notnull String variable, @Notnull int value);
@Contract("_ -> this", mutates = "this")
public @Notnull Key set(@Notnull String variable, @Notnull double value);
public void speak(boolean interupt);
@Contract(pure = true)
public @Notnull String toString();
}
An example usage would look something like this, assuming the key text.minecraft_access.foobar is set to {bar} is {foo} this would result in the narrator speaking the meaning of life, the universe, and everything is 42:
Key.of("text.minecraft_access.foobar")
.set("foo", 42)
.set("bar", "the meaning of life, the universe, and everything")
.speak(false);
Of course this is tentative and subject to change, I think Key might conflict with some other classes which would make it annoying to use so it is likely to be renamed.
Of course this is tentative and subject to change, I think
Keymight conflict with some other classes which would make it annoying to use so it is likely to be renamed.
Just, Narration?