HULD don't work when called by timers
Vaans opened this issue · comments
Describe the bug
Seems that HULD don't work when is called via Timers. For example, if whe have something to transtale, and taht text is called from a timer, like OnTime3000, the HULD can't detect it and sent the original text.
To Reproduce
Steps to reproduce the behavior:
- Make a small script that the dialogue or announce are triggered via timers.
// Test
prontera,150,150,0 script test huld 4_F_SISTER,{
mes("Text without timers.");
mes("Should appear in Spanish.");
announce(_("Test HULD, this text should be appear in Spanish."), bc_all);
initnpctimer();
close();
OnTimer1500:
npctalk(("Hi, i'm talking in english with timers."));
npctalk(("This text should appear in Spanish with timers."));
announce(_("Test HULD with timer, this text should be appear in Spanish."), bc_all);
end;
}
- Use some program to translate this text, in this example i used POT
- See the problem. All text that is triggered by timers isn't translated.
Expected behavior
The text should be translated with timers labels.
Screenshots
In this screenshots the only text that has been translated is that don't have timer's labels.
System specs (please complete the following information):
- OS: Centos 7
- Hercules Version [v2023.03.08]
- Mode: pre-renewal
- Packet version: 2021-10-28
- Client type: RagexeRE
Plugins used or source modifications
N/A
Additional context
N/A
The reason those messages in the timer doesn't get translated is that they don't have an attached player to get the language from.
In this case, it uses the server default language (as defined in conf/map/map-server.conf
- default_language
) as a fallback. I believe in your case the server's default language is english, and that's why you saw it in english instead of spanish (spanish being the player-defined language only).
I am not sure if using the fallback when there are no players attached should be called a bug... because this comes with a limitation in HULD: messages that are sent to multiple players will be in a single language (probably for performance reasons).
In this case, if there are no player attached (like when this timer runs), which language should it pick? the server default one or ??
, since any player could have triggered this (or no player at all) and several players will see it (in a single language). But there is also another side here: the announce
in the main initial code, although being global, is being translated to the player's language (in this case showing in Spanish to everyone).
Edit: You can check this out by changing the default_language
in your map-server.conf
to Spanish. You will probably get those messages from the timer in Spanish. end of edit
From my point of view, going with the server defined language makes more sense, but it should also affect other global messages. But that's only my opinion.
There are some workarounds that could allow you to keep the player's language in the timer (and if 2 players trigger that at same time, we get the last one language): store the string in a npc variable before starting the timer, and use the variable in the timer instead of the string.
The same workaround would allow the first announce be in server language: store the string in a npc variable during OnInit and use it in player context (because it was translated at OnInit, it goes in the server language).
But in both cases, they are only workarounds.
Thank you for the clarification. Yes, i used the workaround that store the strings translated and put it in the timers labels.
Well, seems an issue with the operation instead of the system, gonna close this issue.
Thank you @guilherme-gm