wichert / lingua

Translation toolkit for Python
Other
45 stars 32 forks source link

Python extractor: --keyword doesn't work with function that uses type annotations #87

Open omarkohl opened 7 years ago

omarkohl commented 7 years ago

Our pluralization function (ngettext) is defined as follows (using Python 3 type annotations).

def _p(
        singular: str,
        plural: str,
        n: int,
        mapping: Dict=None
        ) -> TranslationString:
    pass

We extract the strings from the source with following command:

    pot-create --keyword=_ts --keyword=_p:1,2 "$SEARCH_PATH" -o "$LOCALES_PATH"/$DOMAIN.pot

This breaks with following error:

Aborting due to parse error in ./xyz/utils.py[140]: Unexpected token: :

In utils.py on line 140 you will of course find the _p() function.

alexbrault commented 4 years ago

93 might have fixed this