vertilia / text Goto Github PK
View Code? Open in Web Editor NEWTranslation library based on concept of gettext .po files
License: BSD 2-Clause "Simplified" License
Translation library based on concept of gettext .po files
License: BSD 2-Clause "Simplified" License
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.