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

Feature #23583 Add current and fallback locales in WDT / Profiler #23625

Merged
merged 1 commit into from
Sep 13, 2017

Conversation

nemoneph
Copy link
Contributor

@nemoneph nemoneph commented Jul 22, 2017

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

The goal of this PR is to add informations about the locale and the fallback locales in the translation WDT panel / and profiler


<div class="metrics">
<div class="metric">
<span class="value">{{ collector.locale }}</span>
Copy link
Member

Choose a reason for hiding this comment

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

When some data is missing, we use a dash (-) instead of an empty string (e.g. -> <td class="text-right">{{ listener.priority|default('-') }}</td>). The problem with a white space is that you don't know if it's because of some error or because there's really no data.

In TranslationDataCollector.php you used an empty string when there's no locale, so maybe here we can check if it's empty and display a -


{% if collector.fallbackLocales|length %}
<div class="metric">
<span class="value">{{ collector.fallbackLocales | join(' | ') }}</span>
Copy link
Member

Choose a reason for hiding this comment

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

Here, in addition to showing a - when there are no fallback locales, I'd use a comma (,) instead of a pipe (|) to separate the values.

@nemoneph
Copy link
Contributor Author

nemoneph commented Jul 24, 2017

Thanks for the review @javiereguiluz

I've made some updates:

-> use a comma for separate the values instead of |
-> if locale is empty, set the default value to '-' (check/set this in TranslationDataCollector is enough ?)
-> if the fallback_locales is empty, set the default value to '-'

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Jul 25, 2017
@nicolas-grekas
Copy link
Member

Adding to milestone 3.4 since this is where new features are merged.

*
* @return string
*/
public function getLocale()
Copy link
Member

Choose a reason for hiding this comment

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

phpdoc can be removed

* Gets the fallback locales.
*
* @return array
*/
Copy link
Member

Choose a reason for hiding this comment

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

same here

*/
public function getLocale()
{
return !empty($this->data['locale']) ? $this->data['locale'] : '-';
Copy link
Member

Choose a reason for hiding this comment

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

A quick comment about using - as a return value: the PHP methods of data collectors can be called from other PHP code (e.g. when using the profiler in tests). So I always prefer to return values optimized for PHP. In this case, null or an empty string (as you originally did) would be more convenient than returning -. The - symbol is just a visual detail used to let the user know that this value is empty ... so maybe is better to move that to the Twig template. Thanks!

(same comment for getFallbackLocales() ... retuning an empty array may be better)

@nemoneph nemoneph force-pushed the feature/23583 branch 2 times, most recently from e425993 to 2ccab30 Compare July 25, 2017 17:15
@nemoneph
Copy link
Contributor Author

@javiereguiluz Yes make sense.

Here the update:

-> remove phpdoc
-> use default('-') in view instead of TranslationDataCollector

@@ -13,6 +13,12 @@

{% set text %}
<div class="sf-toolbar-info-piece">
<b>Locale</b>
<span class="sf-toolbar-status">
{{ collector.locale | default('-') }}
Copy link
Member

Choose a reason for hiding this comment

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

the spaces around the pipe operator should be removed (same below)

@nemoneph
Copy link
Contributor Author

nemoneph commented Sep 5, 2017

@xabbuh Thx, update done.

@xabbuh
Copy link
Member

xabbuh commented Sep 11, 2017

I think you could best rebase these changes onto the 3.4 branch now and change the target branch here.

@nemoneph nemoneph changed the base branch from master to 3.4 September 11, 2017 17:09
@nemoneph
Copy link
Contributor Author

@xabbuh Yes, it's done too now.

Copy link
Member

@xabbuh xabbuh left a comment

Choose a reason for hiding this comment

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

failure is not related

@fabpot
Copy link
Member

fabpot commented Sep 13, 2017

Thank you @nemoneph.

@fabpot fabpot merged commit 98a8a6c into symfony:3.4 Sep 13, 2017
fabpot added a commit that referenced this pull request Sep 13, 2017
… / Profiler (nemoneph)

This PR was merged into the 3.4 branch.

Discussion
----------

Feature #23583  Add current and fallback locales in WDT / Profiler

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

The goal of this PR is to add informations about the locale and the fallback locales in the translation WDT panel / and profiler

Commits
-------

98a8a6c Feature #23583  Add current and fallback locales in WDT / Profiler
This was referenced Oct 18, 2017
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull request Mar 25, 2018
…locales in WDT / Profiler (nemoneph)

This PR was merged into the 3.4 branch.

Discussion
----------

Feature symfony#23583  Add current and fallback locales in WDT / Profiler

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

The goal of this PR is to add informations about the locale and the fallback locales in the translation WDT panel / and profiler

Commits
-------

98a8a6c Feature symfony#23583  Add current and fallback locales in WDT / Profiler
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.

6 participants