Socket
Book a DemoInstallSign in
Socket

@mangoweb/contember-translation-provider

Package Overview
Dependencies
Maintainers
6
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mangoweb/contember-translation-provider

## Installation

0.0.5
latest
Source
npmnpm
Version published
Maintainers
6
Created
Source

Contember Translation Provider

Installation

npm install @mangoweb/contember-translation-provider

How to use

Install translations plugin to your contember project.

In TranslationProvider.tsx

import { ContemberTranslationProvider, useIsError } from '@mangoweb/contember-translation-provider'

// Wrap your app by this component
export const TranslationProvider = () => (
	<ContemberTranslationProvider
		project="__PROJECT__"
		stage="live"
		domain="app"
		initialLanguage="en"
	>
		<YourAppContent />
	</ContemberTranslationProvider>
)

const TranslationProviderInner = (props) => {
	const [loadFailedRetrying, setLoadFailedRetrying] = React.useState(false)
	const isError = useIsError()

	if (isError) {
		return (
			<div>
				<h1>
					Loading translations has failed.
				</h1>
				<button
					onClick={() => {
						setLoadFailedRetrying(true)
						location.reload()
					}}
					disabled={loadFailedRetrying}
				>
					Try again
				</button>
			</div>
		)
	}

	return <>{props.children}</>

In any other component which needs translations

import { useTranslate } from '@mangoweb/contember-translation-provider'

export const OtherComponent: React.SFC = () => {
	const translate = useTranslate()

	// const setLanguage = useSetLanguage()
	// const isLoadingInitialLanguage = useIsLoadingInitialLanguage()
	// const isLoadingAnotherLanguage = useIsLoadingAnotherLanguage()
	// const isError = useIsError()
	// const currentLanguage = useCurrentLanguage()
	// const currentVisibleLanguage = useCurrentVisibleLanguage()

	return <div>{translate('greeting.world')}</div>
}

FAQs

Package last updated on 30 Jun 2020

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.