Skip to content

[FrameworkBundle] Add option --as-tree to translation:update command #38393

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

Merged
merged 1 commit into from
Oct 6, 2020

Conversation

jschaedl
Copy link
Contributor

@jschaedl jschaedl commented Oct 3, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #38344
License MIT
Doc PR tbd.

Before:

$ bin/console translation:update --domain messages --output-format=yml --force en

# messages.yaml
app.backend.title: __app.backend.title
app.backend.content: __app.backend.content

After:

$ bin/console translation:update --domain messages --output-format=yml --force --as-tree=3 en

# messages.yaml
app:
    backend:
        title: __app.backend.title
        content: __app.backend.content

@@ -84,6 +84,7 @@ protected function configure()
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to update'),
new InputOption('xliff-version', null, InputOption::VALUE_OPTIONAL, 'Override the default xliff version', '1.2'),
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically', 'asc'),
new InputOption('as-tree', null, InputOption::VALUE_NONE, 'Dump the messages as a tree-like structure'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would allow an argument which would be the "inline" option: --as-tree=3.

@@ -13,6 +13,7 @@ CHANGELOG
* added `framework.http_client.retry_failing` configuration tree
* added `assertCheckboxChecked()` and `assertCheckboxNotChecked()` in `WebTestCase`
* added `assertFormValue()` and `assertNoFormValue()` in `WebTestCase`
* Added `--as-tree=3` option to `translation:update` command to dump messages as a tree-like structure. The given value defines the level where to switch to inline YAML
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"--as-tree"

@@ -84,6 +84,7 @@ protected function configure()
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to update'),
new InputOption('xliff-version', null, InputOption::VALUE_OPTIONAL, 'Override the default xliff version', '1.2'),
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically', 'asc'),
new InputOption('as-tree', null, InputOption::VALUE_OPTIONAL, 'Dump the messages as a tree-like structure: The given value defines the level where to switch to inline YAML'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not set the default value here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure about that at first, but decided to remove the default value because I can just call ...'as_tree' => $input->getOption('as-tree')... when setting the writers options which will result in 'as_tree' => null and with this make sure that the YamlFileDumper wouldn't call the ArrayConverter::expandToTree($data); method every time.

@fabpot
Copy link
Member

fabpot commented Oct 6, 2020

Thank you @jschaedl.

@fabpot fabpot merged commit 81833b6 into symfony:master Oct 6, 2020
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.2 Oct 7, 2020
@fabpot fabpot mentioned this pull request Oct 14, 2020
@jschaedl jschaedl deleted the issue-38344 branch June 2, 2021 20:04
nicolas-grekas added a commit that referenced this pull request Sep 20, 2023
…ull` command (syffer)

This PR was merged into the 6.4 branch.

Discussion
----------

[Translation] Add `--as-tree` option  to `translation:pull` command

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes/no
| New feature?  | yes
| Deprecations? | no
| Tickets       | n/a
| License       | MIT
| Doc PR        | todo

This PR adds an option `--as-tree` to the command `translation:pull`, like the PR #38393 did it for the command `translation:extract`.

This option would ease the use of the command `translation:pull` when the yaml translations are stored as a tree. Without it, the yaml translations are inlined after a `translation:pull`, regardless of whether it was stored as inline or as a tree. To bypass this, you would either have to
- re-indent the yaml file yourself after a `translation:pull`
- replace one service (e.g. `translation.dumper.yaml`) to forcefully add the option `as_tree` for the yaml file dumper

Commits
-------

2f328ad [Translation] Add `--as-tree` option  to `translation:pull` command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Translation] Dumping YAML translations as tree
4 participants