Jump to content
  • 0
AnnieRuru

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

Question

What is the difference between _("<string>") and _$("<string>") meant for HULD

I found a few clues in script.c

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

so its script->buildin_lang_macro_offset and script->buildin_lang_macro_fmtstring_offset

 

next, in generate-translations.c

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

now this make sense, _("<string>") is somehow group together with mes and select
_$("<string>") is somehow group together with mesf

 

so this is my guess ...

_("<string>") is for those without %d %s ...
_$("<string>") is for those with %d %s ... like sprintf ... right ?

 

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

<none>
c format
no c format

Spoiler

-	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 < .@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


#: 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

 

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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.

Share this post


Link to post
Share on other sites
  • 0

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 -> 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 <-- can be solve by F_MesColor
%s into % s <-- nothing can be done with this, other than manually fix it

Edited by AnnieRuru

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.