@pretronic/react-github-languages
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

Pretronic open source logo
Pretronic Open Source
React GitHub Languages

Translate your React projects easily

Version npm downloads Pretronic Discord Pretronic Docs Platform

The React GitHub language project is a simple and easy-to-use library for translating your React projects into different languages. The library directly consumes the language files from a GitHub repository.


Features & Advantages

  • Multiple languages — with this library you can use as many languages as you want. All languages are listed in the language.json in your GitHub repository.

  • Message variables — you can pass custom variables to any translatable message.

  • No backend infrastructure required — all messages are consumed directly from the GitHub repository, you don't need a server.

  • Everyone can translate — let everyone in your community help translate your projects, they can easily contribute to your GitHub language repository.

  • Easy to use and simple — the library is very light and can be integrated very quickly.

Quick start

React GitHub Languages can be installed via the npm packet manager.

npm install @pretronic/react-github-languages

After the installation, create a new GitHub repository and add a new language file (en.json). An example repository can be found here.

{
  "name": "English",
  "localName": "English",
  "code": "en",
  "messages": {
    "page.description": "Today is the {today}"
  }
}

Your app can be localized very easily. Just set up the language provider and pass your variables to the message component, and finally translate your messages. You can find a clear introduction here.

import React from 'react';
import './App.css';
import {LanguageProvider, Message} from "@pretronic/react-github-languages";

export default class App extends React.Component<{}, {}> {


    render() {
        return(<LanguageProvider repository={"Pretronic/PretronicAccountTranslations"} branch={"main"} language={"en"} >

        <div style={{display: "flex",textAlign: "center",justifyContent: "center"}}>
            <p>
                <Message name={"page.description"} variables={{today: new Date().toLocaleDateString()}} />
            </p>
        </div>

        </LanguageProvider>)
    }
}

License

The React GitHub Languages Project is under the Apache License, version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package Sidebar

Install

npm i @pretronic/react-github-languages

Weekly Downloads

0

Version

1.0.6

License

Apache-2.0

Unpacked Size

37.8 kB

Total Files

15

Last publish

Collaborators

  • fridious
  • dkrieger