{"id":21525787,"url":"https://github.com/bkwld/cloak-i18n","last_synced_at":"2026-01-20T19:32:26.826Z","repository":{"id":39578265,"uuid":"478216305","full_name":"BKWLD/cloak-i18n","owner":"BKWLD","description":"Localization conventions for Cloak + Craft.","archived":false,"fork":false,"pushed_at":"2024-06-11T23:43:10.000Z","size":393,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T11:01:58.958Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://cloak-i18n.netlify.app","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/BKWLD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-04-05T16:39:51.000Z","updated_at":"2024-06-11T23:43:13.000Z","dependencies_parsed_at":"2024-06-12T03:15:46.118Z","dependency_job_id":"88a4cc72-5056-4f10-a3b0-a62ff048917b","html_url":"https://github.com/BKWLD/cloak-i18n","commit_stats":{"total_commits":102,"total_committers":3,"mean_commits":34.0,"dds":0.07843137254901966,"last_synced_commit":"b6e4d89690dc93400ff25e649fdebb3477cbf48a"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BKWLD%2Fcloak-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BKWLD%2Fcloak-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BKWLD%2Fcloak-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BKWLD%2Fcloak-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BKWLD","download_url":"https://codeload.github.com/BKWLD/cloak-i18n/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247667947,"owners_count":20976138,"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-11-24T01:38:29.392Z","updated_at":"2026-01-20T19:32:26.816Z","avatar_url":"https://github.com/BKWLD.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @cloak-app/i18n\n\nLocalization conventions for Cloak + Craft.\n\n- [View demo](https://cloak-i18n.netlify.app)\n- [Edit CodeSandbox](https://githubbox.com/BKWLD/cloak-i18n)\n\n## Install\n\n1. Install with `yarn add @cloak-app/i18n`\n2. Add to nuxt.config with `modules: ['@cloak-app/i18n']`\n3. Install and configure a Cloak CMS package, like [`@cloak-app/craft`](https://github.com/BKWLD/cloak-craft).\n    - CMS packages **must** be added *after* the `@cloak-app/i18n` module in `modules` so that their injected clients are available to the [`fetch-translations.coffee`](./plugins/fetch-translations.coffee) plugin.\n    - Currently only `@cloak-app/craft` is supported\n4. Add `this.$nuxtI18nHead({ addSeoAttributes:true })` to your head, probably in your default layout, as described in [the @nuxtjs/i18n docs](https://i18n.nuxtjs.org/seo/#setup)\n    - Adding to the nuxt.config conflicts with [@nuxtjs/gtm](https://github.com/nuxt-community/gtm-module/issues/136)\n\nIf using the `generateJson` option, you'll need to support CORS requests for the JSON files.  If using Netlify, add this to your `static/_redirects` file:\n\n```\n# Allow access to i18n json files\n/i18n/*\n\tAccess-Control-Allow-Origin: *\n```\n\n### Module Options\n\nSet these properties within `cloak: { i18n: { ... } }` in the nuxt.config:\n\n- `currentCode` - The `code` code (see the `locales` object) of the **current** locale.  Defaults to `process.env.LOCALE_CODE` and then `process.env.CMS_SITE` (which converts `_` to `-` to convert Craft handle to ISO code).  See the [@nuxtjs/i18n `defaultLocale` option](https://i18n.nuxtjs.org/options-reference/#defaultlocale).\n- `locales` - An array of objects for defining the list of supported locales. This array is similar to the [@nuxtjs/i18n `locales` option](https://i18n.nuxtjs.org/options-reference/#locales). The objects look like:\n  ```js\n  {\n    code: 'en', // Should be an ISO code\n    domain: 'https://cloak-i18n.netlify.app', // Should be full origin\n\n    // @cloak-app/i18n additions\n    currency: 'USD', // Optional, used with $n()\n  }\n  ```\n- `generateJson` - Boolean to enable static generation of JSON files for each locale's static strings.  You would enable this if you wanted to use the static strings outside of Nuxt, like as part of components that are used in a Shopify theme.  The JSON is written to `/dist/i18n/{code}.json` where `{code}` comes from the `locales` array.\n- `craft.categories` - An array of category titles from [Translations Admin](https://plugins.craftcms.com/translations-admin).  If undefined, it's treated as `[\"site\"]` by Translations Admin.\n\n### Project Dependencies\n\n- This package expects that there is a unique Netlify Site for every locale.  In other words, when you switch locales, you are switching domains.\n- If using Craft, you're expected to use the [Translations Admin](https://plugins.craftcms.com/translations-admin) plugin fror static translations.\n\n## Usage\n\n### Static Strings\n\nThis package uses [@nuxtjs/i18n](https://i18n.nuxtjs.org) which, itself, consumes [`vue-i18n`](https://kazupon.github.io/vue-i18n). Thus, look to their docs for a deeper explanantion for how to translate text. The most common helper you'll use is [`$t()`](https://kazupon.github.io/vue-i18n/api/#vue-injected-methods).  For example:\n\n```vue\n\u003cbutton\u003e{{ $t('articles.read_me') }}\u003c/button\u003e\n```\n\n### Components\n\n`\u003ccloak-i18n-locale-selector /\u003e`\n\nRenders a select-style menu for choosing a locale.  This component can be configured with the following Stylus or CSS customer properties:\n\n- `cloak-i18n-locale-selector-radius` - The radius of the select button and the menu background.\n- `cloak-i18n-locale-selector-padding-h` - The horizontal padding within the toggle button and in the select menu.\n- `cloak-i18n-locale-selector-toggle-height` - The height of the select button.\n- `cloak-i18n-locale-selector-options-padding-v` - The vertical padding within the select menu and the spacing between locale options within the menu.\n\n## Contributing\n\nRun `yarn dev` to open a Nuxt dev build of [the demo directory](./demo).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkwld%2Fcloak-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbkwld%2Fcloak-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkwld%2Fcloak-i18n/lists"}