Open monstromatic opened 5 years ago
Hmm, I'm not 100% sure I understand what you mean with: "My global contains 2 localized collections". Do you mean you reference collections from a Global (so it's related data)?
Can you share the Global fieldset and Global data (just sample data, doesn't haven't have to be "real") so that I can try and recreate the issue on my end.
Yes that's it :-)
Here is the footer global data in the default locale (site/content/globals/footer.yaml):
footer_title: 'Come see us!'
addresses_collection:
- 31c18869-c380-41c4-8f6a-76bb69992711
page_links:
- d30c66fb-954d-4d23-94b2-1d566dd65bf5
external_links:
- dc2997dd-c597-43e4-bd76-789479625154
copywrite: 'All Rights Reserved.'
title: Footer
fieldset: footer_globals
id: 12d6d17e-22d9-444a-bca3-5c8f57cf2fe3
Here is the translated footer global data (site/content/globals/fr/footer.yaml): site/content/globals/fr/footer.yaml
footer_title: 'Passez nous voir !'
copywrite: 'Tous droits réservés.'
id: 12d6d17e-22d9-444a-bca3-5c8f57cf2fe3
Here is the footer_globals fieldset:
sections:
main:
display: Main
fields:
footer_title:
type: text
localizable: true
display: 'Footer title'
addresses_collection:
collection:
- addresses
mode: panes
type: collection
display: 'Addresses Collection'
localizable: true
page_links:
type: pages
display: 'Page links'
mode: panes
localizable: true
external_links:
collection:
- external-links
mode: panes
type: collection
localizable: true
display: 'External links'
copywrite:
type: text
display: Copywrite
localizable: true
title: 'Footer Globals'
hide: true
taxonomies: true
Thanks a lot for your help!
Great, thanks for the example data!
I can't make any promises in terms of timeline, but I'll try and have a look at this when I next have some time available!
Hello,
Any update about that? The bug appears not only on globals but on pages too. It is a huge issue for my project cause I'll have multiple langues and a lot of collections... Maybe in the goDeep function?
Hey @monstromatic, I had a look at this today (took a while to dig up a multilingual site) but everything seems to be working as expected.
/!/Fetch/global/global?locale=nl
and the correct locale was shown in the data{{ fetch global="global" locale="nl" }}
which also showed correct locale dataCan you confirm that you're on the latest version of Fetch (v4.3.1)? And which version of Statamic are you using?
Hey! Thanks for digging! Yes I use Statamic 2.11.3 et Fetch 4.3.1. I still have the issue, even with pages and pages with mounted collection.
"First level" data are localized as excepted but related datas with id (like: addresses_collection:
Hmm, maybe I didn't nest deep enough. I'll try and add an additional level of related data to the entries and see if that shows the bug you are experiencing.
If not, perhaps you are able/willing to share your existing project (privately) to make the recreation process easier on my end?
Thank you so much for trying! The project actually run locally but I could try to give you a kind of "package" for testing. Feel free to ask me for testing some code changes in Fetch.php in my project, I am working on it all day long 7/7...
Hey @monstromatic, I did some further digging and there's definitely something funky going on when data is nested deeper than 1-2 levels. I'm not seeing your bug, but hitting something else atm.
Either way, this is currently out of scope of what I have time for unfortunately. I can take 1 final crack at it if you ZIP up your project (removing all sensitive data, e.g. passwords, keys, etc) and emailing me at aryeh.raber@gmail.com. I'll try and at least look at your particular issue, but can't promise anything.
I ran into a very similar issue to the one described above, and I was able to resolve it with a very small change to Fetch.php
.
I doubt it will be any help to OP after all this time, but below is the fix anyway:
In the relatedData($value, $key)
function, change
if (Content::exists($value)) {
return Content::find($value)->toArray();
}
to
if (Content::exists($value)) {
if ($this->locale !== default_locale()) {
return Content::find($value)->in($this->locale)->toArray();
}
return Content::find($value)->toArray();
}
Hello
My global contains 2 localized collections and localized text vars. When I switch the "locale", the vars are updated but the collections stay in the default locale.
When I switch from english to french {{ fetch global="footer" locale="fr" }} => text vars change as excepted but collections don't. Any idea?