-
Notifications
You must be signed in to change notification settings - Fork 182
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
I18n and blog doesn't seem to cooperate when building the content collection #343
Comments
A potential workaround is creating a specialised page with the Credit to epochwolf and this thread (appeared after several searches). |
@andreamoro Yes there does seem to be issue with the page_articles not taking into account the options provided I need to create more tests for this. Do remember though that the i8n module used in core is not really supported in Blog and hacks need to happen - there should be more cross-over but blog still remains an extension. |
I can't get pagination, tags, and calendar to work with an i18n blog. The problem is the @iwarner how do you pass options to |
@clstudio haven't tried your solution, but I believe you still need to do something like |
@andreamoro It's not a solution :) |
Welcome to the club then @clstudio .
Hope the above can help. |
@iwarner what about having something in the after_configuration method that reads all the current path and overwrite both the Though, I suspect I may have been doing something wrong with too. Is the code below correct to have a locale in Italian?
I have been not expressly referencing the Thanks |
@andreamoro I have 4+ language blog all nicely managed in a single blog controller via {lang}. I tried several times to break it into 4+ separate blogs but failed tremendously at each attempt. In my case it's best to keep it together and find another fix. |
That's what I'm trying to achieve, but was unsuccessful so far.
Does your content reside into a single folder, with the language
identifiable via the path?
Would you mind sharing your structure and config.rb blog section?
Cheers
…On 15 May 2017 10:00, "clstudio" ***@***.***> wrote:
@andreamoro <https://github.com/andreamoro> I have 4+ language blog all
nicely managed in a single blog controller via {lang}. I tried several
times to break it into 4+ separate blogs but failed tremendously at each
attempt. In my case it's best to keep it together and find another fix.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#343 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFA1h16EsQPkHVuFs_hDal2dagxBvjZsks5r6BQngaJpZM4NSZvn>
.
|
I have created the following : https://iwarner.github.io/middleman-blog-test With the source code here : https://github.com/iwarner/middleman-blog-test This outlines some of the setup I do - please check out the config.rb There are definite issues with the page_articles on the index page. In config you can see I set locale on template files as such, but this needs to be better so what we can do
ready do
end |
@andreamoro The content resides as follows:
@iwarner Thanks, that looks interesting, looping through each blog. Need a bit more time figuring this out. |
So kind of you @iwarner |
Ok, I think I nailed down the issue with my configuration, which requires the By having this setting on, the blog extension seems to correctly import the locale setting from the i18n extension. Below the portion of my config.rb file for anybody else stumbling across this issue:
By doing so, I was able to achieve the following build output:
whilst the source is something like
I will be exploring some more pieces from @iwarner configuration as it is more efficient having the loop to generate the blog instances. |
Hiya Can you check the __middleman sitemap and make sure Tags / Archive pages have the correct locale option |
I was not generating them, but I did a test for the Tags in the meantime. Below the output.
The locale setting doesn't seem to be injected into the Tag, which is a bit annoying. This doesn't work also when the |
Yeah this is why I have the routine to push in the locale options. need to add template : true in the tag template frontmatter. |
So the |
This is why I created the repo and test site :) template: true - to files in here - https://github.com/iwarner/middleman-blog-test/tree/master/source/template |
Yes, you're right. Ok gotcha reading the code. Aside from this, does the "better_error" (which I learned its existence from you today) works for you. I cannot get anything other than standard error page. Sorry for the deviation. |
Make sure you also have
|
Yes, that's in place. |
Not sure if this is still an issue for you but I managed to make it work based on the previous code. Using the template: true in tags templates and category templates. Config.rb `# Make sure locals are available in all pages
end activate :blog do |blog| blog.tag_template = "localizable/tag.html" blog.custom_collections = { activate :blog do |blog| blog.tag_template = "localizable/tag.fr.html" blog.custom_collections = { activate :blog do |blog| blog.tag_template = "localizable/tag.es.html" blog.custom_collections = { This is a lot of monkey patching and I feel like it should be supported as a default feature using Middleman / Middleman blog. PS: I'm no ruby expert so please forgive my nooby code |
Hope this helps someone. I've been having some trouble with pagination and multi-lingual blogs specifically. I was trying to make two separate blog index pages that show all the content of the blog of 1 language. I managed to fix it by following these pointers:
We've got some other specifics in our configuration which also might help you. We have defined a locales = [:en, :nl]
locales.each_with_index do | locale, index |
# Blog
activate :blog do | blog |
# Locale path: first locale is mounted at root
path = index > 0 ? "#{locale}/" : ""
blog.name = "blog_#{locale}"
blog.permalink = "#{path}blog/{year}/{month}/{day}/{title}.html"
# See "Edit 3" to understand why this is so weird.
# blog.sources = "blog/{lang}/{year}-{month}-{day}-{engtitle}.html"
blog.sources = "blog/#{locale}/{lang}/{year}-{month}-{day}-{engtitle}.html"
blog.layout = "blog"
# Pagination
blog.paginate = true
blog.page_link = "page/{num}"
blog.per_page = 15
# Calendar
blog.calendar_template = "blog/calendar.html"
blog.year_link = "#{path}blog/{year}.html"
blog.month_link = "#{path}blog/{year}/{month}.html"
blog.day_link = "#{path}blog/{year}/{month}/{day}.html"
# Tags
blog.tag_template = "blog/tag.html"
blog.taglink = "#{path}blog/tag/{tag}.html"
# Use the global Middleman I18n.locale instead of the lang in the
# article's frontmatter
blog.preserve_locale = true
blog.custom_collections = {
author: {
link: "#{path}blog/author/{author}.html",
template: "blog/author.html"
}
}
end
end Using this configuration also works for the custom Edit: I have to admit that I'm also still using this helper function to fix the locale in blog overview pages, which might help cause the fact that this works:
Edit 2: This still doesn't work because now all files are added to the last blog (in this case Edit 3: I found a solution, but it is not as pretty as I had hoped. I changed this line in blog.sources = "blog/{lang}/{year}-{month}-{day}-{engtitle}.html" to this: blog.sources = "blog/#{locale}/{lang}/{year}-{month}-{day}-{engtitle}.html" I had to move all my blog posts from |
ℹ️ This issue is stale because it has been open for more than 90 days with no activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions. |
This issue is stale because it has been open for more than 90 days with no activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions. |
Expected behaviour
With the I18n module active, I would expect the locale to be read and page_articles collection to be populated accordingly to the current locale
Actual behaviour
Regardless the current locale, the default language is always used hence the wrong collection of articles is returned
Steps to reproduce the problem
Using the gist below, navigate in the blog file under each of the locale folder, you will see the Italian version outputting the english title.
https://github.com/andreamoro/middleman-sprockets-test.git
Additional information
A possible workaround I may have found is to query directly the sitemap object.
A
blog.local_articles(different-locale)
produce always 0 results despite content is in the sitemap.The issue above also creates problems with the pagination feature because of the erroneous dataset used. Although the right dataset could be queried with something like the below, in that case, the pagination will not be triggered anymore.
The text was updated successfully, but these errors were encountered: