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

Inconsistency between space/environments locales and default locale #204

Open
HQ063 opened this issue Jul 12, 2019 · 0 comments
Open

Inconsistency between space/environments locales and default locale #204

HQ063 opened this issue Jul 12, 2019 · 0 comments

Comments

@HQ063
Copy link
Contributor

HQ063 commented Jul 12, 2019

There is some inconsistency regarding locales and default locale on space and environment. The locales are defined in a specific environment, but the default locale is defined in the space. This leads to weird situations.
For example, the space object has a #default_locale method, but it has no #locales and the environment has a #locales but not a #default_locale, and when I query the defaul_locale
for an space I get a code that is not part of the allowed locales for the master environments.

[103] pry(main)> space = contentful_management.spaces.find('vyk520m9px5z')
[104] pry(main)> space.locales
NoMethodError: undefined method `locales' for #<Contentful::Management::Space:0x00007fdb22b87838>
[105] pry(main)> space.default_locale
=> "en-US"
[108] pry(main)> environment = space.environments.find('master')
[109] pry(main)> environment.default_locale
NoMethodError: undefined method `found_locale' for #<Contentful::Management::Environment:0x00007fdb251fefe8>
[112] pry(main)> environment.locales.all.collect(&:code)
=> ["en-CA", "fr-CA"]

So default_locale is en-US for an space that doesn't has en-US as available locale in any of the environments.

This should not be a big problem, except that when I retrieve a content_type from that environment, the default_locale for that content_type is also wrong.

[115] pry(main)> product = environment.content_types.find('product')
[116] pry(main)> product.default_locale
=> "en-US"

And that problem causes a lot of other bugs, for example: #201, #202, #203

I've read #73 and I know I can use product.client.configuration[:default_locale] = 'en-CA', but that changes the default_locale for the whole contentful management client, and I need to keep it independently for each space.

As a workaround I'm avoiding this problem with this:
product.define_singleton_method(:default_locale) { 'en-CA' } but doesn't feel like a real solution, it's more a temporal patch.

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

No branches or pull requests

1 participant