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

i18n support #14

Open
seroperson opened this issue Feb 24, 2025 · 1 comment
Open

i18n support #14

seroperson opened this issue Feb 24, 2025 · 1 comment

Comments

@seroperson
Copy link

Hello! Thank you for your plugin! I'm using it in website with several locales and it seems missing some little tweaks:

  • If your page uses i18n key as a title (or description), this plugin displays it as a key, not a localized string
  • og:locale expects data.lang instead of data.locale

But probably there is something else. Thank you again for your work!

@seroperson
Copy link
Author

seroperson commented Feb 25, 2025

Temporary workaround using custom generator to substitute all title, description and lang fields:

class Builders::PostDataFixer < SiteBuilder
  def build
    # Fixing bridgetown-seo-tag i18n things
    generator do
      posts = site.collections.posts.resources
      posts.each do |post|
        post.data["lang"] = post.data["locale"]
      end
      
      pages = site.collections.pages
      pages.each do |page|
        helper = Bridgetown::RubyTemplateView::Helpers.new(page, site)
        locale = page.data["locale"]
        page.data["title"] = helper.t(page.data["title"], locale: locale)
        page.data["description"] = helper.t(page.data["description"], locale: locale)
        page.data["lang"] = locale
      end
    end
  end
end

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

1 participant