{"id":15059301,"url":"https://github.com/pcdevil/eleventy-plugin-intl-utils","last_synced_at":"2026-01-03T06:05:52.904Z","repository":{"id":42692514,"uuid":"437643260","full_name":"pcdevil/eleventy-plugin-intl-utils","owner":"pcdevil","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-23T09:07:41.000Z","size":199,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T16:41:44.759Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pcdevil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-12T19:57:47.000Z","updated_at":"2022-01-06T12:25:33.000Z","dependencies_parsed_at":"2024-10-26T21:56:33.596Z","dependency_job_id":"d49dcadd-0976-42bd-9f8f-c8baade3fe4a","html_url":"https://github.com/pcdevil/eleventy-plugin-intl-utils","commit_stats":{"total_commits":44,"total_committers":2,"mean_commits":22.0,"dds":"0.022727272727272707","last_synced_commit":"f3b89cf619f19aa21c5a569d93248069286dff92"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcdevil%2Feleventy-plugin-intl-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcdevil%2Feleventy-plugin-intl-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcdevil%2Feleventy-plugin-intl-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcdevil%2Feleventy-plugin-intl-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pcdevil","download_url":"https://codeload.github.com/pcdevil/eleventy-plugin-intl-utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243719333,"owners_count":20336593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-09-24T22:40:57.885Z","updated_at":"2026-01-03T06:05:52.895Z","avatar_url":"https://github.com/pcdevil.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eleventy-plugin-intl-utils\nA set of internationalization utils for [Eleventy](https://www.11ty.dev/).\n\n## Motivation\nIt's super fast to create a static website with **Eleventy** and with the help of [`eleventy-plugin-i18n`](https://www.npmjs.com/package/eleventy-plugin-i18n) localization can be done with ease too.\n\nHowever it only gives solution for static data and dynamic data still needs treatment during layout rendering. This plugin aims to help with a set of [filters](https://www.11ty.dev/docs/filters/) and [shortcodes](https://www.11ty.dev/docs/shortcodes/).\n\nThe implementations of the filters are mostly wrappers around the [ECMAScript Internationalization API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) with a little _bit of sugar_.\n\n## Usage\nThis guide corresponds to [Eleventy documentation](https://www.11ty.dev/docs/plugins/#add-the-plugin-to-eleventy-in-your-config-file):\n\n1. Install the package\n    ```bash\n    npm install --save @pcdevil/eleventy-plugin-intl-utils\n    ```\n\n2. Add to your config file\n    ```javascript\n    // file: .eleventy.js\n    const intlUtils = require('@pcdevil/eleventy-plugin-intl-utils');\n\n    module.exports = function (eleventyConfig) {\n        // ...\n\n        const intlUtilConfig = {\n            locale: 'en-GB',\n        };\n        eleventyConfig.addPlugin(intlUtils, intlUtilConfig);\n    };\n    ```\n\n## Configuration object\nA general configuration object can be passed optionally via Eleventy config when the plugin is initiated. This sections lists the available configuration properties.\n\n### `locale`\nThis property affects the output language of the filters. See [`locales` argument section on Intl page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument) for more info.\n\n- **Type**: String\n- **Default value**: `undefined` (**Node.js** will pick up the system's language)\n- **Example values**: `\"en-GB\"`, `\"hu\"`\n\n## Filters\n\n### `country_name`\nTransforms a country code into a country name. Useful to display author's location.\n\n- **Used Internationalization API**: `Intl.DisplayNames()` with _region_ type ([MDN article](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames))\n\n#### LiquidJS Example\n\n```\n{% assign country = \"FR\" %}\n{{ country | country_name }}\n```\n\nThis renders \"France\" when the `intlUtilConfig.locale` is `en`.\n\n### `language_name`\nTransforms a language code to a renderable text. Useful for language selectors or when the current language is displayed.\n\n- **Used Internationalization API**: `Intl.DisplayNames()` with _language_ type ([MDN article](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#using_type_language_with_languagedisplay))\n\n#### LiquidJS Example\n\n```\n{% assign language = \"en-GB\" %}\n{{ language | language_name }}\n```\n\nThis renders \"British English\" when the `intlUtilConfig.locale` is `en`.\n\n### `short_datetime_format`\nTransforms a date string to a short date time text. Useful for blog post dates.\n\n- **Used Internationalization API**: `Intl.DateTimeFormat()` with _short_ date and time style ([MDN article](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat))\n\n#### LiquidJS Example\n\n```\n{% assign postDate = \"2021-12-12 17:36 +0100\" %}\n{{ postDate | short_datetime_format }}\n```\n\nThis renders \"12/12/21, 5:36 PM\" when the `intlUtilConfig.locale` is `en`.\n\n## Shortcodes\n\n### `year_interval`\nTransforms two date strings to a year range. Useful when a larger time interval is presented.\n\nThe input should be an array with two date string and the first one should precede before the second one.\n\n- **Used Internationalization API**: `Intl.DateTimeFormat.prototype.formatRange()` with _numeric_ year ([MDN article](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRange))\n\n#### LiquidJS Example\n\n```\n{% assign startDate = \"2011-05-16 11:00 +0200\" %}\n{% assign endDate = \"2020-03-01 00:00 +0100\" %}\n{% year_interval startDate, endDate %}\n```\n\nThis renders \"2011 – 2020\" (with en dash in the middle) when the `intlUtilConfig.locale` is `en`.\n\n#### Fallback value\nThe second `endDate` argument can be omitted and it has the current date as default value.\n\nThis behaviour helps when an open-ended / ongoing interval needs be displayed:\n\n```\n{% assign startDate = \"2011-05-16 11:00 +0200\" %}\n{% year_interval startDate %}\n```\n\nThis renders \"2011 – 2021\" (with en dash in the middle) when the `intlUtilConfig.locale` is `en` and the current year is 2021.\n\n### `year_open_interval`\nTransforms a date string into an _open_ year range where the end date is absent. Useful when a ongoing interval is presented.\n\n- **Used Internationalization API**: `Intl.DateTimeFormat.prototype.formatRange()` with _numeric_ year ([MDN article](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRange))\n\n#### LiquidJS Example\n\n```\n{% assign startDate = \"2011-05-16 11:00 +0200\" %}\n{% year_interval startDate %}\n```\n\nThis renders \"2011 – \" (with en dash in the middle) when the `intlUtilConfig.locale` is `en`.\n\n#### Difference from `year_interval`\nWhile the [`year_interval`](#year_interval) shortcode always created a _closed_ year range (by applying the current year as default), the `year_open_interval` only displays the start date.\n\n## License\nAvailable under the [MIT license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpcdevil%2Feleventy-plugin-intl-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpcdevil%2Feleventy-plugin-intl-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpcdevil%2Feleventy-plugin-intl-utils/lists"}