Git Product home page Git Product logo

text's People

Contributors

cpeel avatar dotgit avatar

Watchers

 avatar  avatar

Forkers

cpeel

text's Issues

xtext thinks all strings with %s are format strings

xtext is checking for only the existence of % when detecting php-formatted strings, but not all strings with %s are formatted strings. xgettext appears to do some fancy heuristics to guess which is which although it doesn't do a great job. xgettext supports a xgettext:no-php-format comment above it to indicate that it isn't a format string. When these strings are written out to the file, the #, php-format line is not included.

While we could make xtext smarter about detecting PHP-format strings -- a complicated regex would probably get us 99% of the way there -- if xtext honored some kind of manual comment that would work just as well.

I'm happy to work up a PR to fix this (or at least to try) but before I went down that path I thought I'd open an issue and see if it's something you're interested in fixing or being fixed.

xtext only detects comments immediately prior to the expression, not on the line above

xgettext will detect comments on the line before the translation string. Because xtext uses an actual PHP parser, it (appears to) only detects commands of the expression immediately before the translation string.

For example:

// TRANSLATORS: say hello
$string = sprintf(_("Hello, world"));

$string = sprintf(
    // TRANSLATORS: bye bye bye
    _("Bye bye birdie")
);

xgettext will output (ignore the php-format -- it's technically accurate but not useful for this example):

#. TRANSLATORS: say hello
#: test.php:4
#, php-format
msgid "Hello, world"
msgstr ""

#. TRANSLATORS: bye bye bye
#: test.php:8
#, php-format
msgid "Bye bye birdie"
msgstr ""

xtext will output:

#: test.php:4
msgid "Hello, world"
msgstr ""

#. TRANSLATORS: bye bye bye
#: test.php:8
msgid "Bye bye birdie"
msgstr ""

I think this could be solved by keeping track of comments as they are encountered. When a string translation expression is encountered check if the line of the last comment (well, the last line of the prior comment) was on the line immediately above the string translation expression.


FYI: Distributed Proofreaders is trying to use xtext to replace xgettext as our translation-prep tool primarily because xgettext is completely ignorant of PHP 7.3's indented heredoc. I realize that it might not be an objective for xtext to be a drop-in replacement for xgettext so please let me know if these issues and PRs are not wanted / welcome.

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.