1.0.1 • Published 3 years ago

@kotlia/react-i18n-auto v1.0.1

Weekly downloads
96
License
MIT
Repository
github
Last release
3 years ago

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)