bridgetownrb / bridgetown

A next-generation progressive site generator & fullstack framework, powered by Ruby
https://www.bridgetownrb.com
MIT License
1.16k stars 112 forks source link

key `locales' not found in attributes for new Bridgetown::Model::Base #681

Closed Jahija303 closed 1 year ago

Jahija303 commented 1 year ago

This appears when using multi locale files, either by naming the file with .multi.md extension (eg: index.multi.md) or adding "locale: multi" to front matter (docs: https://www.bridgetownrb.com/docs/internationalization#multi-locale-files). It does not show up otherwise, eg: having two separate files and naming them index.en.md, index.de.md.

Bridgetown Version: 1.2.0.beta4

To Reproduce Set "locale: multi" in front matter OR Use the .multi extension within the file name

Current behavior Logs: "key `locales' not found in attributes for new Bridgetown::Model::Base"

Expected behavior Do nothing

Computing environment (please complete the following information):

mattiasamilon commented 1 year ago

I seem to have the same problem, using the multi file extension.

rickychilcott commented 1 year ago

Can you give the full file name you are using and possibly a reproduction repo? I’m using multi locale via extension and front matter in my project on beta5

Gusser93 commented 1 year ago

Seems to be this line causing the message if no locales-attribute is defined in the frontmatter. But I don't have any experience with ruby. My example:

index.md (generates message)

---
layout: default
locale: multi
---

# Welcome to your new Bridgetown website.

{{ "welcome.intro" | t}}

index.md (no message)

---
layout: default
locale: multi
locales:
    - de
    - en
---

# Welcome to your new Bridgetown website.

{{ "welcome.intro" | t}}
jaredcwhite commented 1 year ago

Thanks for the additional context. I'm not sure there's any bug here…it may just be a warning which we could suppress because it's an optional key.