what is the difference between _("<string>") and _$("<string>")

AnnieRuru

~~Cute~Cute~Scripter~~
Messages
1,677
Points
0
Location
your next door ~
Discord
AnnieRuru#1609
Github
AnnieRuru
Emulator
Client Version
2019-05-30aRagexeRE
What is the difference between _("&lt;string&gt;") and _$("&lt;string&gt;") meant for HULD

I found a few clues in script.c

else if( strcmp(buildin-&gt;name, "mes") == 0 ) script-&gt;buildin_mes_offset = script-&gt;buildin_count;
else if( strcmp(buildin-&gt;name, "mesf") == 0 ) script-&gt;buildin_mesf_offset = script-&gt;buildin_count;
else if( strcmp(buildin-&gt;name, "select") == 0 ) script-&gt;buildin_select_offset = script-&gt;buildin_count;
else if( strcmp(buildin-&gt;name, "_") == 0 ) script-&gt;buildin_lang_macro_offset = script-&gt;buildin_count;
else if( strcmp(buildin-&gt;name, "_$") == 0 ) script-&gt;buildin_lang_macro_fmtstring_offset = script-&gt;buildin_count;


so its script-&gt;buildin_lang_macro_offset and script-&gt;buildin_lang_macro_fmtstring_offset

next, in generate-translations.c

if (!duplicate) {
if (script-&gt;syntax.last_func == script-&gt;buildin_mes_offset
|| script-&gt;syntax.last_func == script-&gt;buildin_select_offset
|| script-&gt;syntax.lang_macro_active
) {
is_translatable_string = true;
} else if (script-&gt;syntax.last_func == script-&gt;buildin_mesf_offset
|| script-&gt;syntax.lang_macro_fmtstring_active
) {
is_translatable_fmtstring = true;
}
}


now this make sense, _("&lt;string&gt;") is somehow group together with mes and select
_$("&lt;string&gt;") is somehow group together with mesf

so this is my guess ...

_("&lt;string&gt;") is for those without %d %s ...
_$("&lt;string&gt;") is for those with %d %s ... like sprintf ... right ?

so ... my next question is ... there are 3 types

&lt;none&gt;
c format
no c format

- script asdf FAKE_NPC,{
.@a$ = _("test");
.@b$ = _$("nothing");
end;
OnInit:
bindatcmd "mobcount", strnpcinfo(NPC_NAME)+"::Onaaa";
end;
Onaaa:
if ( !.@atcmd_numparameters ) {
dispbottom "input a mob ID";
end;
}
.@mobid = atoi( .@atcmd_parameters$ );
if ( getmonsterinfo( .@mobid, MOB_LV ) == -1 ) {
dispbottom "invalid monster ID";
end;
}
.@size = getunits( BL_MOB, .@bl, false, strcharinfo(PC_MAP) );
for ( .@i = 0; .@i &lt; .@size; ++.@i )
if ( getunitdata( .@bl[.@i], UDT_CLASS ) == .@mobid )
++.@c;
dispbottom sprintf(_("There are %1$dx %2$s in %3$s."), .@c, getmonsterinfo( .@mobid, MOB_NAME ), strcharinfo(PC_MAP) );
end;
}


generate the file as

Code:
#: npc/zzz.txt
# .@a$ = _("test");
msgctxt "asdf"
msgid "test"
msgstr ""

#: npc/zzz.txt
# .@b$ = _$("nothing");
#, c-format
msgctxt "asdf"
msgid "nothing"
msgstr ""

#: npc/zzz.txt
# dispbottom sprintf(_("There are %1$dx %2$s in %3$s."), .@c, getmonsterinfo( .@mobid, MOB_NAME ), strcharinfo(PC_MAP) );
#, no-c-format
msgctxt "asdf"
msgid "There are %1$dx %2$s in %3$s."
msgstr ""
what are those actually means then ?

if translate by hand, it probably doesn't mean anything ...

line 187 in generate-translations.c

is_translatable_fmtstring ? "#, c-format\n" : (has_percent_sign ? "#, no-c-format\n" : ""),




@Haru @Dastgir

 
This can give some overview: https://github.com/HerculesWS/Hercules/issues/2233

_$ is used if there's some string formatting (%s, %d or something like that), mesf is basically 3 commands in one, i.e mes+sprintf+_$

_() is used to enclose strings which aren't in commands that are translated(only few commands are detected like mes/select), others needs to be enclosed in _(), also raw string needs to be enclosed.

c-format is comment in pot file which says formatting is present.

 
that means _$() or _() is equally detect by HULD, the only difference is it generate a comment in the pot file
means nothing big differences
 ... I actually thought _() unable to parse %s or something ... seems I was wrong

@Myriad, soon we will roll out a new version of HULD, it already discuss on the staff level
old design -&gt; http://herc.ws/board/topic/8687-hercules-ultimate-localization-design/
once the new design roll out, I will force recommend the community to adapt this new scripting style

and for your question, because sprintf("Test %s", .@var); isn't detect by HULD
and its sprintf(_("Text %s"), .@var); , only enclose the string

by the way, on a side note, I seriously think we should change all the ^000000 into F_MesColor(C_BLACK)

some machine translation can break
^000000 into ^ 000000 &lt;-- can be solve by F_MesColor
%s into % s &lt;-- nothing can be done with this, other than manually fix it

 
Last edited by a moderator:
Back
Top