npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

remix-polyglot

v0.3.1

Published

type-safe, cached-forever, split-able, non-flickering, pre-loading, persistence-agnostic internationalization made for remix ♥

Downloads

5

Readme

remix-polyglot

type-safe, cached-forever, split-able, non-flickering, pre-loading, persistence-agnostic internationalization made for remix ♥

...all while still using plain old json files as phrase storage.

🚨 Monkey-Patches Remix 🙈

This package uses unofficial Remix API and monkey-patches Remix data functions to make sure all lazy translation files are loaded before rendering a new page with new translation namespaces.

I hope remix will eventually provide an official way to dynamically declare route dependencies

Until then, this package is mainly meant as a case-study and to underline my opinion that an API for this is needed. The package might break with any patch release of remix - use at your own risk.

Install

npm install remix-polyglot
# yarn add remix-polyglot

Playground

Open in StackBlitz

Examples

See examples folder for guidance on how to setup your project

Wait what?!

type-safe

by running remix-polyglot a declaration file is created based on your translation files Enabling:

Auto-Completion:

Catching Typos:

Typed Interpolation:

cached-forever

running remix-polyglot also minifies and content-hashes your translation files and puts them next to the remix build artifacts.

split-able

Each route can use its own set of translations (namespaces) only the translation files used for the current routes and locale are loaded.

non-flickering

🚨 This behavior is achieved using internal and potential unstable Remix API

When navigating in the frontend, the transition to the next page is delayed until all required translations are loaded.
Creating the same UX like with traditional server rendering: First page render already includes all translations.
No need for loading spinners.

Note how the home-EA5A9AB7.json takes much longer to load then the route chunk (this is not the case normally). The page transition will take 1s

pre-loading

🚨 This behavior is achieved using internal and potential unstable Remix API

Required translation files of target routes are loaded along with the route chunk and loader data.
This way, the splitted-out translations are very likely to not increase page load time at all when navigating in the frontend.

Note how loading of home-EA5A9AB7.json starts at the same moment the route chunk is loaded


Let's talk

I've been unhappy with the state of i18n in JS/TS for quite a while and would like to provide a sleek & modern solution here.

Please be invited to discuss about this or send me an email.