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

@lingufox/client

v1.8.30

Published

- Visit [LinguFox](https://lingufox.com) and create an account - Create a Web App via the "Onboarding Process" or later using the "Add new Web App" button - Once successfully created, you will receive a Web App token

Readme

LinguFox

Installation

1. Create a LinguFox account

  • Visit LinguFox and create an account
  • Create a Web App via the "Onboarding Process" or later using the "Add new Web App" button
  • Once successfully created, you will receive a Web App token

2. Configure Web App

2.1. Install The Package

npm install @lingufox/client
# or 
yarn add @lingufox/client

2.2 Initialization

It is necessary to initialize library in the root file (main.ts, index.ts...), before starting the React app as in example shown bellow

Init Function
import { init, LanguageCode } from '@lingufox/client'

init({
    code: '6gmhja7xN03MhCZ7HcBTaIeUddZ7pRSGwTCex99.dGVuYW50X1lGYTRRanRrcmRfMzUwMDQw',
    clientTranslations: defaultTranslation,
    defaultLanguage: LanguageCode.EN,
})
Configuration Options

| Option | Required | Description | | ------------------ | -------- | ---------------------------------------------------------------------------------------------------------------------- | | code | yes | A unique code for connecting client applications to the LinguFox. | | clientTranslations | yes | Translation resources | | defaultLanguage | yes | The base language of your application. Must match the Source Language selected in LinguFox. This language serves as the foundation for all translations. Note: Source Language cannot be changed in LinguFox once created - you would need to create a new application if a different source language is required. | | supportedLngs | no | An array of allowed languages | | enableDebugMode | no | Enable debug log on the console |

3. Verify the Connection

After implementing LinguFox in your application, verify the connection by:

  • Opening your Web App in a new tab to trigger the connection status update
  • OR go to your Web App detail page inside LinguFox and clicking the refresh icon

NOTE: When clicking the refresh icon from the Web App detail page inside the LinguFox, you will see a popup confirming that the library is installed and successfully connected.

Initialization Example

import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
import { init, TranslationResource, LanguageCode } from '@lingufox/client'

const defaultTranslation: TranslationResource = {
    [LanguageCode.EN]: {
        translation: {
            'test-key-1': 'This is a default translation for the key',
            'test-key-2': 'This is a default translation for the key 2',
            'test-key-11': 'This is a default translation for the key 11',
            'test-key-111': 'This is a default translation for the key 111',
            'test-key-intrapolation':
                'This is a default translation for the key {{key}}',
        },
    },
    [LanguageCode.DE]: {
        translation: {
            'test-key-1': 'Dies ist eine Standardübersetzung für den Schlüssel',
            'test-key-2':
                'Dies ist eine Standardübersetzung für den Schlüssel 2',
            'test-key-11':
                'Dies ist eine Standardübersetzung für den Schlüssel 11',
            'test-key-111':
                'Dies ist eine Standardübersetzung für den Schlüssel 111',
            'test-key-intrapolation':
                'Dies ist eine Standardübersetzung für den Schlüssel {{key}}',
        },
    },
}

init({
    code: '6gmhja7xN03MhCZ7HcBTaIeUddZ7pRSGwTCex99.dGVuYW50X1lGYTRRanRrcmRfMzUwMDQw',
    clientTranslations: defaultTranslation,
    defaultLanguage: LanguageCode.EN,
    supportedLngs: [LanguageCode.EN, LanguageCode.DE],
}).then(() => {
    ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
        <React.StrictMode>
            <App />
        </React.StrictMode>
    )
})

Default Translations

Default translations need to be set for the default language and can also be set for other languages used in the application. They serve two key purposes:

  1. They provide a starting point for translating a key.
  2. They act as a fallback value if a key is not translated or if the application data is unavailable.
const defaultTranslation: TranslationResource = {
    [LanguageCode.EN]: { // For example the default language here is English
        translation: {
            'test-key-1': 'This is a default translation for the key',
            'test-key-2': 'This is a default translation for the key 2',
            'test-key-11': 'This is a default translation for the key 11',
            'test-key-111': 'This is a default translation for the key 111',
            'test-key-intrapolation':
                'This is a default translation for the key {{key}}',
        },
    },
}

Translation Function

You can add localized text keys using the Translate component and the useTranslation hook. Here are examples of both:

import './App.css'
import { useTranslate, Trans } from '@lingufox/client'

function App() {
    const { t } = useTranslation()

    return (
        <div>
            <h1> Test React Vite App </h1>
            Component: <Trans
                i18nKey="test-key-1"
                components={{
                    u: <u />,
                    em: <em />,
                    a: <a />,
                }}
            />
            Translatable:{' '}
            <Trans
                i18nKey="test-key-translatable"
                components={{
                    u: <u />,
                    em: <em />,
                    a: <a />,
                }}
            />
            <div></div>
            <p> {t('test-key-10')} </p>
            <p> {t('test-key-11')} </p>
            <p> {t('test-key-12')} </p>
            <p> {t('test-key-intrapolation', { key: 1 })} </p>
            <div></div>
        </div>
    )
}

export default App

Changing Language

To change the localization, use the changeLanguage function. Here’s an example:

import { useTranslate, LanguageCode } from '@lingufox/client'
const { t } = useTranslate()

changeLanguage(LanguageCode.DE)

By following these steps, you can effectively integrate and utilize the LinguFox library in your React application.

Best Practices

1. String Concatenation

Avoid string concatenation in translations as it can lead to issues with word order in different languages.

❌ Don't do this:

`${t(translationSourceLanguageIso)} (${t('source_language')})`
// or
t(translationSourceLanguageIso) + ' (' + t('source_language') + ')'

✅ Do this instead:

// In translation file:
{
    "source_language_iso": "{{sourceLanguage}} (Source Language)"
}

// In your code:
t('source_language_iso', {
    sourceLanguage: t(translationSourceLanguageIso)
})

These best practices are aligned with i18next's recommended best practices to ensure consistent and maintainable localization patterns.