Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

i18n-table

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-table

A React component that helps organize and manage translations

  • 1.0.5
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by175%
Maintainers
1
Weekly downloads
 
Created
Source

i18n-table

MIT license Vazco NPM version

Installation

npm install i18n-table

Get started

  1. Import TranslationManager and styles
import TranslationManager from "i18n-table";
import "i18n-table/dist/index.css";
  1. Prepare translations
const translations = {
  en: {
    colors: {
      red: "Red",
      blue: "Blue",
      green: "Green",
    },
  },
  es: {
    colors: {
      red: "Rojo",
      green: "Verde",
    },
  },
};

translations object should have locales as keys and objects or nested objects as values.

  1. Prepare locales with full and local names.

[!IMPORTANT] The locale property have to match with locale used in the first step.

const locales = [
  { locale: "en", fullName: "English", localName: "English" },
  { locale: "es", fullName: "Spanish", localName: "Español" },
];
  1. Render TranslationManager on your page
export const App = () => {
  const onSave = (translation) => {
    /* Handle saving translations - structure is the same as in the step 2. */
  };

  return <TranslationManager translations={translations} locales={locales} onSave={onSave} />;
};
  1. If you want to write your own styles, copy /src/lib/styles.css file to your project, modify it and import it instead of i18n-table/dist/index.css

  2. You can also customize header translations.

const componentTranslations = {
  save: t("save"),
  search: t("search"),
  select: t("select"),
  translationKey: t("translationKey"),
};

export const App = () => {
  const onLocaleChange = (locale) => i18n.setLocale(locale);

  return (
  <TranslationManager
    {/* ... */}
    componentTranslations={componentTranslations}
    onLocaleChange={onLocaleChange}
  />
)
};

License

Like every package maintained by Vazco, i18n-table package is MIT licensed.

Keywords

FAQs

Package last updated on 25 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc