1.0.6 • Published 3 years ago

@pretronic/react-github-languages v1.0.6

Weekly downloads
17
License
Apache-2.0
Repository
github
Last release
3 years ago

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.