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

References in PO translation files #29962

Stadly opened this issue Jan 23, 2019 · 1 comment

References in PO translation files #29962

Stadly opened this issue Jan 23, 2019 · 1 comment


Copy link

@Stadly Stadly commented Jan 23, 2019

The PO translation file format supports references, so that one can easily see where the message is used in the source files. This can be very helpful when translating.

The PoFileDumper does not support references. It would be really nice if this could be implemented.

The format is:

#: path\to\file:line
#: path\to\other\file:line
msgid untranslated-string
msgstr translated-string

For example:

#: lib/error.c:116
msgid "Unknown system error"
msgstr "Error desconegut del sistema"

This comment has been minimized.

Copy link

@nicolas-grekas nicolas-grekas commented Jan 29, 2019

Would you like to submit a PR to support this?

@fabpot fabpot closed this Apr 6, 2019
fabpot added a commit that referenced this issue Apr 6, 2019
This PR was merged into the 4.3-dev branch.


[Translator] Add comments when dumping po files

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | ?    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #29962
| License       | MIT
| Doc PR        |

This code
$catalogue = new MessageCatalogue('fr');
$dumper = new PoFileDumper();

$catalogue->set('', 'First key', 'custom');
$catalogue->setMetadata('', ['sources' => 'src/file_1', 'comments' => 'Comment', 'flags' => 'fuzzy'], 'custom');

$catalogue->set('key.second', 'Second key', 'custom');
$catalogue->setMetadata('key.second', ['sources' => ['src/file_1', 'src/file_2'], 'comments' => ['Comment 1', 'Comment 2'], 'flags' => ['fuzzy', 'another']], 'custom');

$dumper->dump($catalogue, [
    'path' => 'xxx',

Will produces this output:
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: fr\n"

# Comment
#, fuzzy
#: src/file_1
msgid ""
msgstr "First key"

# Comment 1
# Comment 2
#, fuzzy,another
#: src/file_1 src/file_2
msgid "key.second"
msgstr "Second key"


31b3a55 Add comments when dumping po files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.