Giter Club home page Giter Club logo

gettext-swig's People

Contributors

eldarc avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

domio eldarc

gettext-swig's Issues

Regex detects strings that it shouldn't

[edit] I updated this comment soon after posting it.

I'm working on gettext-volt to integrate into xgettext-template and I was very confused because it appeared as though it was detecting strings but then I couldn't figure out how that could because it isn't wrapped in {{}}.

This will detect 1 string, because of the , after ('Features') :

{%- set menus = [
  'features': this.translate._('Features'),
  'admin': this.translate._('Admin')
] -%}

This will detect 0 strings:

{%- set menus = [
  'features': this.translate._('Features')
] -%}

I'm not quite sure why that comma is necessary but it seems to me that to be 100% that gettext-swig would need to to have more than one regex pattern. Swig shouldn't be detecting any of these.

[NFR] Add variable string interpolator format

swig-i18n-abide supports a rather nice %s, %d format with {% trans "String %(foobar)s with string replacements" %}.

I think that '%(var)s' format might be idea for variable strings. So then the Swig parser would just need to collapse '%(var)(s|d)' to '%(s|d)' for the extracted message.

[NFR] Support for comment extraction

First of all, thanks for the job you've done so far.

It would be awesome if parser could extract comments as well, as in:

{# TRANSLATORS Here is some info for translators #}

and then just pass -c=TRANSLATORS to the command.

I'd contribute a PR myself instead of writing NFR, but I know jack shit about it.

P.S. I actually use Volt as my template engine, but this extractor beats the hell out of xgettext-volt as it supports contexts unlike latter.

\' doesn't work

{{t('You\'ve successfully created a Webird account. To activate it, please click below to verify your email address.')}} comes over as You\\.

I think that there needs to be two different regexs. One would ignore \' inside of single quotes and the other would ignore \" within double quotes.

Consider loosening the spaces match from '{{ +' to '{{ {0,3}'

Its valid to have no spaces after the {{. I set it at up to a maximum of 3 spaces just because it could help if someone quickly pasted it in while testing. I was having issues with getting it to run until I browsed at the source.

  this.expressionPattern = new RegExp([
//    '{{ +',
    '{{ {0,3}',
    '(' + Object.keys(keywordSpec).map(escapeRegExp).join('|') + ')',
    '\\(',
    '([\\s\\S]*?)',
    '\\)',
    ' {0,3}}}'
//    ' +}}'
    ].join(''), 'g');
}

Sorry, I'm too lazy for a pull request plus I figure that you need to reversion npm anyways if you like it. Personally, I need this.

Parser fails on plural comment escaping

The parser appears to fail on all of these:

Single quote escapes:
<p>{{ ngettext('\'quote', 'quotes', amount) }}</p>
<p>{{ ngettext('\'quote\'', 'quotes', amount) }}</p>
<p>{{ ngettext('quote', '\'quotes', amount) }}</p>
<p>{{ ngettext('quote', '\'quotes\'', amount) }}</p>
Double quote escapes:
<p>{{ ngettext("\"quote", "quotes", amount) }}</p>
<p>{{ ngettext("\"quote\"", "quotes", amount) }}</p>
<p>{{ ngettext("quote", "\"quotes", amount) }}</p>
<p>{{ ngettext("quote", "\"quotes\"", amount) }}</p>

[NFR] Support both {{}} and {%%} formats to support entire Django template family

It appears that {{ }} always uses paranthesis and that {% %} doesn't. They are intended for different uses but that so far appears to be the only constant as different engines use them for different functionality. By supporting both of these formats the Swig parser can be used across the entire line of Django family templates (and there are several varieties).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.