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

[Translator] Add comments when dumping po files #30909

Merged
merged 1 commit into from Apr 6, 2019

Conversation

Projects
None yet
6 participants
@deguif
Copy link
Contributor

commented Apr 6, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? ?
Fixed tickets #29962
License MIT
Doc PR

This code

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

$catalogue->set('key.one', 'First key', 'custom');
$catalogue->setMetadata('key.one', ['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 "key.one"
msgstr "First key"

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

@lyrixx lyrixx changed the title Add comments when dumping po files [Translator] Add comments when dumping po files Apr 6, 2019

@Nyholm

This comment has been minimized.

Copy link
Member

commented Apr 6, 2019

I like this PR. Thank you
👍


Just and FYI:

In xliff we have notes and target-attributes. Here we introduce sources, comments and flags.

We maybe should have 4 standard thing keys that are shared over all dumpers/loaders.

@fabpot

This comment has been minimized.

Copy link
Member

commented Apr 6, 2019

Looks like the tests are broken by the features introduced in this PR. @deguif Can you have a look?

@deguif deguif force-pushed the deguif:issue-29962 branch from 82d08d4 to b0a3d69 Apr 6, 2019

@deguif

This comment has been minimized.

Copy link
Contributor Author

commented Apr 6, 2019

Please don't merge, I will rebase it once #30919 will get merged.

fabpot added a commit that referenced this pull request Apr 6, 2019

bug #30919 [Translator] Fix wrong dump for PO files (deguif)
This PR was merged into the 3.4 branch.

Discussion
----------

[Translator] Fix wrong dump for PO files

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

When working on #30909 I encountered this bug.
Currently the tests were passing, because the po fixture file contained only one translation.

Commits
-------

b54abfc Fix wrong dump for PO files
@fabpot

This comment has been minimized.

Copy link
Member

commented Apr 6, 2019

@deguif You can rebase this one now.

@deguif deguif force-pushed the deguif:issue-29962 branch from b0a3d69 to 31b3a55 Apr 6, 2019

@deguif

This comment has been minimized.

Copy link
Contributor Author

commented Apr 6, 2019

@fabpot this should be mergeable, test failures are not related.

@fabpot

fabpot approved these changes Apr 6, 2019

@fabpot

This comment has been minimized.

Copy link
Member

commented Apr 6, 2019

Thank you @deguif.

@fabpot fabpot merged commit 31b3a55 into symfony:master Apr 6, 2019

1 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
fabbot.io Your code looks good.
Details

fabpot added a commit that referenced this pull request Apr 6, 2019

feature #30909 [Translator] Add comments when dumping po files (deguif)
This PR was merged into the 4.3-dev branch.

Discussion
----------

[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
```php
$catalogue = new MessageCatalogue('fr');
$dumper = new PoFileDumper();

$catalogue->set('key.one', 'First key', 'custom');
$catalogue->setMetadata('key.one', ['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 "key.one"
msgstr "First key"

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

Commits
-------

31b3a55 Add comments when dumping po files

@nicolas-grekas nicolas-grekas added this to the next milestone Apr 6, 2019

fabpot added a commit that referenced this pull request Apr 29, 2019

feature #31248 [Translator] Add sources when dumping qt files (Stadly)
This PR was merged into the 4.3-dev branch.

Discussion
----------

[Translator] Add sources when dumping qt files

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

This PR implements similar functionality as #30909, but for Qt files. Currently, only the Qt element `location` is supported, so only `sources` metadata is included in the dump.

Commits
-------

ff7577d Add sources when dumping qt files

@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019

fabpot added a commit that referenced this pull request May 7, 2019

feature #31249 [Translator] Set sources when extracting strings from …
…php files (Stadly)

This PR was squashed before being merged into the 4.3-dev branch (closes #31249).

Discussion
----------

[Translator] Set sources when extracting strings from php files

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Set metadata about filenames and line numbers when extracting translatable strings from php files. This PR complements #30909 and #31248, as those PRs implement support for dumping the filenames and line numbers to Po and Qt file formats.

Commits
-------

f05d4e4 [Translator] Set sources when extracting strings from php files

@fabpot fabpot referenced this pull request May 9, 2019

Merged

Release v4.3.0-BETA1 #31435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.