translate issue #7

Closed
opened 2024-10-17 10:28:16 -04:00 by Yaode_owo · 4 comments
Owner

with: ['a', 'b']

%%s
bot: %a
correct: %s

%s %s %s
bot: a b %s
correct: %s %s %s

%s %3$s
bot: a %3$s
correct: %s %3$s

with: ['a', 'b'] %%s bot: %a correct: %s %s %s %s bot: a b %s correct: %s %s %s %s %3$s bot: a %3$s correct: %s %3$s

For issues 2 and 3, this can be resolved by returning the original string whenever an error occurs (like there not being any arguments left even though there's an %s specified, or trying to get an argument at an invalid index).

However, in my experience, to properly fix the first issue, you cannot just replace %% with % and then run the rest of the sprintf-like function like usual because this would execute as so:

%%s -> %s -> a

I think you could modify your current Regex to accept % as well as s for the format specifier, but of course instead of actually inserting the argument at the current position it would instead insert a literal %. How well this would work with the JavaScript replaceAll function, which I am not familiar with.

Personally, I iterate through each character of the format string and then construct the translated String based on the contents of the format string and the arguments, throwing an exception when there's some sort of issue and in the code that invokes the sprintf function just returns the format string if an error occurred.

For issues 2 and 3, this can be resolved by returning the original string whenever an error occurs (like there not being any arguments left even though there's an %s specified, or trying to get an argument at an invalid index). However, in my experience, to properly fix the first issue, you cannot just replace %% with % and then run the rest of the sprintf-like function like usual because this would execute as so: `%%s -> %s -> a` I think you could modify your current Regex to accept % as well as s for the format specifier, but of course instead of actually inserting the argument at the current position it would instead insert a literal %. How well this would work with the JavaScript replaceAll function, which I am not familiar with. Personally, I iterate through each character of the format string and then construct the translated String based on the contents of the format string and the arguments, throwing an exception when there's some sort of issue and in the code that invokes the sprintf function just returns the format string if an error occurred.
Author
Owner

do you know how to get system chat isActionBar ?

do you know how to get system chat isActionBar ?

do you know how to get system chat isActionBar ?

Shouldn't it just be a field in the packet object?

> do you know how to get system chat isActionBar ? [Shouldn't it just be a field in the packet object?](https://prismarinejs.github.io/minecraft-data/?d=protocol&v=1.20.4#toClient_system_chat)
Author
Owner

... i found other packet.

... i found other packet.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Yaode_owo/Minecraft-protocol-1.20.4-chat-parser#7
No description provided.