[Haskell-cafe] haskell i18n best practices
Rogan Creswick
creswick at gmail.com
Sat Oct 1 00:43:25 CEST 2011
On Fri, Sep 30, 2011 at 2:09 PM, Felipe Almeida Lessa
<felipe.lessa at gmail.com> wrote:
> On Fri, Sep 30, 2011 at 5:44 PM, Rogan Creswick <creswick at gmail.com> wrote:
>> The grammatical framework excels at translation and localization -- it
>> probably has the highest learning curve of the options; but it will
>> generate the best / most accurate text depending on the target
>> language:
>>
>> * http://www.grammaticalframework.org
>>
>> At first brush, it may seem like extreme overkill; but it is able to
>> handle many, many infuriating corner cases (eg: properly forming
>> discontinuous constituents, updating case / tense and number to agree
>> with potentially variable quantities and genders, addressing the
>> absence of "yes" and "no" in some languages, etc...)
>>
>> The language processing bits are expressed in a PMCFG grammar, which
>> uses a syntax similar to haskell. The PMCFG compiles to a PGF file
>> that can be loaded and used by a haskell module that implements the
>> runtime, so it doesn't change your run-time requirements (if you
>> already rely on haskell, there are also runtime implementations in
>> javascript, java, c and python).
>
> I've seen GF before, but I can't actually see how one would use it for
> localization. Are there any simple examples?
Here's a *very* simple example I just threw together, based on the
Foods grammar (so it's quite contrived), but hopefully it's sufficient
for the moment:
https://github.com/creswick/gfI8N
Updating it to use the Phrasebook example would make it much more
interesting... I think there are numbers in there, and iirc, it uses
the actual resource grammars, which is what you really want for a real
system.
Usage details in the README.md, and I've commented the important
function in the haskell source. The rest of the magic is in the (also
ugly) Setup.hs.
You will also need to manually install gf, I believe, even if you use
cabal-dev, due to some annoyingly complex (but solveable) build-order
and PATH complications.
--Rogan
More information about the Haskell-Cafe
mailing list