Skip to content

[ProductAttribute] Make select attribute translatable#8766

Merged
pamil merged 9 commits into
Sylius:masterfrom
GSadee:select-attribute-translation
Oct 24, 2017
Merged

[ProductAttribute] Make select attribute translatable#8766
pamil merged 9 commits into
Sylius:masterfrom
GSadee:select-attribute-translation

Conversation

@GSadee

@GSadee GSadee commented Oct 4, 2017

Copy link
Copy Markdown
Member
Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets fixes #8220
License MIT

Based on the PR #8206 created by @Lowlo and partially based on the PR #8751

@GSadee GSadee added this to the 1.1 milestone Oct 4, 2017
@GSadee GSadee force-pushed the select-attribute-translation branch 4 times, most recently from 285acf9 to a471fa4 Compare October 10, 2017 20:55
@GSadee GSadee force-pushed the select-attribute-translation branch 6 times, most recently from d8b316c to 1e915bf Compare October 15, 2017 11:06

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

?ContainerInterface?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

after locale change -> in different locale?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, is there any way we can get rid of those parent calls?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've been trying to come up with better solution, but without success. If you have any suggestion, please share with me 😃

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hardcoded en_US?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will filter out 0.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Strict types can be added here (and to this class entirely)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing typehint

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can be private

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Filtering out zeros.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens if values[attribute.value][fallbackLocale] is not defined?

@GSadee GSadee force-pushed the select-attribute-translation branch 2 times, most recently from bd8f5be to dc8dbe5 Compare October 18, 2017 07:05

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

array_search returns either a key (int / string) or false when the value was not found, so this expression can be reduced to $localeCode === $key only.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is it so? Empty treats 0 value as empty.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

$newKey cannot be null here as getUniqueKey returns string.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing typehints here (+ other method definitions).

@GSadee GSadee force-pushed the select-attribute-translation branch from dc8dbe5 to 889f071 Compare October 18, 2017 13:26

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SelectAttributeChoicesCollectionType uses LocaleProviderInterface::getDefaultLocaleCode() to get its default locale, this one has base locale injected as $defaultLocale, is that intentional?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Anyway, if it's intentional, I guess $baseLocale would be more appropriate name then.

@GSadee GSadee force-pushed the select-attribute-translation branch from 889f071 to bacae1d Compare October 23, 2017 12:17

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess there's still something wrong with those definitions, %locale% points to a base locale code, whereas sylius.translation_locale_provider service has getDefaultLocaleCode method which returns current channel's default locale. Is there any reason for using these two simultaneously instead of only one of them?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I didn't notice that 👍
I've changed to use sylius.translation_locale_provider instead of %locale%.

@GSadee GSadee force-pushed the select-attribute-translation branch from bacae1d to 79c0178 Compare October 24, 2017 07:07
@pamil pamil merged commit de016ee into Sylius:master Oct 24, 2017
@pamil

pamil commented Oct 24, 2017

Copy link
Copy Markdown
Contributor

Thanks @Lowlo & @GSadee, especially for your patience! :)

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

Successfully merging this pull request may close these issues.

RFC - Translatable atribute values behavior

4 participants