Giter Site home page Giter Site logo

awesome-localization-script's Introduction

Awesome localization script Python version

A simple python script to translate any file to different languages providing locale files in JSON format.

Prerequisites

You need to install python to run the script

You can download it here

Usage

Add tags and keys to the file that you want to translate:

<lang>key</lang>

Example

index.html

<li>
  <a href="#services" class="scrollto"><lang>services</lang></a>
</li>
<li>
  <a href="#motivation" class="scrollto"><lang>motivation</lang></a>
</li>
<li>
  <a href="#projects" class="scrollto"><lang>projects</lang></a>
</li>
<li>
  <a href="#team" class="scrollto"><lang>team</lang></a>
</li>
<li>
  <a href="#contact" class="scrollto"><lang>contact</lang></a>
</li>

Create locales folder

Add the locale files to the folder, use the format shown below to add the key and translations, and save the file as .json:

{
  "key": "translation"
}

Example

ca.json

{
  "services": "Serveis",
  "motivation": "Motivació",
  "projects": "Projectes",
  "team": "Equip",
  "contact": "Contacte",
}

Check the configuration of the script, you can change the following options:

OPEN_TAG = "<lang>"
CLOSE_TAG = "</lang>"
LOCALE_FILES_PATH = "locales/"
INPUT_FILE_PATH = "index.html"
OUTPUT_FILE_NAME = "index.html"
  • OPEN_TAG & CLOSE_TAG: You can change the open and close tag to indicate the keys
  • LOCALE_FILES_PATH: Path to locales folder
  • INPUT_FILE_PATH: Path and filename to input file
  • OUTPUT_FILE_NAME: Filename to output file

Finally execute the script with:

python translate.py

After running the script you will find a folder for each language file you provided with the translation inside.

Example

ca/index.html

<li>
  <a href="#services" class="scrollto">Serveis</a>
</li>
<li>
  <a href="#motivation" class="scrollto">Motivació</a>
</li>
<li>
  <a href="#projects" class="scrollto">Projectes</a>
</li>
<li>
  <a href="#team" class="scrollto">Equip</a>
</li>
<li>
  <a href="#contact" class="scrollto">Contacte</a>
</li>

For more info you can check the provided example.

awesome-localization-script's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.