Socket
Book a DemoInstallSign in
Socket

easy-translation

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

easy-translation

Easy React Translations Component. Translates all text on screen using JSON translation files.

unpublished
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

React - Easy Translation

Installation
 

 

Setup

Setup is simple and easy.

Create a directory in public (or someplace accessable on the internet). Example: "locale", this is where the translation files will be. Create a file for each language that you want to support.

 

Name files based on language. Example : en.json, fr.json... etc

See next section on how to add the Provider to your code. The provider will fetch the translation file needed based on the browser language.

React: Can used directly in your entry point.

import { LanguageProvider } from "easy-translation";
 
function MainPage() {
   return(
     <LanguageProvider languagePath="<http path to language directiory>">
         <YourComponents/>
     </LanguageProvider>
   );
}
export default MainPage;

Nextjs: Needs a client component

entry point:
function MainPage() {
return(
  <Lang>
     <YourComponents/>
  </Lang>
);
}
export default MainPage;
 
client component:
"use client";
import { ReactNode } from "react";
import { LanguageProvider } from "easy-translation";

function Lang({ children }: { children: ReactNode }) {
   return (
     <LanguageProvider languagePath="<http path to language directiory>">
           {children}
     </LanguageProvider>
   );
}
export default Lang;

   

 

 

FAQs

Package last updated on 22 Feb 2025

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