Skip to content

Localization

Isaac edited this page Jul 23, 2026 · 1 revision

PWindows uses the Jekyll Polyglot plugin to build the website in multiple languages from one set of layouts and shared data.

Understand the public URLs

en-us is the default language. Default-language pages use the normal public routes without a language folder.

Language Homepage Example page
English (en-us) / /about
Simplified Chinese (zh-cn) /zh-cn/ /zh-cn/about

Do not create or link to /en-us/. The default language must stay at the site root so existing public links remain short and stable.

The language settings are declared in _config.yml:

languages: ["en-us", "zh-cn"]
default_lang: "en-us"
lang_from_path: true
parallel_localization: false

The first entry in languages must match default_lang. Localization is built serially because parallel Polyglot processes can race while updating Jekyll's shared cache. _config.windows.yml also keeps this setting disabled.

Link to pages correctly

Write internal links using the unprefixed public route:

<a href="{{ '/about' | relative_url }}">About</a>

Polyglot keeps that link as /about in the English build and changes it to /zh-cn/about in the Chinese build. Do not:

  • hard-code /en-us/ or /zh-cn/ into normal navigation links;
  • detect the browser language and redirect every visitor;
  • maintain a separate cookie-based routing system.

The language switcher is the exception. It deliberately links between language versions, so _includes/footer.html uses Polyglot's static_href tag. The switcher preserves the current page and gets its visible labels from _data/languages.yml.

Translate shared page content

Most pages use one source template and select translated values with site.active_lang:

{{ site.data.translations[site.active_lang].about.title }}

Add every interface string to both language sections in _data/translations.yml. Keep keys and nesting identical between languages.

Language names used by the switcher live in _data/languages.yml:

en-us:
  label: English
zh-cn:
  label: 简体中文

When adding a language to _config.yml, add its label and all required shared translations before building the site.

Translate structured data

Keep values that are the same in every language at the top level. Put visitor-facing text under each language code.

Games

- slug: example-game
  path: /games/example-game
  status: In development
  image: /assets/img/example-game.png
  engine: Unity
  language: C#
  effect: false
  en-us:
    title: Example Game
    summary: Information about the example game.
  zh-cn:
    title: 示例游戏
    summary: 示例游戏的信息。

Departments

example:
  path: /departments/example
  staff_department: Example
  en-us:
    name: Example Department
    bio: Responsible for the example area.
  zh-cn:
    name: 示例部门
    bio: 负责示例领域。

Staff

exampleperson:
  aboutpage: true
  department: Example
  pfp: /assets/staffpfp/example-person.png
  path: /staff/exampleperson
  en-us:
    name: Example Person
    role: Example Role
    bio: An English biography.
  zh-cn:
    name: 示例人员
    role: 示例职位
    bio: 中文简介。

Templates select these values with bracket notation:

{{ game[site.active_lang].title }}
{{ department[site.active_lang].bio }}
{{ person[site.active_lang].name }}

Locale-specific server addresses live under server.address in _data/site.yml. Shared external links remain single values.

Publish translated news

Each article translation is a separate Markdown file:

_articles/
├── en-us/example-update.md
└── zh-cn/example-update.md

Both files must:

  • have the same filename so they keep one base article route;
  • declare their language explicitly with lang: en-us or lang: zh-cn;
  • use layout: news;
  • translate the title, summary, and article body;
  • keep matching facts such as the date, author, banner, category, and featured state unless there is an intentional editorial reason not to.

The resulting addresses are /article/example-update and /zh-cn/article/example-update.

Metadata and sitemap behavior

The shared default layout:

  • sets the document's lang from site.active_lang;
  • uses Polyglot's I18n_Headers tag for canonical and hreflang links;
  • generates locale-aware Open Graph URLs.

The project generates one root sitemap.xml containing every supported language route. sitemap.xml and robots.txt are excluded from localization so duplicate files are not created inside language folders.

Do not add jekyll-sitemap back to the project while the custom multilingual sitemap is in use.

Verify localization changes

Run all commands in Running Checks, then inspect at least:

  • / and /zh-cn/;
  • the changed page in English and Chinese;
  • an English and Chinese news article when article behavior changed;
  • the footer language links on a normal page and an article;
  • sitemap.xml.

Confirm that:

  • there is no generated _site/en-us/ directory;
  • switching languages stays on the same page;
  • English links remain unprefixed;
  • Chinese internal links begin with /zh-cn/;
  • the <html lang> and canonical URL match the current language;
  • there is only one generated sitemap.xml and one robots.txt.

Return to Home.

Clone this wiki locally