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

i18n1998

v1.1.48

Published

This module contains the configs, helpers and translations required to make an identity app available in multiple languages.

Downloads

11

Readme

WSO2 Identity Server - Internationalization (i18n) module for Identity apps.

This module contains the configs, helpers and translations required to make an identity app available in multiple languages.

Implemented on top of i18next library.

Install

Add following dependency in your package.json file. "@wso2is/i18n": "<VERSION>"

Build

npm run build

Running Tests

npm run test

Usage

Initialize the module.

import { I18n } from "@wso2is/i18n";

I18n.init(options, override, true, true)
    .then(() => {
        // On successful init.
    })
    .catch((error) => {
        // On error.
    });

Init function arguments:

| Parameter | Type | Default | Description |
| :------------------------ |:--------------------------:| :---------------------------------| :-------------------------------------------------| | options | i18next.InitOptions | undefined | Passed in init options. | override | boolean | false | Should the passed in options replace the default. | autoDetect | boolean | false | If autodetect plugin should be used or not. | useBackend | boolean | false | If XHR back end plugin should be used or not. | debug | boolean | false | If debug is enabled. | framework | SupportedI18nFrameworks | SupportedI18nFrameworks.REACT | The framework to use. | plugins | i18next.Module[] | undefined | Other i18next plugins to use.

Get the instance.

import { I18n } from "@wso2is/i18n";

const i18n = I18n.instance;

Use in the provider

import { I18nextProvider } from "react-i18next";
import { I18n } from "@wso2is/i18n";

return (
    <I18nextProvider i18n={ I18n.instance }>
        ...
    </I18nextProvider>
)

Adding a new language to the module.

  1. Create a folder with the language's ISO code inside src/translations. ex: en-GB
  2. Create a portals folder and implement the common, user portal, dev portal, etc. namespaces.
  3. Create other folders such as docs, etc. and place the necessary translations.
  4. Create a meta.ts file and add all the necessary metadata regarding the language bundle.
import { LocaleMeta } from "../../models";

export const meta: LocaleMeta = {
    code: "en-GB",
    flag: "gb",
    name: "English (United Kingdom)",
    namespaces: [ "common", "devPortal", "myAccount" ]
};
  1. Export the bundle from the index.
import * as portals from "./portals";
import { LocaleBundle } from "../../models";
import { meta } from "./meta";

export const EN_GB: LocaleBundle = {
    meta,
    resources: {
        portals
    }
};

Adding a new language during runtime.

  1. Create a folder with the language's ISO code inside the distribution directory. ex: For Dev Portal, the i18n bundle will be saved under resources/i18n. Create a folder fr to store french language the translations.
  2. Copy the translated JSON files.
  3. Update the meta.json file.
{
    "fr": {
        "code": "fr",
        "flag": "fr",
        "name": "French (France)",
        "namespaces": ["common", "devPortal"],
        "paths": {
            "devPortal": "fr/portals/devPortal.json",
            "common": "fr/portals/common.json"
        }
    }
}

License

Licenses this source under the Apache License, Version 2.0 (LICENSE), You may not use this file except in compliance with the License.