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

@opensea/next-translate

Package Overview
Dependencies
Maintainers
9
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opensea/next-translate

Package for custom useTranslate hook

  • 1.0.6
  • npm
  • Socket score

Version published
Weekly downloads
103
decreased by-6.36%
Maintainers
9
Weekly downloads
 
Created
Source

next-translate

@opensea/next-translate provides a useTranslate hook that returns a translation function that wraps next-translate's t function to support in-code defaults for plural translation variants and a slightly improved interface for translations without variables.

Getting started

Install

npm install

Usage

import { useTranslate } from '@opensea/next-translate';

const Example = () => {
  const t = useTranslate('ns1');
  const [count, setCount] = useState(0);

  // Second param is default value and third param variables (optional)
  const noVariables = t('example.noVariables', 'No variables');

  // Default values for "zero", "one", and "other" translations variants can be specified in code
  const plurals = t(
    'example.plurals',
    {
      zero: 'No items',
      one: '1 item',
      other: '{{count}} items'
    },
    { count }
  );

  // Default value for "zero" can be omitted and default value for "other" will be used
  const optionalZero = t(
    'example.optionalZero',
    { one: '1 item', other: '{{count}} items' },
    { count }
  );

  // ...
};

Local development

Running tests

npm run test

FAQs

Package last updated on 28 Sep 2023

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