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

wuthery-l10n

v0.3.0

Published

Typescript package to interact with Wuthery's localization files.

Downloads

6

Readme

l10n

Storage of localization files for Wuthery services, with Python and TS packages to interact with the data

Setting up the development environment

Python

# Clone the repo
git clone https://github.com/Wuthery/l10n

# Install the dependencies
cd l10n
poetry install --with dev --no-root

# If you want to run the tests locally
poetry install --with test --no-root

# Install pre-commit
pre-commit install

Typescript

# Clone the repo
git clone https://github.com/Wuthery/l10n

# Install the dependencies
cd wuthery-l10n
npm i

Usage

Python Package

# Install the package
poetry add wuthery.l10n
from wuthery.l10n import Translator, Language

async with Translator() as translator:
    translation = translator.translate(2, Language.EN_US, variable="Wuthery")

TypeScript Package

# Install the package
npm i wuthery-l10n

On server side (layout.tsx):

import { I18nProvider, Language } from 'wuthery-l10n/client';
import {
    LANGUAGE_KEY,
    detectReqLanguage,
    fetchTranslation,
} from 'wuthery-l10n/server';
import { getCookie } from 'cookies-next';
import { headers, cookies } from 'next/headers';


const Layout = async ({
    children,
}: Readonly<{
    children: React.ReactNode;
}>) => {
    let language = getCookie(LANGUAGE_KEY, { cookies }) as Language || undefined;
    if (!language) {
        const reqHeaders = headers();
        language = detectReqLanguage(reqHeaders.get('accept-language') || '');
    }
    const translation = await fetchTranslation(language);
    return (
        <I18nProvider
            initialLanguage={language}
            initialTranslations={{[language]: translation}}
        >
            <html>
                <body>
                    {children}
                </body>
            </html>
        </I18nProvider>
    );
};
export default Layout;

In component:

'use client';
import { useTranslation, Language } from 'wuthery-l10n/client';

const Component = () => {
    const { changeLanguage, t, language } = useTranslation();
    return (
        <div>
            <h1>{t('test_str', {'variable': 0})}</h1>
            <button onClick={() => changeLanguage(language == Language.ZH_TW ? Language.EN_US : Language.ZH_TW)}>Change language</button>
        </div>
    );
};
export default Component;

String conventions

  • Use - instead of _ to seperate words, e.g. test-str instead of test_str
  • Use / to seperate scopes, e.g. scope/test-str