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

Feature Request: Leverage the data cascade for per-page contextual localisations #23

Open
chriskirknielsen opened this issue Aug 21, 2022 · 2 comments

Comments

@chriskirknielsen
Copy link

chriskirknielsen commented Aug 21, 2022

Hi there,

I like this plugin but ran into issues: I wanted to be able to add localised strings from context.
My reasoning behind not adding those strings into a global data file for each language is that longform content is a bit of a pain to organise.

For example, if a layout page (say your typical /about/ page) that needs a particular string localised that isn't within the content itself but a component outside the main layout, you might not want to have all that stuff in your en.json file and whatnot. By adding the translation within the page itself, you can keep your page's localised content contained within the same file. A minor convenience but in my case, it makes a lot of sense.

I have worked this idea into PR #24, let me know what you think.

Note that I nested the additional data under page to prevent key collisions. Prefixing with an underscore or setting a plugin option to a specific key might be a better idea, but keeping it simple for now.

I hope this all make sense, and I can provide a more fleshed out example if interested!

@adamduncan
Copy link
Owner

@chriskirknielsen Thank you for the suggestion and PR here. Apologies I wasn't more proactive in responding to this at the time. I hope you've found use in having forked this feature into what you're working on.

I definitely think this idea adds value, and would like to consider it alongside the broader open issues/requests (see comment re: project status), whether that's merging this as part of a minor version update, or integrating into a more fundamental rethink for a v1.0.0 release.

@chriskirknielsen
Copy link
Author

@adamduncan No worries! I did get my own solution running in the meantime, but it doesn't feel very clean despite being quite functional.

And that sounds like a plan! Feel free to ping me to discuss this if you'd like, happy to provide insight or feedback. There's probably also lots of room for improvement in my approach so taking time to consider it is the wisest option.

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

2 participants