You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I have been trying the method from the docs for generating pages from an external data source. In my case, these data are blog posts in multiple languages, and which posts are translations of each other is indicated by properties on the post items in the incoming JSON array.
I'm getting stuck with the Internationalization plugin. As far as I can tell from the plugin source code and documentation, translations for pages are found by comparing filenames. At least, that seems most likely given that the docs recommend files called en/about.md paired with es/about.md.
page.lang is getting set and the output is written to correct locale directories, but locale_links returns an empty array.
If the above assumption is correct, then the problem is because all the generated pages have the same origin file properties. For example, if I'm defining the pagination in a template called blog-articles.md, then if I log page for each generated page, inputPath, filePathStemp etc. all refer to that file. (interestingly, page.lang is unset when my permalink function is called, but it is set correctly when the page is rendered. The only thing happening is that I use data.article.lang to build the permalink).
I can't figure out how I would modify what the plugin sees for the input filename. Is there somewhere this can be set? Also, the plugin source code is a bit too convoluted to easily see what I would need to modify :)
I have tried various attempts at using the pagination before hook, but I can't modify the full data from there. I've made a few attempts with eleventyComputed but only half-heartedly because the docs imply I can't modify this type of properties from there ...
Does anyone have an idea how I can get the i18n plugin to see these data-generated pages as related?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi!
I have been trying the method from the docs for generating pages from an external data source. In my case, these data are blog posts in multiple languages, and which posts are translations of each other is indicated by properties on the post items in the incoming JSON array.
My template, blog-articles.md:
I'm getting stuck with the Internationalization plugin. As far as I can tell from the plugin source code and documentation, translations for pages are found by comparing filenames. At least, that seems most likely given that the docs recommend files called
en/about.md
paired withes/about.md
.page.lang
is getting set and the output is written to correct locale directories, butlocale_links
returns an empty array.If the above assumption is correct, then the problem is because all the generated pages have the same origin file properties. For example, if I'm defining the pagination in a template called
blog-articles.md
, then if I logpage
for each generated page,inputPath
,filePathStemp
etc. all refer to that file. (interestingly,page.lang
is unset when mypermalink
function is called, but it is set correctly when the page is rendered. The only thing happening is that I usedata.article.lang
to build the permalink).I can't figure out how I would modify what the plugin sees for the input filename. Is there somewhere this can be set? Also, the plugin source code is a bit too convoluted to easily see what I would need to modify :)
I have tried various attempts at using the pagination
before
hook, but I can't modify the full data from there. I've made a few attempts with eleventyComputed but only half-heartedly because the docs imply I can't modify this type of properties from there ...Does anyone have an idea how I can get the i18n plugin to see these data-generated pages as related?
Beta Was this translation helpful? Give feedback.
All reactions