[erlang-questions] Best Practices: Localization of Erlang Applications. Also, Error Messages!

Loïc Hoguin essen@REDACTED
Thu Jul 14 12:56:07 CEST 2011


On 07/13/2011 09:19 PM, Alex Arnon wrote:
> Hi All,
> 
> We're building a nontrivial Erlang application, which will provide a
> potentially high-volume, public RESTful Web Service. As part of the API,
> we will be providing both informative text (status, labels, layout
> templates) and error messages. A twofold question, then, to the
> experienced Grandmasters in the audience:
> 1. How have you implemented localization of text? This includes
> parameterized format strings.

I don't know how well it works but there's always:
  http://www.trapexit.org/Gettext_-_An_internationalization_package.

I'll be interested hearing what you find works best.

> 2. Has anyone used composite error values? For example, instead of
> {error, badarg}, use {error, {badarg, [{arg, ArgumentName}, {message,
> LocalizedMessageId}, {message_args, [...]}... Should we steer clear of
> these, and if so, what alternative would you suggest?

OTP uses format_error functions to format the errors. You could use the
same pattern in your case but internationalized. For example passing
{error, badarg, What} to the function would give the formatted version
in the currently selected language.

-- 
Loïc Hoguin
Dev:Extend



More information about the erlang-questions mailing list