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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@resourge/i18n-locales-load

v1.2.3

Published

`@resourge/i18n-locales-load` is a tool to help create and load translations into the the project without the messy JSON's.

Downloads

77

Readme

i18n-locales-load

@resourge/i18n-locales-load is a tool to help create and load translations into the the project without the messy JSON's.

Features

  • Build with typescript.
  • Plugin to support Vite.js.
  • Only the translation files are built into the production code.
  • 100% javascript.
  • Same variable for the translation "key" and to use with "t(...)".
  • Prevents missing translations.
  • Prevents having a different "keys" on the JSON and on the "t(...)".
  • Built into "version" to making sure "production" will always have the newest version.
  • Caches translations into localStorage.
  • Loads translation on demand (only on production).

Installation

Install using Yarn:

yarn add @resourge/i18n-locales-load

or NPM:

npm install @resourge/i18n-locales-load --save

Setup

Vite config

import { i18nLocalesLoad } from '@resourge/i18n-locales-load/i18nLocalesLoad'
import { defineConfig } from 'vite';

export default defineConfig({
	...,
	plugins: [
		...
		i18nLocalesLoad({
			// File where the translations will be created.
			translationFilePath: './src/assets/translations/Translations.ts'
		})
	]
})

i18n

import { i18nLocalesBackend } from '@resourge/i18n-locales-load/i18nLocalesBackend';
import i18n from 'i18next';

i18n
...
.use(i18nLocalesBackend) 
.init(...)

export default i18n;

Translations File

import { Translations, gender, plural } from '@resourge/i18n-locales-load'

export const TRANSLATIONS = Translations(['en', 'pt'], {
	HELLO: {// KEY becomes => HELLO
		en: 'Hello',
		pt: 'Olá'
	},
	RIMURU: {
		TEMPEST: {// KEY becomes => RIMURU.TEMPEST
			en: 'Rimuru Tempest',
			pt: 'Rimuru Tempest'
		},
		IS_BEST: {// KEY becomes => RIMURU.IS_BEST
			en: 'Is the best',
			pt: 'É o melhor'
		},
		GENDER: gender({// KEY becomes => RIMURU.GENDER
			female: {
				en: 'Rimuru Female',
				pt: 'Rimuru Femenino'
			},
			male: {
				en: 'Rimuru Male',
				pt: 'Rimuru Masculino'
			}
		}),
		PLURAL: plural({ // KEY becomes => RIMURU.PLURAL
			one: {
				en: 'one Rimuru', // On translation file KEY becomes => RIMURU.PLURAL_one
				pt: 'um Rimuru'   // On translation file KEY becomes => RIMURU.PLURAL_one
			},
			other: {
				en: 'other Rimuru', // On translation file KEY becomes => RIMURU.PLURAL_other
				pt: 'outro Rimuru'  // On translation file KEY becomes => RIMURU.PLURAL_other
			}
		})
	}
})

Usage

After the setup you are free to use it as you see fit.

Note: './src/assets/translations/Translations' needs to be the same as translationFilePath from the vite config

React

import React from 'react';
import { useTranslation } from 'react-i18next';

import { TRANSLATIONS } from './src/assets/translations/Translations';

const Component = () => {
	const { t } = useTranslation();
	return (
		<div>
			{ t(TRANSLATIONS.HELLO) }
			{ t(TRANSLATIONS.RIMURU.TEMPEST) }
			{ t(TRANSLATIONS.RIMURU.IS_BEST) }
			{ t(TRANSLATIONS.RIMURU.PLURAL, { count: 1 }) } // one Rimuru
			{ t(TRANSLATIONS.RIMURU.PLURAL, { count: 2 }) } // other Rimuru
		</div>
	);
};

export default Component;

Javascript / Other packages

import { t } from 'i18next';

t(TRANSLATIONS.HELLO)

Webpack

I plan in the future to add a plugin for webpack.

License

MIT Licensed.