# shopify.i18n.js

> A small Javascript library for adding dynamic i18n features to Shopify themes.

Latest version **0.2.1** (published 2015-06-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install shopify.i18n.js
pnpm add shopify.i18n.js
yarn add shopify.i18n.js
bun add shopify.i18n.js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2015-06-27 |
| First published | 2014-10-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Gavin Ballard |
| Maintainers | gavinballard |
| Keywords | Shopify, i18n, Javascript |

## Links

- npm: https://www.npmjs.com/package/shopify.i18n.js
- Repository: https://github.com/discolabs/shopify.i18n.js
- Homepage: https://github.com/discolabs/shopify.i18n.js#readme
- Issues: https://github.com/discolabs/shopify.i18n.js/issues
- npm.io page: https://npm.io/package/shopify.i18n.js

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2015-06-27
- 0.2.0 — 2015-06-27
- 0.1.0 — 2014-10-30

## README

shopify.i18n.js
===============

A small (experimental) Javascript library for adding dynamic i18n features to Shopify themes.
Incorporates and builds on Caroline Schnapp's [jquery.currencies.js][].

To see this in action, check out the very in-progress [Bootstrap for Shopify 4][] development store.


### Features
- Allow dynamic switching of locales using DOM elements marked up with `data-translate`;
- Allow dynamic switching of currencies using DOM elements marked up with `data-convert`;
- Store locale and currency preference in a user cookie for persistence.


### Assumptions
- You have a recent version of jQuery available;
- You've pulled in Shopify's recent current data through `currencies.js` (see example below);
- You've copied all `.json` files from your theme's `locales` directory into `assets` so that they're accessible via a `$.getJSON` request.


### Usage

This is probably *not* ready for production use.
If you'd like to use it, you can copy the files from the `dist` directory or install via bower:

```
bower install shopify.i18n.js
```

Then incorporate it at the bottom of your `theme.liquid` like this:

```html
    <!-- Javascript -->
    {{ 'jquery.min.js' | asset_url | script_tag }}
    {{ '/services/javascripts/currencies.js' | script_tag }}
    {{ 'shopify.i18n.min.js' | asset_url | script_tag }}

    <script type="text/javascript">
      Shopify.i18n.init("{{ shop.locale }}", "{{ shop.locale | append: '.json' | asset_url }}", "{{ shop.currency }}");
    </script>
  </body>
</html>
```

[jquery.currencies.js]: https://github.com/carolineschnapp/currencies
[Bootstrap for Shopify 4]: http://bootstrap-4.myshopify.com

---
_Source: https://npm.io/package/shopify.i18n.js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
