Kotsu icon indicating copy to clipboard operation
Kotsu copied to clipboard

Strings extraction

Open ArmorDarks opened this issue 8 years ago • 2 comments

There seems to be very few suitable solutions for extraction of gettext strings into .pot file, which then could be used for translation into different locales, and all of them have issues:

  • jsxgettext

    Node implementation of xgettext

    Pros:

    • Pure Node implementation
    • Supports Swig (thus works with Nunjucks)

    Cons:

    • Can extract only from singular and plural functions: https://github.com/zaach/jsxgettext/issues/95
    • Can't extract context and domain, thus can't handle properly functions with such arguments: https://github.com/zaach/jsxgettext/issues/94
    • Parser failing to parse some ordinary Nunjucks declarations (https://github.com/zaach/jsxgettext/issues/83 and https://github.com/zaach/jsxgettext/issues/78)
    • Doesn't extract comments from Nunjucks: https://github.com/zaach/jsxgettext/issues/86
    • Doesn't merge extracted strings properly: https://github.com/zaach/jsxgettext/issues/90
    • Doesn't support custom function names properly (minor): https://github.com/zaach/jsxgettext/issues/93
  • grunt-i18n-abide

    Ready Grunt task with set of useful gettext-related tools

    Pros:

    • Set of ready tools for Grunt

    Cons:

    • Uses jsxgettext for extraction, thus has same issues
    • Doesn't work in Windows environment: https://github.com/mozilla/grunt-i18n-abide/issues/47
  • grunt-xgettext

    Another Node/Grunt implementation of xgettext

    Pros:

    • Pure Node implementation
    • Supports context

    Cons:

    • Doesn't support custom function names properly (minor): https://github.com/arendjr/grunt-xgettext/issues/8

    • Doesn't have native support for Jinja or Nunjucks: https://github.com/arendjr/grunt-xgettext/issues/21

      Can parse in html mode, but in such case there are a lot of limitations

    • Can extract comments in expected form only from JavaScript: https://github.com/arendjr/grunt-xgettext#context-and-comments

    • Doesn't support domains: https://github.com/arendjr/grunt-xgettext/issues/6

  • Python Babel

    Some more informations:

    Note: didn't test yet

    Pros:

    • Has Jinja integration
    • Can do everything that native gettext can (I suppose)

    Cons:

    • Hostile environment
    • External dependency
  • POEdit

    Works with inbuilt gettext, can extract from JS, PHP, etc. JS and PHP extractors seems to be working for Nunjucks

    Pros:

    • Seems to be working
    • Can map custom functions with arguments positions properly

    Cons:

    • External dependency
    • No API or CLI, only standalone program
    • Doesn't have explicit support for Jinja or Nunjucks, but JS and PHP parsers seems to work
  • Native xgettext

    Pros:

    • Works
    • Can map custom functions with arguments positions properly

    Cons:

    • External dependency
    • Doesn't have explicit support for Jinja or Nunjucks, but JS and PHP parsers seems to work
    • Needs wrapper for processing batch files

ArmorDarks avatar Oct 16 '15 08:10 ArmorDarks