@kotlia/react-i18n-auto

1.0.1 • Public • Published

react-i18n-auto

A simple react component to automatically translate string component with Google Translate API - without API Key.

Quick Example

import React, { Component } from "react"
import Translator, { translate } from 'react-i18n-auto'

export default class Page extends Component {

    render() {
    
        const T = Translator({from: "en"});
        
        console.log(translate("Hello, world", { from: "en", to: "fr" }));  // => "Bonjour le monde"
        
        return (
            <>
                <T>Hello, world</T>  // Text enclosed by "T" (in this case) will be translated.
            </>
        );
        
    }
    
}

Docs

Translator({ from: string, to: string | undefined })

Creates translator.

from: Language code of the original language.
to: Force language to be converted to. By default, text will be translated to the browser language. (navigator.language)

/@kotlia/react-i18n-auto/

    Package Sidebar

    Install

    npm i @kotlia/react-i18n-auto

    Weekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    12.6 kB

    Total Files

    14

    Last publish

    Collaborators

    • kotlia