{"id":16327140,"url":"https://github.com/danguilherme/docpad-plugin-polyglot","last_synced_at":"2026-06-28T18:31:58.986Z","repository":{"id":57214154,"uuid":"88303780","full_name":"danguilherme/docpad-plugin-polyglot","owner":"danguilherme","description":"🌐 DocPad plugin for multilingual websites","archived":false,"fork":false,"pushed_at":"2017-04-21T08:20:34.000Z","size":48,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-26T21:58:20.241Z","etag":null,"topics":["docpad","docpad-plugin","i18n","multi-language"],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danguilherme.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-14T21:12:35.000Z","updated_at":"2017-11-08T11:48:05.000Z","dependencies_parsed_at":"2022-08-26T13:41:18.324Z","dependency_job_id":null,"html_url":"https://github.com/danguilherme/docpad-plugin-polyglot","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/danguilherme/docpad-plugin-polyglot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danguilherme%2Fdocpad-plugin-polyglot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danguilherme%2Fdocpad-plugin-polyglot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danguilherme%2Fdocpad-plugin-polyglot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danguilherme%2Fdocpad-plugin-polyglot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danguilherme","download_url":"https://codeload.github.com/danguilherme/docpad-plugin-polyglot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danguilherme%2Fdocpad-plugin-polyglot/sbom","scorecard":{"id":318981,"data":{"date":"2025-08-11","repo":{"name":"github.com/danguilherme/docpad-plugin-polyglot","commit":"2e3d6cf5783faf5f4c1df9fe3805127ec8432aa1"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: npmCommand not pinned by hash: docpad-setup.sh:3","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-18T00:55:47.915Z","repository_id":57214154,"created_at":"2025-08-18T00:55:47.915Z","updated_at":"2025-08-18T00:55:47.915Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34900367,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docpad","docpad-plugin","i18n","multi-language"],"created_at":"2024-10-10T23:10:30.285Z","updated_at":"2026-06-28T18:31:58.966Z","avatar_url":"https://github.com/danguilherme.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polyglot Plugin for [DocPad](http://docpad.org)\n\n\u003c!-- BADGES/ --\u003e\n\n\u003cspan class=\"badge-npmversion\"\u003e\u003ca href=\"https://npmjs.org/package/docpad-plugin-polyglot\" title=\"View this project on NPM\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/docpad-plugin-polyglot.svg\" alt=\"NPM version\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-npmdownloads\"\u003e\u003ca href=\"https://npmjs.org/package/docpad-plugin-polyglot\" title=\"View this project on NPM\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/docpad-plugin-polyglot.svg\" alt=\"NPM downloads\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-daviddm\"\u003e\u003ca href=\"https://david-dm.org/danguilherme/docpad-plugin-polyglot\" title=\"View the status of this project's dependencies on DavidDM\"\u003e\u003cimg src=\"https://img.shields.io/david/danguilherme/docpad-plugin-polyglot.svg\" alt=\"Dependency Status\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-daviddmdev\"\u003e\u003ca href=\"https://david-dm.org/danguilherme/docpad-plugin-polyglot#info=devDependencies\" title=\"View the status of this project's development dependencies on DavidDM\"\u003e\u003cimg src=\"https://img.shields.io/david/dev/danguilherme/docpad-plugin-polyglot.svg\" alt=\"Dev Dependency Status\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\n\u003c!-- /BADGES --\u003e\n\n\nAdd multilanguage support for your site.\n\nHeavily inspired and mostly based on [multilang](https://www.npmjs.com/package/docpad-plugin-multilang) and \u003cdel\u003ethe abandoned\u003c/del\u003e [multilanguage](https://www.npmjs.com/package/docpad-plugin-multilanguage) plugins.\n\n\n\u003c!-- INSTALL/ --\u003e\n\n\u003ch2\u003eInstall\u003c/h2\u003e\n\nInstall this DocPad plugin by entering \u003ccode\u003edocpad install polyglot\u003c/code\u003e into your terminal.\n\n\u003c!-- /INSTALL --\u003e\n\n\n\u003ch2\u003eConfiguration\u003c/h2\u003e\n\n|Config|Default|Description|\n|---|---|---|\n|**mainLanguage**|*(required)*|The main language of the website. There is no specific format, but it is recommended to use some language code pattern, like [IANA](https://www.w3.org/International/questions/qa-html-language-declarations), [ISO](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) or [IETF](https://en.wikipedia.org/wiki/IETF_language_tag).|\n|**languages**|*(required)*|The languages the website will be translated into.|\n|**omitMainFolder**|`true`|Whether the main language files should be in the root of the website or have its own folder.|\n\n\u003ch2\u003eUsage\u003c/h2\u003e\n\n### Configuration\nAdd the necessary configuration into docpad.js:\n\n```javascript\nplugins: {\n  polyglot: {\n    mainLanguage: \"pt-br\",\n    languages: [\"pt-br\", \"en\"]\n  }\n}\n```\n\n### Directory Structure\nAs `omitMainFolder` is `true` by default, only languages different from `mainLanguage` need to be inside its own folder:\n\n```bash\nproject-folder\n└─src/\n  └─documents/\n    ├─index.html # home in brazilian portuguese\n    ├─sobre.html # brazilian portuguese\n    └─en/ # all in english\n      ├─index.html\n      └─about.html\n```\n\nThe generated URLs would be:\n\n```\n/index.html\n/sobre.html\n/en/index.html\n/en/about.html\n```\n\nHowever, if `omitMainFolder` is `false`, each file must be inside its language folder, even for the main language:\n\n```bash\nproject-folder\n└─src/\n  └─documents/\n    ├─en/ # all in english\n    │ ├─index.html\n    │ └─about.html\n    └─pt-br/ # all in brazilian portuguese\n      ├─index.html\n      └─sobre.html\n```\n\nThe generated URLs would be:\n\n```\n/pt-br/index.html\n/pt-br/sobre.html\n/en/index.html\n/en/about.html\n```\n\n### How translations for a page are determined\nAt first the metadata of the page is searched for a dictionary named `translations`. In this dictionary if there are entries with the language keys then it is assumed that these pages are the translation of the current page. For instance for the page /postagem-poliglota.html, if there is a header\n\n```\n---\ntitle: \"Sobre\"\nlayout: \"default\"\ntranslations:\n  en: about.html\n---\n```\nthen `/en/about.html` is assumed to be the translation to `en` of this page.\n\n\u003e Note that the dictionary value (`about.html`) **doesn't have any additional extension** (eg. `.html.md`). It's only necessary to put the final extension in it.\n\nFor languages that are not specified with the `translations` dictionary, it is assumed that the name (including the path without the language directory) of the translated page is the same. In the above example, the file `/en/sobre.html` would be assumed as the `en` translation. If no such page is found in the database then it is assumed that there is no translation of the current page to that language.\n\n### Injected template data\nThe plugin injects some properties and functions into the template data so that they can be used in the template.\n\nThe functions are:\n- `date({ date, format, lang })`: Print the date of the article in a localized form. Takes several optional parameter: `date` and `lang` to use different values than the ones of the document. `format` to use a different date format as specified by [Moment.js](https://momentjs.com/) (defaults to `LL`).\n- `hasLang(lang)`: Whether there is a translation of the current page to that language.\n- `toLang(lang)`: Receives a language code as parameter and returns the URL of the translation of the current page. If there is no translation, it returns `undefined`.\n- `otherLangs()`: Dictionary with the other languages and their URLs that are available for this document. The object structure is `{ \"\u003clanguage\u003e\": \"\u003ctranslation URL\u003e\" }`\n- `langFromUrl(url)`: Allow to obtain current language from URL if `@document.lang` isn't available. Using `@document.lang` is prefered for performance.\n\nThe properties are:\n- `mainLanguage`: The main language, set on config\n- `languages`: List of the languages, set on config\n\n### Template data in use\nUsing the example defined above, if we wrote the following code into `/en/about.html.eco`:\n\n```\n- Lang: \u003c%= @document.lang %\u003e\n- Lang from URL: \u003c%= @langFromUrl(@document.url) %\u003e\n- Translation: \u003c%= @toLang('pt-br') %\u003e\n- Has Portuguese: \u003c%= @hasLang('pt-br') %\u003e\n- Has English: \u003c%= @hasLang('en') %\u003e\n- Other languages: \u003c%= JSON.stringify(@otherLangs()) %\u003e\n```\n\nWe would see the following output:\n```\n- Lang: en\n- Lang from URL: en\n- Translation: /sobre.html\n- Has Portuguese: true\n- Has English: true\n- Other languages: { \"pt-br\": \"/sobre.html\" }\n```\n\n### Injected document data\nProperties are also injected into each document. They are:\n\n- `lang`: The language of the document.\n- `translationURLs`: Dictionary with all translations to the current page (including itself). Probably unnecessary with the functions in the template data.\n\n### Generated collections\nFor every language, a collection whose name is composed from `lang_\u003clanguage\u003e` is automatically created containing all files that have this language. For instance for the language `pt-br` there is a collection named `lang_pt-br`.\n\n\u003c!-- HISTORY/ --\u003e\n\n\u003ch2\u003eHistory\u003c/h2\u003e\n\n\u003ca href=\"https://github.com/danguilherme/docpad-plugin-polyglot/blob/master/HISTORY.md#files\"\u003eDiscover the release history by heading on over to the \u003ccode\u003eHISTORY.md\u003c/code\u003e file.\u003c/a\u003e\n\n\u003c!-- /HISTORY --\u003e\n\n\n\u003c!-- CONTRIBUTE/ --\u003e\n\n\u003ch2\u003eContribute\u003c/h2\u003e\n\n\u003ca href=\"https://github.com/danguilherme/docpad-plugin-polyglot/blob/master/CONTRIBUTING.md#files\"\u003eDiscover how you can contribute by heading on over to the \u003ccode\u003eCONTRIBUTING.md\u003c/code\u003e file.\u003c/a\u003e\n\n\u003c!-- /CONTRIBUTE --\u003e\n\n\n\u003c!-- BACKERS/ --\u003e\n\n\u003ch2\u003eBackers\u003c/h2\u003e\n\n\u003ch3\u003eMaintainers\u003c/h3\u003e\n\nThese amazing people are maintaining this project:\n\n\u003cul\u003e\u003cli\u003e\u003ca href=\"http://danguilherme.github.io/\"\u003eGuilherme Ventura\u003c/a\u003e — \u003ca href=\"https://github.com/danguilherme/docpad-plugin-polyglot/commits?author=danguilherme\" title=\"View the GitHub contributions of Guilherme Ventura on repository danguilherme/docpad-plugin-polyglot\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003ch3\u003eSponsors\u003c/h3\u003e\n\nNo sponsors yet! Will you be the first?\n\n\n\n\u003ch3\u003eContributors\u003c/h3\u003e\n\nThese amazing people have contributed code to this project:\n\n\u003cul\u003e\u003cli\u003e\u003ca href=\"http://danguilherme.github.io/\"\u003eGuilherme Ventura\u003c/a\u003e — \u003ca href=\"https://github.com/danguilherme/docpad-plugin-polyglot/commits?author=danguilherme\" title=\"View the GitHub contributions of Guilherme Ventura on repository danguilherme/docpad-plugin-polyglot\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"http://balupton.com\"\u003eBenjamin Lupton\u003c/a\u003e — \u003ca href=\"https://github.com/danguilherme/docpad-plugin-polyglot/commits?author=balupton\" title=\"View the GitHub contributions of Benjamin Lupton on repository danguilherme/docpad-plugin-polyglot\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"http://mdm.cc\"\u003eMichael Duane Mooring\u003c/a\u003e — \u003ca href=\"https://github.com/danguilherme/docpad-plugin-polyglot/commits?author=mikeumus\" title=\"View the GitHub contributions of Michael Duane Mooring on repository danguilherme/docpad-plugin-polyglot\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"http://robloach.net\"\u003eRob Loach\u003c/a\u003e — \u003ca href=\"https://github.com/danguilherme/docpad-plugin-polyglot/commits?author=RobLoach\" title=\"View the GitHub contributions of Rob Loach on repository danguilherme/docpad-plugin-polyglot\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/vsopvsop\"\u003evsopvsop\u003c/a\u003e — \u003ca href=\"https://github.com/danguilherme/docpad-plugin-polyglot/commits?author=vsopvsop\" title=\"View the GitHub contributions of vsopvsop on repository danguilherme/docpad-plugin-polyglot\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003ca href=\"https://github.com/danguilherme/docpad-plugin-polyglot/blob/master/CONTRIBUTING.md#files\"\u003eDiscover how you can contribute by heading on over to the \u003ccode\u003eCONTRIBUTING.md\u003c/code\u003e file.\u003c/a\u003e\n\n\u003c!-- /BACKERS --\u003e\n\n\n\u003c!-- LICENSE/ --\u003e\n\n\u003ch2\u003eLicense\u003c/h2\u003e\n\nUnless stated otherwise all works are:\n\n\u003cul\u003e\u003cli\u003eCopyright \u0026copy; \u003ca href=\"http://danguilherme.github.io/\"\u003eGuilherme Ventura\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\nand licensed under:\n\n\u003cul\u003e\u003cli\u003e\u003ca href=\"http://spdx.org/licenses/MIT.html\"\u003eMIT License\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003c!-- /LICENSE --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanguilherme%2Fdocpad-plugin-polyglot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanguilherme%2Fdocpad-plugin-polyglot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanguilherme%2Fdocpad-plugin-polyglot/lists"}