interpreter 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in interpreter.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Jagdeep Singh
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,30 @@
1
+ = Interpreter
2
+
3
+ Interpreter makes managing different translations easy. It provides a simple UI to add and modify translations.
4
+
5
+ == Requirements
6
+
7
+ Interpreter uses a Redis database as the backend to store translations. So make sure you have Redis running on your system and you have redis gem is in your Gemfile.
8
+
9
+ == Installation
10
+
11
+ Add the gem to your Gemfile.
12
+
13
+ gem 'interpreter'
14
+
15
+ Create an initialization file
16
+
17
+ config/initializers/interpreter.rb
18
+
19
+ Add the following to it and you can set a Redis database to use as the backend store
20
+
21
+ Interpreter.setup do |config|
22
+ config.backend = Redis.new
23
+ end
24
+
25
+ == Usage
26
+
27
+ You can access all the translations by visiting the following url
28
+
29
+ /interpreter/translations
30
+
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,12 @@
1
+ class Interpreter::TranslationsController < ApplicationController
2
+
3
+ def index
4
+ @translations = Interpreter::Translation.all
5
+ end
6
+
7
+ def create
8
+ Interpreter::Translation.create(params[:locale], params[:key], params[:value])
9
+ redirect_to interpreter_translations_url, :notice => "Translation added."
10
+ end
11
+
12
+ end
@@ -0,0 +1,16 @@
1
+ = form_tag interpreter_translations_path do
2
+
3
+ .field
4
+ = label_tag :locale
5
+ %br
6
+ = text_field_tag :locale
7
+ .field
8
+ = label_tag :key
9
+ %br
10
+ = text_field_tag :key
11
+ .field
12
+ = label_tag :value
13
+ %br
14
+ = text_field_tag :value
15
+ .actions
16
+ = submit_tag "Save"
@@ -0,0 +1,16 @@
1
+ %h1 Translations
2
+ #translations
3
+ .header
4
+ .key Key
5
+ .value Value
6
+ %br.clearfloat
7
+ .body
8
+ - @translations.each do |t|
9
+ .translation
10
+ .key= t.key
11
+ .value= t.value
12
+ %br.clearfloat
13
+
14
+
15
+ %h2 Add Translation
16
+ = render :partial => "form"
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ namespace :interpreter do
3
+ resources :translations
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "interpreter/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "interpreter"
7
+ s.version = Interpreter::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Jagdeep Singh"]
10
+ s.email = ["jagdeepkh@gmail.com"]
11
+ s.homepage = "https://github.com/jagdeep/interpreter"
12
+ s.summary = %q{Provides an interface for managing translations}
13
+ s.description = %q{Use this to manage translations for different parts of application.}
14
+
15
+ s.rubyforge_project = "interpreter"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,18 @@
1
+ module Interpreter
2
+ autoload :Translation, "interpreter/translation"
3
+
4
+ mattr_reader :backend
5
+ @@backend = nil
6
+
7
+ class Engine < Rails::Engine
8
+ end
9
+
10
+ def self.setup
11
+ yield self
12
+ end
13
+
14
+ def self.backend=(backend)
15
+ @@backend = backend
16
+ I18n.backend = I18n::Backend::Chain.new(I18n::Backend::KeyValue.new(@@backend), I18n.backend)
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ class Interpreter::Translation
2
+ attr_reader :locale, :key, :value
3
+
4
+ def initialize locale, key, value
5
+ @locale = locale
6
+ @key = key
7
+ @value = value
8
+ end
9
+
10
+ def self.all
11
+ collection = []
12
+ Interpreter.backend.keys.each do |key|
13
+ collection << self.new(key.split('.')[0], key, Interpreter.backend[key])
14
+ end
15
+ return collection.sort{|a, b| a.key <=> b.key}
16
+ end
17
+
18
+ def self.create locale, key, value
19
+ I18n.backend.store_translations(locale, { key => value }, :escape => false)
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Interpreter
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: interpreter
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.2
6
+ platform: ruby
7
+ authors:
8
+ - Jagdeep Singh
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-01 00:00:00 +05:30
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: Use this to manage translations for different parts of application.
18
+ email:
19
+ - jagdeepkh@gmail.com
20
+ executables: []
21
+
22
+ extensions: []
23
+
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - .gitignore
28
+ - Gemfile
29
+ - LICENSE.txt
30
+ - README.rdoc
31
+ - Rakefile
32
+ - app/controllers/interpreter/translations_controller.rb
33
+ - app/views/interpreter/translations/_form.html.haml
34
+ - app/views/interpreter/translations/index.html.haml
35
+ - config/routes.rb
36
+ - interpreter.gemspec
37
+ - lib/interpreter.rb
38
+ - lib/interpreter/translation.rb
39
+ - lib/interpreter/version.rb
40
+ has_rdoc: true
41
+ homepage: https://github.com/jagdeep/interpreter
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ requirements: []
62
+
63
+ rubyforge_project: interpreter
64
+ rubygems_version: 1.6.1
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Provides an interface for managing translations
68
+ test_files: []
69
+