Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for comments in PhpCode extractor #100

Closed
mlocati opened this issue Feb 19, 2016 · 5 comments
Closed

Add support for comments in PhpCode extractor #100

mlocati opened this issue Feb 19, 2016 · 5 comments

Comments

@mlocati
Copy link
Member

mlocati commented Feb 19, 2016

When using xgettext to extract translatable strings from PHP files we have the option to extract comments (the -add-comments option):

For instance, let's say we have this test.php file

<?php

echo __(
    /* i18n: %1$s is the partial number, %2$s is the total number. Example: 2 of 3 */
    '%1$s of %2$s',
    $count,
    $total
);

If you run this command:

xgettext --add-comments=i18n --keyword=__:1 --add-location test.php

Here's the output:

#. i18n: %1$s is the partial number, %2$s is the total number. Example: 2 of 3
#: test.php:5
#, php-format
msgid "%1$s of %2$s"
msgstr ""

What about adding support to extract such comments?

@oscarotero
Copy link
Member

I'm agree. I knew there were comments in gettext but I didn't know that they had to be placed there.
One question: comments with // are allowed too?

@mlocati
Copy link
Member Author

mlocati commented Feb 19, 2016

From

<?php

echo __(
    /* i18n: Test comment 1 */
     'test 1'
);

echo __(
    // i18n: Test comment 2
     'test 2'
);

echo __(
    # i18n: Test comment 3
     'test 3'
);

xgettext extracts this

#. i18n: Test comment 1
#: test.php:5
msgid "test 1"
msgstr ""

#. i18n: Test comment 2
#: test.php:10
msgid "test 2"
msgstr ""

#. i18n: Test comment 3
#: test.php:15
msgid "test 3"
msgstr ""

@oscarotero
Copy link
Member

nice!

@oscarotero
Copy link
Member

I guess this can be closed

@mlocati
Copy link
Member Author

mlocati commented Feb 19, 2016

I guess this can be closed

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants