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

Config can't remove unwanted available locales #672

Closed
lcharette opened this issue Mar 21, 2017 · 6 comments
Closed

Config can't remove unwanted available locales #672

lcharette opened this issue Mar 21, 2017 · 6 comments
Assignees
Labels
confirmed bug Something isn't working internationalization Related to the localization feature
Milestone

Comments

@lcharette
Copy link
Member

Setting the available locale in a sprinkle config file to remove the unwanted locale won't work. This only replace the locale displayed name.

            'locales' => [
                'available' => [
                    'fr_FR' => 'Français'
                ],
            ]

To solve this issue, available locale should only be an array of locale code ('available' => ['fr_FR', 'en_US']) and the locale name should be define elsewhere (locale metadata for example).

(Related to #671)

@lcharette lcharette added confirmed bug Something isn't working internationalization Related to the localization feature labels Mar 21, 2017
@lcharette lcharette added this to the 4.0 milestone Mar 21, 2017
@lcharette lcharette self-assigned this Mar 21, 2017
@alexweissman
Copy link
Member

As a short-term solution, what if userfrosting/config had a getDefined method that did the same thing as get, but then removed any keys from the sub-array that are assigned to null?

So then you could do:

            'locales' => [
                'available' => [
                    'fr_FR' => 'Français',
                    'en_US' => null,
                    'de_DE' => null,
                    ...
                ],
            ]

Then you could call $config->getDefined('site.locales.available') and it would strip out those null-valued keys.

@lcharette
Copy link
Member Author

I guess it could work. Any reason it couldn't be done in normal get? db/laravel settings?

@alexweissman
Copy link
Member

I mean, we could always do an array_walk or something to filter them out in the config service.

lcharette added a commit that referenced this issue Apr 6, 2017
Update settings-profile.html.twig

Temp fix for #672
@lcharette
Copy link
Member Author

See #682 for a temp fix.

@alexweissman
Copy link
Member

The more general problem here is the ability for a schema/config/whatever file loaded in a later Sprinkle, to remove (rather than simply overwrite) content from a previously loaded Sprinkle.

The question is, do we want to have something in the syntax of the files themselves that can do this? Otherwise, I think my getDefined approach might be the best.

@alexweissman alexweissman modified the milestones: 4.x, 4.1.0 Jun 13, 2017
@alexweissman
Copy link
Member

I'm going to close this because it's technically been fixed with the Repository::getDefined method.

The broader discussion about the correct way to store and load locale metadata can be continued in this issue: userfrosting/i18n#4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed bug Something isn't working internationalization Related to the localization feature
Projects
None yet
Development

No branches or pull requests

2 participants