$ show untra/polyglot
Polyglot is a Ruby gem that serves as a Jekyll plugin for internationalization (i18n) of static sites. It enables building a site in multiple languages by forking the Jekyll build process per language, patching core Jekyll classes (`Site`, `StaticFile`) to handle language-specific files, and providing Liquid tags for SEO headers (`I18n_Headers`) and URL relativization control (`static_href`). The plugin coordinates documents across languages, supports fallback to the default language, localizes `site.data` via language-specific subdirectories, and generates Netlify-compatible redirects. It is not a standalone application but a library that integrates deeply with Jekyll via hooks and monkey-patching. The repository includes a comprehensive demo site with 18 languages, a full RSpec test suite, CI via CircleCI, and extensive documentation in both README and `ai_docs/`. The codebase is well-structured, with clear separation of concerns (hooks, patches, liquid tags), and demonstrates non-trivial engineering in areas like parallel forking, regex-based URL relativization, and document coordination.
The LLM identified 3 files worth highlighting for reuse:
A self-contained Liquid tag that generates `<link rel='alternate' hreflang='...'>` tags for all available language versions of the current page. It also outputs a canonical link. The tag requires no internal Polyglot state beyond standard Jekyll page variables (`page.available_languages`, `page.url`, `site.url`). It can be extracted into any Jekyll project that needs SEO hreflang support, and is the recommended way to implement language alternates in static sites.
A Liquid block tag that prevents URL relativization for its contents. It temporarily disables Polyglot's `relative_url` and `absolute_url` filters within the block, allowing links to remain absolute (e.g., for CDN-hosted assets, external URLs). This is a clean, minimal implementation that solves a common pain point in multi-language Jekyll sites where automatic URL prefixing must be bypassed for specific regions.
A Jekyll hook (`:polyglot, :post_write`) that localizes Netlify `_redirects` files. It reads the generated `_redirects` from the default language site directory, and for each non-default language, it rewrites the redirect rules to include the language prefix. This is a self-contained utility that could be reused in any Jekyll project deploying to Netlify with multi-language support, demonstrating a clean pattern for post-build file manipulation.