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

@lingui/remote-loader

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lingui/remote-loader

Load remotely your translations

  • 3.11.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

[![License][badge-license]][license] [![Version][badge-version]][package] [![Downloads][badge-downloads]][package]

@lingui/remote-loader

Load your .json catalogs remotely.

This tool is useful when you have plain .json files which are messages/catalogs, but Lingui needs them compiled, this tool under the hood will compile them to Lingui standards.

Usage

import { i18n } from "@lingui/core"
import { remoteLoader } from "@lingui/remote-loader"

export async function remoteActive(locale: string) {
  const remoteMessages = await fetch(`https://some-api/${locale}/messages`)
  const compiledMessages = remoteLoader({ messages: remoteMessages })
  i18n.load(locale, compiledMessages)
  i18n.activate(locale)
}

With fallback messages

import { i18n } from "@lingui/core"
import { remoteLoader } from "@lingui/remote-loader"
import { messages: fallbackMessages } from "./local-messages-to-fallbac/"

export async function remoteActive(locale: string) {
  const remoteMessages = await fetch(`https://some-api/${locale}/messages`)
  const compiledMessages = remoteLoader({ messages: remoteMessages, fallbackMessages })
  i18n.load(locale, compiledMessages)
  i18n.activate(locale)
}

Keywords

FAQs

Package last updated on 07 Sep 2021

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