{"id":42819739,"url":"https://github.com/rehhouari/alpinejs-i18n","last_synced_at":"2026-01-30T06:48:47.371Z","repository":{"id":39919262,"uuid":"366579069","full_name":"rehhouari/alpinejs-i18n","owner":"rehhouari","description":"Easy i18n (Internationalization) for Alpine.js!","archived":false,"fork":false,"pushed_at":"2025-11-29T10:35:20.000Z","size":361,"stargazers_count":69,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-12-01T11:55:36.245Z","etag":null,"topics":["alpine","alpinejs","arabic","i18n","internationalization","localization","translation"],"latest_commit_sha":null,"homepage":"https://alpinejs-i18n-example.vercel.app/","language":"TypeScript","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/rehhouari.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"rehhouari","tidelift":null,"community_bridge":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2021-05-12T03:17:48.000Z","updated_at":"2025-11-29T10:35:24.000Z","dependencies_parsed_at":"2023-02-10T00:15:36.008Z","dependency_job_id":"99443829-0fcc-444e-9844-27b66972530b","html_url":"https://github.com/rehhouari/alpinejs-i18n","commit_stats":{"total_commits":60,"total_committers":3,"mean_commits":20.0,"dds":0.06666666666666665,"last_synced_commit":"500f2f7bf6395f99e20bdbcd1a3fdc81de680cba"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":"rehhouari/alpine-typescript-plugin-template","purl":"pkg:github/rehhouari/alpinejs-i18n","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehhouari%2Falpinejs-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehhouari%2Falpinejs-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehhouari%2Falpinejs-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehhouari%2Falpinejs-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rehhouari","download_url":"https://codeload.github.com/rehhouari/alpinejs-i18n/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehhouari%2Falpinejs-i18n/sbom","scorecard":{"id":769200,"data":{"date":"2025-08-18","repo":{"name":"github.com/rehhouari/alpinejs-i18n","commit":"8015eb01660c039a5139d817f219475bc1f36ce1"},"scorecard":{"version":"v5.2.1-41-g40576783","commit":"40576783fda6698350fcbbeaea760ff827433034"},"score":2.9,"checks":[{"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/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 1/19 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/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#code-review"}},{"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/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#token-permissions"}},{"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/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"1 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/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#maintained"}},{"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/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#pinned-dependencies"}},{"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/40576783fda6698350fcbbeaea760ff827433034/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/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#security-policy"}},{"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/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#branch-protection"}},{"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/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 12 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T01:46:15.074Z","repository_id":39919262,"created_at":"2025-08-23T01:46:15.075Z","updated_at":"2025-08-23T01:46:15.075Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28906984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T06:42:00.998Z","status":"ssl_error","status_checked_at":"2026-01-30T06:41:58.659Z","response_time":66,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["alpine","alpinejs","arabic","i18n","internationalization","localization","translation"],"created_at":"2026-01-30T06:48:46.710Z","updated_at":"2026-01-30T06:48:47.363Z","avatar_url":"https://github.com/rehhouari.png","language":"TypeScript","funding_links":["https://ko-fi.com/rehhouari"],"categories":[],"sub_categories":[],"readme":"# i18n Plugin for Alpine.js\n\nInternationalization (i18n) support for Alpine.js (unofficial)\n\n[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/rehhouari/alpinejs-i18n)](https://github.com/rehhouari/alpinejs-i18n/tree/2.5.3)\n[![npm bundle size](https://img.shields.io/bundlephobia/minzip/alpinejs-i18n)](https://bundlephobia.com/result?p=alpinejs-i18n@2.5.3)\n[![Downloads from Jsdelivr NPM](https://img.shields.io/jsdelivr/npm/hm/alpinejs-i18n)](https://www.jsdelivr.com/package/npm/alpinejs-i18n?version=2.5.3)\n[![npm](https://img.shields.io/npm/dm/alpinejs-i18n)](https://npmjs.com/package/alpinejs-i18n)\n[![Changelog](https://img.shields.io/badge/change-log-log)](/CHANGELOG.md)\n[![Donate](https://img.shields.io/badge/Support-%E2%99%A5-pink)](https://ko-fi.com/rehhouari)\n\n## About\n\nThis plugin allows you to easily use localization in your Alpine.js projects!\nIt provide two _magic helpers_ that you can use to localize strings in your Alpine.js websites \u0026 webapps.\n\n## Compatibility\n\nVersion **^2.x** for Alpine v3.\n\nVersion **1.0.0** for Alpine v2.\n\n#### [Demo](https://alpinejs-i18n-example.vercel.app/)\n\n## Features\n\n-   Easy localization of strings using a [magic helper](#t-magic-helper)\n-   Support [variables in strings](#using-variables-in-strings)!\n-   Setting \u0026 getting [current locale](#locale-magic-helper) using a magic helper as well\n-   Automatically update affected components on locale change!\n-   Can be easily used [outside of Alpine.js components](#usage-from-javascript) (in Javascript)\n-   Typescript support.\n\n## Installation\n\n### CDN\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/alpinejs-i18n@2.x.x/dist/cdn.min.js\"\u003e\u003c/script\u003e\n```\n\n### NPM\n\n```\nnpm install alpinejs-i18n\n```\n\n```js\nimport AlpineI18n from 'alpinejs-i18n';\nimport Alpine from 'alpinejs';\n\ndocument.addEventListener('alpine-i18n:ready', function () {\n\t// ... scroll to Usage to see where locale and messages came from\n\twindow.AlpineI18n.create(locale, messages);\n});\nAlpine.plugin(AlpineI18n);\nAlpine.start();\n```\n\n### ES6 Module\n\nAdd the following `\u003cscript\u003e` to the `\u003chead\u003e` of your document **before** including Alpine:\n\n```html\n\u003cscript type=\"module\"\u003e\n\timport AlpineI18n from 'https://cdn.jsdelivr.net/npm/alpinejs-i18n@2.x.x/dist/module.esm.min.js';\n\tdocument.addEventListener('alpine-i18n:ready', function () {\n\t\t// ... scroll to Usage to see where locale and messages came from\n\t\twindow.AlpineI18n.create(locale, messages);\n\t});\n\tdocument.addEventListener('alpine:init', () =\u003e {\n\t\twindow.Alpine.plugin(AlpineI18n);\n\t});\n\u003c/script\u003e\n```\n\n## Usage\n\n### 1- Setting up the translations and locale.\n\nIn Javascript, after importing `alpinejs-i18n`:\n\n```js\n// the default locale\n// you can for example take it from the URL.\nlet locale = 'en';\n\n// the translation data\n// you can load/fetch these from files or keep them hardcoded.\nlet messages = {\n\ten: {\n\t\tbasic: 'button',\n\t\t// can have variables\n\t\tvar: 'hello, {name}',\n\t\t// can be nested\n\t\tdeep: {\n\t\t\tone: 'one',\n\t\t\ttwo: 'two',\n\t\t},\n\t},\n\tar: {\n\t\tbasic: 'زر',\n\t\tvar: 'مرحبا, {name}',\n\t\tdeep: {\n\t\t\tone: 'واحد',\n\t\t\ttwo: 'اثنان',\n\t\t},\n\t},\n};\n\n// finally, pass them to AlpineI18n:\ndocument.addEventListener('alpine-i18n:ready', function () {\n\twindow.AlpineI18n.create(locale, messages);\n});\n```\n\n### 2 - Usage from inside Alpine Components\n\n#### $t magic helper\n\nUsing the `$t` magic helper, you can display the translation for the current locale\n\nFollowing the example settings above:\n\n```html\n\u003cdiv x-data\u003e\n\t\u003cbutton x-text=\"$t('basic')\"\u003e\u003c/button\u003e\n\u003c/div\u003e\n```\n\nThis will make the button's text \"button\".\n\n##### Using variables in strings\n\nUsing variables in translation strings is easy:\n\n```html\n\u003cspan x-text=\"$t('var', {name: 'rafik'})\"\u003e\u003c/span\u003e\n```\n\nThis will make the span's text \"hello, rafik\"!\n\n#### $locale magic helper\n\n##### Setting the locale\n\n`$locale('ar')` will set the locale to `ar` and refresh all Alpine components.\n\n##### Getting the current locale\n\n`$locale()` (without any argument) will get the current locale. (`ar`)\n\n#### Events\n\n-   `alpine-i18n:locale-change` is dispatched to `document` when the locale changes.\n-   `alpine-i18n:ready` is dispatched to `document` when the plugin is ready.\n\n#### Fallback Locale\n\nto set a fallback locale for partially-translated values:\n\n```js\ndocument.addEventListener('alpine-i18n:ready', function () {\n    window.AlpineI18n.fallbackLocale = 'en';\n}\n```\n\n### Extra Tips:\n\n#### Changing writing direction based on locale\n\n```html\n\u003cdiv x-data :dir=\"{'rtl': $locale() == 'ar'}\"\u003e\u003c/div\u003e\n```\n\n\u003e **NOTE**: If you want to set it on the entire `body`, **do not make the `body` an Alpine Component**,\n\u003e [Use this method from Javascript instead](#changing-writing-direction-from-javascript)!\n\u003e The reason for not making body an Alpine component is because it can affect the performance of the site, if the page is big.\n\n#### Usage from Javascript\n\nAll features can be used outside Alpine.js components, meaning from Javascript!\n\n\u003e **If you're inside of a module, append `window.` to `AlpineI18n`. (becomes `window.AlpineI18n`)**\n\n##### Localizing strings t()\n\n```js\nAlpineI18n.t('key', {var: val})\n```\n\n##### Getting \u0026 Setting Locale\n\n**Getting the locale**\n\n```js\nAlpineI18n.locale;\n```\n\n**Setting the locale**\n\n```js\nAlpineI18n.locale = 'ar';\n```\n\n##### Changing writing direction from Javascript\n\n```html\n\u003cscript\u003e\n\t// define the RTL locales you support\n\tvar rtlLocales = ['ar', 'fa'];\n\t// listen to locale changes\n\tdocument.addEventListener('alpine-i18n:locale-change', function () {\n\t\tif (rtlLocales.includes(window.AlpineI18n.locale)) {\n\t\t\tdocument.body.setAttribute('dir', 'rtl');\n\t\t} else {\n\t\t\tdocument.body.removeAttribute('dir');\n\t\t}\n\t});\n\u003c/script\u003e\n```\n\n## Versioning\n\nThis projects follow the [Semantic Versioning](https://semver.org/) guidelines.\n\n## Disclaimer\n\nCommunity project by [@rehhouari](https://github.com/rehhouari), not affiliated with Alpine.js team.\n\n## Acknowledgments\n\n-   [@KevinBatdorf](https://twitter.com/KevinBatdorf) for the constant feedback and help.\n\n## License\n\nCopyright (c) 2021-2025 Rafik El Hadi Houari and contributors.\n\nLicensed under the MIT license, see [LICENSE.md](LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehhouari%2Falpinejs-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frehhouari%2Falpinejs-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehhouari%2Falpinejs-i18n/lists"}