From: Ulf W. <ul...@wi...> - 2007-11-02 13:11:17
|
I haven't gotten around to actually testing sgte (StringTemplate in Erlang) together with Erlhive, but just reading the code, there are a few minor issues. This might also serve as a mini-tutorial on how to make code run inside Erlhive. http://code.google.com/p/sgte/ Several of the modules use the file module. This shouldn't be an obstacle, as file.erl is almost fully supported in Erlhive (only a few dets-specific functions are not). However, in Erlhive, calls to library modules such as file and lists must be dotted. Using .file and .lists etc actually works even in normal code, but it may offend some people, and is officially unsupported. You can instead add this to the beginning of the module: -ifdef(ERLHIVE). -import(.file). -import(.lists). -endif. Also, there are some calls to os:cmd(), which need some attention. For example, in sgte_gettext.erl: gettext_init(TargetDir, SrcFiles, Domain) -> %% Create target directory and parent directories %% when missing. os:cmd("mkdir -p " ++ TargetDir), This call can be replaced with filelib:ensure_dir(TargetDir). This one is trickier: po_header() -> Date = os:cmd("date +%F\\ %T\\ %z"), The call to 'date' doesn't work on Solaris (at least not Solaris 8), since it doesn't support the %F option. It would need to be rewritten in some portable, erlangy, way. I have no problem supporting os:getenv("TZ") as part of the solution, even though this isn't supported right now. Then, the call can be replaced by: {{Y,Mo,D},{H,Mi,S}} = calendar:local_time(), lists:flatten(io_lib:fwrite("~4.4.0w-~2.2.0w-~2.2.0w ~2.2.0w:~2.2.0w:~2.2.0w ~s", [Y,Mo,D,H,Mi,S,os:getenv("TZ")])). (or some, slightly more verbose, but more efficient, solution...) With those small changes, sgte should compile from within an erlhive user account. If erlhive were to support it "natively", sgte.erl and sgte_gettext.erl would have to be transformed, using erlhive_xform.erl, and the other modules could simply be allowed as they are. BR, Ulf W |