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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wsxjs/wsx-i18next

v0.1.1

Published

i18next integration for WSXJS components

Readme

@wsxjs/wsx-i18next

i18next integration for WSXJS components - 为 WSXJS 组件提供 i18next 国际化支持

安装

npm install @wsxjs/wsx-i18next i18next

快速开始

1. 初始化 i18n

import { initI18n } from '@wsxjs/wsx-i18next';

initI18n({
    fallbackLng: 'en',
    resources: {
        en: {
            common: { hello: 'Hello' },
        },
        zh: {
            common: { hello: '你好' },
        },
    },
});

2. 使用装饰器(推荐)

/** @jsxImportSource @wsxjs/wsx-core */
import { WebComponent, autoRegister } from '@wsxjs/wsx-core';
import { i18n } from '@wsxjs/wsx-i18next';

@i18n('common')
@autoRegister({ tagName: 'my-component' })
export class MyComponent extends WebComponent {
    render() {
        return <div>{this.t('hello')}</div>;
    }
}

3. 使用 useTranslation + @state

/** @jsxImportSource @wsxjs/wsx-core */
import { LightComponent, autoRegister, state } from '@wsxjs/wsx-core';
import { i18n, useTranslation } from '@wsxjs/wsx-i18next';

@autoRegister({ tagName: 'my-component' })
export class MyComponent extends LightComponent {
    private translation = useTranslation('common');
    @state private currentLang: string = i18n.language;
    private unsubscribe?: () => void;

    protected onConnected(): void {
        this.unsubscribe = i18n.on('languageChanged', (lng) => {
            this.currentLang = lng;
        });
    }

    protected onDisconnected(): void {
        if (this.unsubscribe) {
            this.unsubscribe();
        }
    }

    render() {
        return <div>{this.translation.t('hello')}</div>;
    }
}

4. 使用 Mixin

/** @jsxImportSource @wsxjs/wsx-core */
import { WebComponent, autoRegister } from '@wsxjs/wsx-core';
import { withI18n } from '@wsxjs/wsx-i18next';

@autoRegister({ tagName: 'my-component' })
export class MyComponent extends withI18n(WebComponent, 'common') {
    render() {
        return <div>{this.t('hello')}</div>;
    }
}

API

initI18n(config?)

初始化 i18next 实例。

i18n (装饰器)

为组件自动注入翻译功能。

@i18n('namespace')
export class MyComponent extends WebComponent {
    render() {
        return <div>{this.t('key')}</div>;
    }
}

useTranslation(namespace?)

创建翻译对象,API 与 react-i18next 兼容。

withI18n(Base, defaultNamespace?)

为基类添加 i18n 支持的 mixin。

响应式机制

  • @i18n 装饰器:自动订阅语言变化并触发重渲染
  • useTranslation + @state:手动订阅,通过更新 @state 触发重渲染
  • withI18n:自动订阅语言变化并触发重渲染

更多信息

查看 RFC-0029 了解完整设计。