diff --git a/.eleventy.js b/.eleventy.js index b2a8f24..fb4a87f 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -3,9 +3,9 @@ const fs = require("fs"); const fluidPlugin = require("eleventy-plugin-fluid"); const navigationPlugin = require("@11ty/eleventy-navigation"); +const i18n = require("eleventy-plugin-i18n-gettext"); const wrap = require("./src/shortcodes/wrap.js"); const generateLocaleLinks = require("./src/shortcodes/generateLocaleLinks.js"); -const translate = require("./src/shortcodes/translate.js"); // Import data files const siteConfig = require("./src/_data/config.json"); @@ -16,6 +16,9 @@ module.exports = function (config) { // Plugins config.addPlugin(fluidPlugin); config.addPlugin(navigationPlugin); + config.addPlugin(i18n, { + localesDirectory: "src/locales" + }); // Shortcodes config.addPairedShortcode("unmarkedList", (content) => wrap(content, "idg-unmarkedList")); @@ -23,7 +26,9 @@ module.exports = function (config) { return ``; }); config.addShortcode("localeLink", generateLocaleLinks); - config.addShortcode("translate", translate); + config.addShortcode("gettext_var", (locale, str) => { + return i18n._(locale, str); + }); // Passthrough copy config.addPassthroughCopy({"src/_redirects": "_redirects"}); diff --git a/.fluidlintallrc.json b/.fluidlintallrc.json index c9de747..b22ccf7 100644 --- a/.fluidlintallrc.json +++ b/.fluidlintallrc.json @@ -1,7 +1,8 @@ { "eslint": { "js": { - "includes": ["./.eleventy.js"] + "includes": ["./.eleventy.js"], + "excludes": ["./src/locales/messages.js"] } }, "lintspaces": { @@ -10,7 +11,8 @@ }, "newlines": { "excludes": [ - "./src/**/*.ttf" + "./src/**/*.ttf", + "./src/locales/**/*.*" ] } }, diff --git a/README.md b/README.md index a5fe280..824380c 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,61 @@ If you make changes to the website, repeat the steps to build the image and star If you make changes to the website, repeat step 2 to build the website and upload any changed files from the `./dist/` directory to the web root of your server. +### Localization/Internationalization + +#### Default langauge + +The default language is specified in `src/_data/config.json` under the `defaultLanguage` property. This must +coorespond to a configured language locale and will instruct the site to generate the site with this as the +default localization. + +The default localization locale will not be added to the URL; however, all other localizations will include the +locale in the URL. + +#### Localizing content + +The site content is contained in Markdown (.md) files located in the `documents` directory. The `documents` directory is +organized into sub-directories for each category of documents and a generic `pages` directory. All of these are further +dividid into sub-directories for each locale. + +The locale directories in a category and the pages directory should be contain the same Markdown files. However, their +contents and front matter `title` will be localized in their respective locale. Additionally each will contain an +[11ty data file](https://www.11ty.dev/docs/data-template-dir/) that provides localization data for rendering the page. + +#### Localizing other text + +To provide specific localizations for text in layouts, partials, and other areas, +[eleventy-plugin-i18n-gettext](https://www.npmjs.com/package/eleventy-plugin-i18n-gettext) is used to provide a +[gettext](https://www.gnu.org/software/gettext/) based approached. + +Calls can either be made in JavaScript or in template files using function, shortcodes, or filters. See the plugin's +[API Usage](https://www.npmjs.com/package/eleventy-plugin-i18n-gettext#api-usage) for more details. + +_**NOTE**: Due to [issue #22](https://github.com/sgissinger/eleventy-plugin-i18n-gettext/issues/22) when passing in the +locale, it needs to use a variable called `locale`_ + +_**NOTE**: Due to [issue #23](https://github.com/sgissinger/eleventy-plugin-i18n-gettext/issues/23) when passing in the +`key`, if it isn't plain text it will not be included in messages.js. A workaround, if a variable is being used, is to +make a call with the resolved text elsewhere. For examplethe category names, used in URLs, are explicitly called in +`src/_data/site.js`_ + +When generating a build, gettext style calls are automatically found and added to `src/locales/messages.js` which can +be used to update .po files. The simplest way is to use an PO editor such as [poedit](https://poedit.net). See: +[Poedit configuration for translations extraction](https://github.com/sgissinger/eleventy-plugin-i18n-gettext/blob/HEAD/docs/Manage-translations-with-Poedit.md) + +#### Adding new locales + +Steps for adding additional locales. + +1. Add configuration for the locale under the `languages` property in `src/_data/config.json`. +2. For each directory under `src/documents` duplicate the `en-CA` directory and rename based on the new locale + 1. In the new directory rename the 11tydata file after the new directory name. + 2. Localize all of the Markdown files' `title` front matter and content. +3. In `src/locales` duplicate the `fr` directory and rename based on the new locale + 1. Update the `messages.po` and `messages.mo` files in the new directory for the new locale. + 1. Update the `Language` + 2. Update the localized text + ## License Information The Inclusive Design Guide's code is licensed under the [BSD diff --git a/package-lock.json b/package-lock.json index 119a6f9..4092b84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4399,6 +4399,12 @@ "integrity": "sha512-Z6DoceYb/1xSg5+e+ZlPZ9v0N16ZvZ+wYMraFue4HYrE4ttONKtsvruIRf6t9TBR0YvSOfi1hUU0fJfBLCDYow==", "dev": true }, + "@types/babel-types": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/babel-types/-/babel-types-7.0.11.tgz", + "integrity": "sha512-pkPtJUUY+Vwv6B1inAz55rQvivClHJxc9aVEPPmaq2cbyeMLCiDpbKpcKyX4LAwpNGi+SHBv0tHv6+0gXv0P2A==", + "dev": true + }, "@types/babel__core": { "version": "7.1.15", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.15.tgz", @@ -4440,6 +4446,15 @@ "@babel/types": "^7.3.0" } }, + "@types/babylon": { + "version": "6.16.6", + "resolved": "https://registry.npmjs.org/@types/babylon/-/babylon-6.16.6.tgz", + "integrity": "sha512-G4yqdVlhr6YhzLXFKy5F7HtRBU8Y23+iWy7UKthMq/OSQnL1hbsoeXESQ2LY8zEDlknipDG3nRGhUC9tkwvy/w==", + "dev": true, + "requires": { + "@types/babel-types": "*" + } + }, "@types/clean-css": { "version": "4.2.5", "resolved": "https://registry.npmjs.org/@types/clean-css/-/clean-css-4.2.5.tgz", @@ -4836,6 +4851,23 @@ "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "dev": true }, + "acorn-globals": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-3.1.0.tgz", + "integrity": "sha1-/YJw9x+7SZawBPqIDuXUZXOnMb8=", + "dev": true, + "requires": { + "acorn": "^4.0.4" + }, + "dependencies": { + "acorn": { + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", + "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "dev": true + } + } + }, "acorn-import-assertions": { "version": "1.7.6", "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.7.6.tgz", @@ -4898,6 +4930,34 @@ "uri-js": "^4.2.2" } }, + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "dev": true, + "requires": { + "kind-of": "^3.0.2", + "longest": "^1.0.1", + "repeat-string": "^1.5.2" + }, + "dependencies": { + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, "alphanum-sort": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/alphanum-sort/-/alphanum-sort-1.0.2.tgz", @@ -5198,6 +5258,44 @@ "@babel/helper-define-polyfill-provider": "^0.2.2" } }, + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + }, + "dependencies": { + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + } + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" + }, + "dependencies": { + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + } + } + }, "babel-walk": { "version": "3.0.0-canary-5", "resolved": "https://registry.npmjs.org/babel-walk/-/babel-walk-3.0.0-canary-5.tgz", @@ -5206,6 +5304,12 @@ "@babel/types": "^7.9.6" } }, + "babylon": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", + "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==", + "dev": true + }, "backo2": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", @@ -5667,6 +5771,16 @@ "integrity": "sha512-vlNK021QdI7PNeiUh/lKkC/mNHHfV0m/Ad5JoI0TYtlBnJAslM/JIkm/tGC88bkLIwO6OQ5uV6ztS6kVAtCDlg==", "dev": true }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "dev": true, + "requires": { + "align-text": "^0.1.3", + "lazy-cache": "^1.0.3" + } + }, "chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -6322,6 +6436,12 @@ "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", "dev": true }, + "core-js": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", + "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", + "dev": true + }, "core-js-compat": { "version": "3.16.1", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.16.1.tgz", @@ -7185,6 +7305,372 @@ } } }, + "eleventy-plugin-i18n-gettext": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/eleventy-plugin-i18n-gettext/-/eleventy-plugin-i18n-gettext-1.5.1.tgz", + "integrity": "sha512-dGLut8gJcIkWjf7kg73YIYUSFOgoQpEtigCzwM3383EGnjfpb/BliPYRejFpBqcbZ/JXWXn98alH4iEPLgOAWQ==", + "dev": true, + "requires": { + "@11ty/eleventy": "^0.11.0", + "gettext-parser": "^4.0.4", + "glob": "^7.1.6", + "moment-timezone": "^0.5.31", + "node-gettext": "^3.0.0", + "printf": "^0.5.3" + }, + "dependencies": { + "@11ty/eleventy": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/@11ty/eleventy/-/eleventy-0.11.1.tgz", + "integrity": "sha512-90iTOifuiRN92gttDFMeGsAuG0/5XwsKvCn/9d5CHYUO80Okq0biSJxr69abYmOstg9jHfkaVxuPkcs4feRb8Q==", + "dev": true, + "requires": { + "@11ty/dependency-tree": "^1.0.0", + "browser-sync": "^2.26.13", + "chalk": "^3.0.0", + "chokidar": "^3.4.0", + "debug": "^4.1.1", + "dependency-graph": "^0.9.0", + "ejs": "^2.7.4", + "fast-glob": "^3.2.2", + "fs-extra": "^8.1.0", + "gray-matter": "^4.0.2", + "hamljs": "^0.6.2", + "handlebars": "^4.7.6", + "javascript-stringify": "^2.0.1", + "liquidjs": "^6.4.3", + "lodash": "^4.17.15", + "luxon": "^1.24.1", + "markdown-it": "^10.0.0", + "minimist": "^1.2.5", + "moo": "^0.5.1", + "multimatch": "^4.0.0", + "mustache": "^2.3.2", + "normalize-path": "^3.0.0", + "nunjucks": "^3.2.1", + "parse-filepath": "^1.0.2", + "please-upgrade-node": "^3.2.0", + "pretty": "^2.0.0", + "pug": "^2.0.4", + "recursive-copy": "^2.0.10", + "semver": "^7.3.2", + "slugify": "^1.4.0", + "time-require": "^0.1.2", + "valid-url": "^1.0.9" + } + }, + "acorn": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true + }, + "chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "requires": { + "center-align": "^0.1.1", + "right-align": "^0.1.1", + "wordwrap": "0.0.2" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "constantinople": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/constantinople/-/constantinople-3.1.2.tgz", + "integrity": "sha512-yePcBqEFhLOqSBtwYOGGS1exHo/s1xjekXiinh4itpNQGCu4KA1euPh1fg07N2wMITZXQkBz75Ntdt1ctGZouw==", + "dev": true, + "requires": { + "@types/babel-types": "^7.0.0", + "@types/babylon": "^6.16.2", + "babel-types": "^6.26.0", + "babylon": "^6.18.0" + } + }, + "dependency-graph": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/dependency-graph/-/dependency-graph-0.9.0.tgz", + "integrity": "sha512-9YLIBURXj4DJMFALxXw9K3Y3rwb5Fk0X5/8ipCzaN84+gKxoHK43tVKRNakCQbiEx07E8Uwhuq21BpUagFhZ8w==", + "dev": true + }, + "is-expression": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-expression/-/is-expression-3.0.0.tgz", + "integrity": "sha1-Oayqa+f9HzRx3ELHQW5hwkMXrJ8=", + "dev": true, + "requires": { + "acorn": "~4.0.2", + "object-assign": "^4.0.1" + }, + "dependencies": { + "acorn": { + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", + "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "dev": true + } + } + }, + "linkify-it": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz", + "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==", + "dev": true, + "requires": { + "uc.micro": "^1.0.1" + } + }, + "markdown-it": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-10.0.0.tgz", + "integrity": "sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "entities": "~2.0.0", + "linkify-it": "^2.0.0", + "mdurl": "^1.0.1", + "uc.micro": "^1.0.5" + } + }, + "pug": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pug/-/pug-2.0.4.tgz", + "integrity": "sha512-XhoaDlvi6NIzL49nu094R2NA6P37ijtgMDuWE+ofekDChvfKnzFal60bhSdiy8y2PBO6fmz3oMEIcfpBVRUdvw==", + "dev": true, + "requires": { + "pug-code-gen": "^2.0.2", + "pug-filters": "^3.1.1", + "pug-lexer": "^4.1.0", + "pug-linker": "^3.0.6", + "pug-load": "^2.0.12", + "pug-parser": "^5.0.1", + "pug-runtime": "^2.0.5", + "pug-strip-comments": "^1.0.4" + } + }, + "pug-attrs": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pug-attrs/-/pug-attrs-2.0.4.tgz", + "integrity": "sha512-TaZ4Z2TWUPDJcV3wjU3RtUXMrd3kM4Wzjbe3EWnSsZPsJ3LDI0F3yCnf2/W7PPFF+edUFQ0HgDL1IoxSz5K8EQ==", + "dev": true, + "requires": { + "constantinople": "^3.0.1", + "js-stringify": "^1.0.1", + "pug-runtime": "^2.0.5" + } + }, + "pug-code-gen": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pug-code-gen/-/pug-code-gen-2.0.3.tgz", + "integrity": "sha512-r9sezXdDuZJfW9J91TN/2LFbiqDhmltTFmGpHTsGdrNGp3p4SxAjjXEfnuK2e4ywYsRIVP0NeLbSAMHUcaX1EA==", + "dev": true, + "requires": { + "constantinople": "^3.1.2", + "doctypes": "^1.1.0", + "js-stringify": "^1.0.1", + "pug-attrs": "^2.0.4", + "pug-error": "^1.3.3", + "pug-runtime": "^2.0.5", + "void-elements": "^2.0.1", + "with": "^5.0.0" + } + }, + "pug-error": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/pug-error/-/pug-error-1.3.3.tgz", + "integrity": "sha512-qE3YhESP2mRAWMFJgKdtT5D7ckThRScXRwkfo+Erqga7dyJdY3ZquspprMCj/9sJ2ijm5hXFWQE/A3l4poMWiQ==", + "dev": true + }, + "pug-filters": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/pug-filters/-/pug-filters-3.1.1.tgz", + "integrity": "sha512-lFfjNyGEyVWC4BwX0WyvkoWLapI5xHSM3xZJFUhx4JM4XyyRdO8Aucc6pCygnqV2uSgJFaJWW3Ft1wCWSoQkQg==", + "dev": true, + "requires": { + "clean-css": "^4.1.11", + "constantinople": "^3.0.1", + "jstransformer": "1.0.0", + "pug-error": "^1.3.3", + "pug-walk": "^1.1.8", + "resolve": "^1.1.6", + "uglify-js": "^2.6.1" + } + }, + "pug-lexer": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/pug-lexer/-/pug-lexer-4.1.0.tgz", + "integrity": "sha512-i55yzEBtjm0mlplW4LoANq7k3S8gDdfC6+LThGEvsK4FuobcKfDAwt6V4jKPH9RtiE3a2Akfg5UpafZ1OksaPA==", + "dev": true, + "requires": { + "character-parser": "^2.1.1", + "is-expression": "^3.0.0", + "pug-error": "^1.3.3" + } + }, + "pug-linker": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/pug-linker/-/pug-linker-3.0.6.tgz", + "integrity": "sha512-bagfuHttfQOpANGy1Y6NJ+0mNb7dD2MswFG2ZKj22s8g0wVsojpRlqveEQHmgXXcfROB2RT6oqbPYr9EN2ZWzg==", + "dev": true, + "requires": { + "pug-error": "^1.3.3", + "pug-walk": "^1.1.8" + } + }, + "pug-load": { + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/pug-load/-/pug-load-2.0.12.tgz", + "integrity": "sha512-UqpgGpyyXRYgJs/X60sE6SIf8UBsmcHYKNaOccyVLEuT6OPBIMo6xMPhoJnqtB3Q3BbO4Z3Bjz5qDsUWh4rXsg==", + "dev": true, + "requires": { + "object-assign": "^4.1.0", + "pug-walk": "^1.1.8" + } + }, + "pug-parser": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/pug-parser/-/pug-parser-5.0.1.tgz", + "integrity": "sha512-nGHqK+w07p5/PsPIyzkTQfzlYfuqoiGjaoqHv1LjOv2ZLXmGX1O+4Vcvps+P4LhxZ3drYSljjq4b+Naid126wA==", + "dev": true, + "requires": { + "pug-error": "^1.3.3", + "token-stream": "0.0.1" + } + }, + "pug-runtime": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/pug-runtime/-/pug-runtime-2.0.5.tgz", + "integrity": "sha512-P+rXKn9un4fQY77wtpcuFyvFaBww7/91f3jHa154qU26qFAnOe6SW1CbIDcxiG5lLK9HazYrMCCuDvNgDQNptw==", + "dev": true + }, + "pug-strip-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/pug-strip-comments/-/pug-strip-comments-1.0.4.tgz", + "integrity": "sha512-i5j/9CS4yFhSxHp5iKPHwigaig/VV9g+FgReLJWWHEHbvKsbqL0oP/K5ubuLco6Wu3Kan5p7u7qk8A4oLLh6vw==", + "dev": true, + "requires": { + "pug-error": "^1.3.3" + } + }, + "pug-walk": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pug-walk/-/pug-walk-1.1.8.tgz", + "integrity": "sha512-GMu3M5nUL3fju4/egXwZO0XLi6fW/K3T3VTgFQ14GxNi8btlxgT5qZL//JwZFm/2Fa64J/PNS8AZeys3wiMkVA==", + "dev": true + }, + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "token-stream": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/token-stream/-/token-stream-0.0.1.tgz", + "integrity": "sha1-zu78cXp2xDFvEm0LnbqlXX598Bo=", + "dev": true + }, + "uglify-js": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", + "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "dev": true, + "requires": { + "source-map": "~0.5.1", + "uglify-to-browserify": "~1.0.0", + "yargs": "~3.10.0" + } + }, + "void-elements": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", + "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", + "dev": true + }, + "with": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/with/-/with-5.1.1.tgz", + "integrity": "sha1-+k2qktrzLE6pTtRTyB8EaGtXXf4=", + "dev": true, + "requires": { + "acorn": "^3.1.0", + "acorn-globals": "^3.0.0" + } + }, + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "requires": { + "camelcase": "^1.0.2", + "cliui": "^2.1.0", + "decamelize": "^1.0.0", + "window-size": "0.1.0" + } + } + } + }, "elliptic": { "version": "6.5.4", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", @@ -7225,6 +7711,26 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, + "encoding": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", + "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", + "dev": true, + "requires": { + "iconv-lite": "^0.6.2" + }, + "dependencies": { + "iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + } + } + }, "engine.io": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.5.0.tgz", @@ -8369,6 +8875,26 @@ "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", "dev": true }, + "gettext-parser": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-4.0.4.tgz", + "integrity": "sha512-VDZEeOIYd0veZXt5iAn0SS3I0Fz14fJw+59avRNa7VIslEDriRLxcfrBd/xeQyOcm6nyS4uuufxm2iw88qirAg==", + "dev": true, + "requires": { + "content-type": "^1.0.4", + "encoding": "^0.1.13", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + } + } + }, "git-raw-commits": { "version": "2.0.10", "resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-2.0.10.tgz", @@ -10490,6 +11016,12 @@ } } }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true + }, "levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -10694,6 +11226,12 @@ "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", "dev": true }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true + }, "lodash.isfinite": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/lodash.isfinite/-/lodash.isfinite-3.3.2.tgz", @@ -10733,6 +11271,12 @@ "is-unicode-supported": "^0.1.0" } }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, "longest-streak": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-2.0.4.tgz", @@ -11502,6 +12046,21 @@ "minimist": "^1.2.5" } }, + "moment": { + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", + "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==", + "dev": true + }, + "moment-timezone": { + "version": "0.5.33", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.33.tgz", + "integrity": "sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==", + "dev": true, + "requires": { + "moment": ">= 2.9.0" + } + }, "moo": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/moo/-/moo-0.5.1.tgz", @@ -11596,6 +12155,15 @@ "integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==", "dev": true }, + "node-gettext": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/node-gettext/-/node-gettext-3.0.0.tgz", + "integrity": "sha512-/VRYibXmVoN6tnSAY2JWhNRhWYJ8Cd844jrZU/DwLVoI4vBI6ceYbd8i42sYZ9uOgDH3S7vslIKOWV/ZrT2YBA==", + "dev": true, + "requires": { + "lodash.get": "^4.4.2" + } + }, "node-libs-browser": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.1.tgz", @@ -13473,6 +14041,12 @@ "integrity": "sha512-28iF6xPQrP8Oa6uxE6a1biz+lWeTOAPKggvjB8HAs6nVMKZwf5bG++632Dx614hIWgUPkgivRfG+a8uAXGTIbA==", "dev": true }, + "printf": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/printf/-/printf-0.5.3.tgz", + "integrity": "sha512-t3lYN6vPU5PZXDiEZZqoyXvN8wCsBfi8gPoxTKo2e5hhV673t/KUh+mfO8P8lCOCDC/BWcOGIxKyebxc5FuqLA==", + "dev": true + }, "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -14207,6 +14781,15 @@ "integrity": "sha1-QzdOLiyglosO8VI0YLfXMP8i7rM=", "dev": true }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "dev": true, + "requires": { + "align-text": "^0.1.1" + } + }, "rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -16124,6 +16707,13 @@ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.1.tgz", "integrity": "sha512-JhS3hmcVaXlp/xSo3PKY5R0JqKs5M3IV+exdLHW99qKvKivPO4Z8qbej6mte17SOPqAOVMjt/XGgWacnFSzM3g==" }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true, + "optional": true + }, "unc-path-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", @@ -16939,6 +17529,12 @@ "integrity": "sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==", "dev": true }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true + }, "with": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/with/-/with-7.0.2.tgz", diff --git a/package.json b/package.json index 507a81a..4a471c3 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@commitlint/config-conventional": "13.1.0", "cross-env": "7.0.3", "debug": "4.3.2", + "eleventy-plugin-i18n-gettext": "1.5.1", "fluid-lint-all": "1.1.5", "html-minifier": "4.0.0", "husky": "4.3.0", diff --git a/src/_data/site.js b/src/_data/site.js new file mode 100644 index 0000000..1c18dd8 --- /dev/null +++ b/src/_data/site.js @@ -0,0 +1,30 @@ +"use strict"; + +const i18n = require("eleventy-plugin-i18n-gettext"); + +module.exports = () => { + // NOTE: Due to [issue #22](https://github.com/sgissinger/eleventy-plugin-i18n-gettext/issues/22) when passing in + // the locale, it needs to use a variable called `locale`. + let locale = "en-CA"; + + // NOTE: Due to [issue #23](https://github.com/sgissinger/eleventy-plugin-i18n-gettext/issues/23) when passing in + // the `key`, if it isn't plain text it will not be included in messages.js. The following is not returned to the + // site data, but it is used to force translations for the category types. + /* eslint-disable-next-line no-unused-vars */ + let categories = { + "activities": i18n._(locale, "activities"), + "insights": i18n._(locale, "insights"), + "practices": i18n._(locale, "practices"), + "tools": i18n._(locale, "tools") + }; + + return { + "title": i18n._(locale, "The Inclusive Design Guide"), + "license": i18n._(locale, "Creative Commons CC BY 3.0"), + "licenseURL": i18n._(locale, "https://creativecommons.org/licenses/by/3.0/"), + "org": i18n._(locale, "Inclusive Design Research Centre"), + "orgURL": i18n._(locale, "https://idrc.ocad.ca/"), + "ocad": i18n._(locale, "OCAD University"), + "ocadURL": i18n._(locale, "https://www.ocadu.ca/") + }; +}; diff --git a/src/_data/site.json b/src/_data/site.json deleted file mode 100644 index 87ad425..0000000 --- a/src/_data/site.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "en-CA": { - "title": "The Inclusive Design Guide", - "license": "Creative Commons CC BY 3.0", - "licenseURL": "http://creativecommons.org/licenses/by/3.0/", - "org": "Inclusive Design Research Centre", - "orgURL": "http://idrc.ocad.ca/", - "ocad": "OCAD University", - "ocadURL": "http://www.ocadu.ca/" - }, - "fr": { - "title": "Guide pour une conception inclusive", - "license": "Creative Commons CC BY 3.0", - "licenseURL": "https://creativecommons.org/licenses/by/3.0/deed.fr", - "org": "Centre de Recherche pour une Conception Inclusive", - "orgURL": "http://idrc.ocad.ca/", - "ocad": "l'Université de l'École d'art et de design de l'Ontario (OCAD University)", - "ocadURL": "http://www.ocadu.ca/" - } -} diff --git a/src/_data/translations.json b/src/_data/translations.json deleted file mode 100644 index f181476..0000000 --- a/src/_data/translations.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "en-CA": { - "activities": "activities", - "insights": "insights", - "practices": "practices", - "tools": "tools", - "skipLink": "Skip to Content", - "breadcrumb": "Breadcrumb", - "home": "Home", - "contents": "contents", - "edit": "Edit this Page on GitHub", - "footer": { - "createdBy": "Created by the", - "communityMembers": "community members", - "of": "of the", - "at": "at", - "supportedBy": "and supported by", - "hostedWith": "Hosted with", - "licensedUnder": "This documentation is licensed under a" - } - }, - "fr": { - "activities": "activités", - "insights": "perspectives", - "practices": "pratiques", - "tools": "outils", - "skipLink": "Accès direct au contenu", - "breadcrumb": "Fil d'Ariane", - "home": "Accueil", - "contents": "sommaire", - "edit": "modifier cette page sur GitHub", - "footer": { - "createdBy": "Créé par la", - "communityMembers": "communauté des membres", - "of": "du", - "at": "de", - "supportedBy": "avec le soutien de", - "hostedWith": "Hébergé par", - "licensedUnder": "Le contenu de ce site est sous licence" - } - } -} diff --git a/src/_includes/layouts/base.njk b/src/_includes/layouts/base.njk index 0d60fea..e48f64a 100644 --- a/src/_includes/layouts/base.njk +++ b/src/_includes/layouts/base.njk @@ -1,6 +1,5 @@ -{% set lang %}{{ lang | default(config.defaultLanguage) }}{% endset %} - + {% include 'partials/head-matter.njk' %} @@ -21,6 +20,6 @@ {% include 'partials/footer.njk' %} - {% uioInit config.languages[lang].uioSlug, config.languages[lang].dir %} + {% uioInit config.languages[locale].uioSlug, langDir %} diff --git a/src/_includes/layouts/category.njk b/src/_includes/layouts/category.njk index eff097c..86000e3 100644 --- a/src/_includes/layouts/category.njk +++ b/src/_includes/layouts/category.njk @@ -6,16 +6,16 @@ {{ page.filePathStem}}.md {% endset %} -{% set navPages = collections[category + "_" + lang] | eleventyNavigationBreadcrumb(eleventyNavigation.key) %} +{% set navPages = collections[category + "_" + locale] | eleventyNavigationBreadcrumb(eleventyNavigation.key) %} {% block content %}
-