Home

Awesome

@shopify/i18next-shopify

This package is an i18nFormat plugin for the i18next library. It allows developers to use the same format used by Shopify apps and themes for localization.

Key features include:

Table of contents

Getting Started
Example
License
Contributing
References

Getting started

Add the package

$ npm install @shopify/i18next-shopify

or

$ yarn add @shopify/i18next-shopify

Configure i18next to use this plugin

Warning The Intl.PluralRules API is required for this plugin's plural handling. If your target environments do not support this API, you may need to polyfill it. This plugin's plural handling is not compatible with i18next's fallback to JSON format v3 plural handling.

import i18next from "i18next";
import ShopifyFormat from "@shopify/i18next-shopify";

i18next.use(ShopifyFormat).init(i18nextOptions);

Example

import i18next from "i18next";
import ShopifyFormat from "@shopify/i18next-shopify";

i18next.use(ShopifyFormat).init({
  lng: "en",
  resources: {
    en: {
      translation: {
        hello: "Hello {{casualName}}!",
        products: {
          "0": "I have no products.",
          "1": "I have a single product.",
          one: "I have {{count}} product.",
          other: "I have {{count}} products.",
        },
      },
    }
  }
});

i18next.t("hello", { casualName: "Shopify" }); // -> Hello Shopify!
i18next.t("products", { count: 2 }); // -> I have 2 products!

License

MIT

Contributing

Want to make i18next-shopify better for everyone? We'd love your help! Please start off by reading our Code of Conduct.

Report a bug

Bugs are tracked at GitHub issues. Search open issues to see if someone else has reported a similar bug. If it's something new, open an issue. We'll use the issue to have a conversation about the problem you want to fix. You may also suggest features using GitHub issues.

When creating a new issue, please ensure the issue is clear and include additional details to help maintainers reproduce it:

Use a clear and descriptive title for the issue to identify the problem.

Contributing Code

Useful commands:

How to contribute:

Thank you for your interest in contributing!

References