[erlang-questions] erlang-gttext only looking for ?TXT macros?

Dmitrii Dimandt dmitriid@REDACTED
Mon May 11 22:24:43 CEST 2009


>
> On May 11, 2009, at 11:07 PM, Dmitrii Dimandt wrote:
>
>>
>> On May 11, 2009, at 10:27 PM, Dmitrii Dimandt wrote:
>>
>>> This is a very strange behavior I've observed in gettext.
>>>
>>> From the tutorial:
>>> In order to create the initial PO file, run the Makefile in the  
>>> directory, that the directories that should be processed, i.e  
>>> where there are code containing ?TXT macros.
>>>
>>> And that's all gettext processes — ?TXT macros. Does it mean that  
>>> I have to only use ?TXT macros and then go through the code and  
>>> change them to ?TXT2, ?FTXT etc manually?
>>>
>>> Is there a way to make erlang_gettext process these macros as well?
>>
>>
>> Ok, I've gotten to the bottom of this. Sort of...
>>
>>
>> ?TXT2("other string", "en")
>>
>> turns into something like
>>
>> {call,39,
>>               {remote,39,{atom,39,gettext},{atom,39,key2str}},
>>               [{string,39,"other string"},{string,39,"en"}]}
>>
>>
>> which somehow doesn't get matched by pt/3 in gettext_compile.erl
>>
>> Weird...
>


Ok. This is an ad-hoc solution that will definitely fail somewhere  
down the road.

In gettext_compile.erl find the following function:

pt([H|T], Opts, Func) when is_tuple(H) ->
    ?debug( "--- 3 --- ~p~n",[H]),
    [while(size(H), H, Opts, Func) | pt(T, Opts, Func)];

change it to:

pt([H|T], Opts, Func) when is_tuple(H) ->
    ?debug( "--- 3 --- ~p~n",[H]),
	case H of
		{call, _, _, _} ->
			[pt(H, Opts, Func) | pt(T, Opts, Func)];
		_ ->
			[while(size(H), H, Opts, Func) | pt(T, Opts, Func)]
	end;

This way pt/3 will not miss the function call to key2str/2. Hopefully...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090511/809a892b/attachment.htm>


More information about the erlang-questions mailing list