Code Monkey home page Code Monkey logo

ghost_reader's Introduction

GhostReader

GhostReader is an alternative I18n backend which makes use of the GhostWriter service (https://github.com/branch14/ghost_writer).

Usage

Gemfile

gem 'ghost_reader'

For development & staging

config/initializers/ghost_reader.rb

unless Rails.env.test?
  config = {
    :report_interval => 42, # secs
    :retrieval_interval => 23, # secs
    :fallback => I18n.backend,
    :logfile => File.join(Rails.root, %w(log ghostwriter.log)),
    :service => {
      :api_key => '<here_goes_your_api_key>'
    }
  }
  
  I18n.backend = GhostReader::Backend.new(config)
end

Configuration

  • 'report interval' is the delay in seconds between subsequent POST requests (reporting requests), which report missing translations.
  • 'retrieval_interval' is the delay in seconds between subsequent GET requests (incremental requests), which retrieve updated translations.
  • 'fallback' point to the I18n backend wich should be used as a fallback.
  • 'logfile' is the path to a optional, separate logfile. If this is omitted, log messages go to standard out.
  • 'service' holds a hash with connection details.
    • 'api_key' is a GhostWriter API key.
    • 'host' is the hostname, optionally with port.
    • 'protocol' is either 'http' or 'https'
    • 'uri' is the complete uri with the folling keys, which will be replaced: :protocol, :host, :api_key

For Live

In a live system you typically don't want to depend on another system, so we'll just go with a static export of translations.

# specify where to get the static file from
echo 'static: https://<ghostservice>/system/static/<apikey>.yml' >> config/ghost_reader.yml

# in a cron job do this
rake ghost_reader:poll

The rake task will rewrite config/locales/ghost_reader.yml if it changed and touch tmp/restart.txt to make passenger restart the application.

It's a good idea to delete all other translations files on this system.

TODO

  • implement counting, for statistics
  • document all config options

THANKS

All work on GhostReader is supported by Panter LLC, Zurich, Switzerland. http://panter.ch

Special thanks go to Andreas Koenig, for his inital version of GhostReader, and Peco Danajlovski for helping with the rewrite.

ghost_reader's People

Contributors

branch14 avatar koa avatar munen avatar vortex avatar robinbortlik avatar

Watchers

 avatar James Cloos avatar  avatar

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.