Code Monkey home page Code Monkey logo

localizor's Introduction

localizor

A packager that will compact all your translation keys onto one single file.

Why ?

Managing translation keys always been complicated. You always need to remember to update the translation file when you remove translation usage. In general you end up with a translation file full of un-used keys. And in the most cases, they are complicated to find.

How ?

localizor provides a simpler way to manage your keys. It uses the folder structure to organize keys in the main translation file. Simply create a .locale.yml next to the component which needs the translations, the process will take it and update the main translation file.

For example :

src/components/header.js :

...
<h1>{t('components.header.title')}</h1>
...

src/components/header.locale.yml :

title: Main title

Will be packaged on

src/locales/translations.yml

en:
  components:
    header:
     title: Main title

With this structure, if you want to know if the translation key is still in use, you just have to search after the related component in your components. If it is not, the key is unused. Localizor provides you a file watcher which will automatically update the main translation file for you.

Usage

yarn add localizor -D
yarn localizor

Config

You can configure localizor by adding an .localizorrc file on the root of your project.

Default config is :

{
  root:          'src', // Root folder where it will look for translation files
  localeFile:    'locale', // The extension file for localizor will look (*.[localeFile].[extension], in this example *.locale.yml) 
  extension:     'yml', // (yml || json)
  defaultLocale: 'en', // The root of the translation file 
  targetFile:    'translations', // The path for the main file (/[targetFile].[extension], in this example ./translations.yml)
  watch:         true, // If the script shoud watch file change
  ignoreFiles:   /(^|[\/\\])\../, // Ignores files from being watched ( config here https://github.com/paulmillr/chokidar) 
  watchFolder:   '.' // Folder where localizor should watch for translation files
}

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.