Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[react-i18n] Extract base i18n logic to allow it to be used in non-react JS projects #2513

Open
2 tasks done
ewajm-shopify opened this issue Dec 22, 2022 · 1 comment
Open
2 tasks done

Comments

@ewajm-shopify
Copy link

ewajm-shopify commented Dec 22, 2022

Overview

It would be useful to extract the base i18n logic from react-i18n, possibly to the quilt i18n library, in order to allow straightforward integration with non-React TS/JS projects.

  • a number of the files in react-i18n are .ts vs .tsx files, including i18n.ts, implying that they do not depend on react for their functionality and could be extracted
  • react-i18n already has i18n as a dependency, so it would only need to switch to importing certain things like the I18n object from that package rather than having it in the react-i18n repo

Motivation

What inspired this enhancement? What makes you think this should be in quilt?

Our particular use case is adding i18n support to ShopifyQL, which is a Typescript package.

Currently our options are to use an external non-Shopify library, implement our own i18n logic or use the react-i18n I18n object directly, forcing us to require react in our dependencies even though we do not use it, leading to unnecessary bloat. We would like to be able to stay within the Shopify ecosystem to more easily stay in line with Shopify I18n guidelines, and would prefer not to have to import a library that is not used directly by our package.

Checklist

  • Please delete the labels section before submitting your issue
  • I have described this issue in a way that is actionable (if possible)
@BPScott
Copy link
Member

BPScott commented Jan 13, 2023

Per #2429 (comment):

react-i18n is designed for translation work in applications. Usage in packages that are published to npm was not part of its original design consideration. It probably works but the ergonomics and runtime behaviour are probably somewhat clunky especially around "what if you ship this package in an app that has per-locale build"s. There's a gap here for a simpler version of i18n that is designed for usage in libraries but this is not a priority given the current goals of this team right now.

If you want a simple translations with one file for the whole package, it might be interesting to copy polaris's i18n approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants