express_translate 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  Express Translate
2
2
  =====
3
+ I18n Translation Interface for end user in Rails app
3
4
 
4
5
  ```bash
5
6
  __ _____ _ _
@@ -19,92 +20,86 @@ Express Translate
19
20
 
20
21
  =====
21
22
 
22
- ##Installation
23
+ ## Installation
23
24
  ### 1. Gemfile
24
25
  ```bash
25
- gem 'express_translate', '~> 1.0.8'
26
+ gem 'express_translate', '~> 1.0.9'
26
27
  ```
27
28
 
28
29
  ### 2. Setup
29
30
  Run on terminal.
30
- ```bash
31
- gem install express_translate
32
- ```
33
31
 
34
- ```bash
35
- bundle install
36
- ```
32
+ ```gem install express_translate```
33
+
34
+ ```bundle install```
37
35
 
38
36
  ### 3. Install
39
37
  Open terminal and run:
40
38
 
41
- ```bash
42
- rails g express_translate:install
43
- ```
44
-
45
- ##Using
39
+ ```rails g express_translate:install```
40
+
41
+ ## Using
46
42
  ### Run
47
43
  Start Redis Server
44
+ ``redis-server``
45
+
46
+ ###Basic usage
47
+ You can see login page at: ``/express_translate/login``
48
+
49
+ Login with account:
48
50
  ```bash
49
- redis-server
51
+ username: "username"
52
+ password: "password"
50
53
  ```
51
54
 
52
- ### Modify accounts
55
+ ###Advanced usage
56
+ #### Modify accounts
53
57
 
54
- Account list config in "/config/express_translate.yml".
58
+ Account list config in ``/config/express_translate.yml``.
55
59
  You can add account:
56
60
  ```bash
57
61
  account:
58
62
  -
59
- username: "abc_name"
60
- password: "abc_pass"
63
+ username: "your_username"
64
+ password: "your_password"
61
65
  ```
62
66
 
63
67
  You need reset account for modified
64
- ```bash
65
- rails g express_translate:reset_account
66
- ```
67
- Or goto url
68
- ```bash
69
- http://you_domain/express_translate/reset/account
70
68
 
71
- * e.g: http://localhost:3000/express_translate/reset/account
72
- ```
69
+ **``http://you_domain/express_translate/reset/account``**
73
70
 
74
- ### Seed
75
- ```bash
76
- rails g express_translate:seed
77
- ```
71
+ #### Seed data
78
72
 
79
- ### Reset data
80
- ```bash
81
- rails g express_translate:reset
82
- ```
73
+ ``rails g express_translate:seed``
83
74
 
84
- ### Login page
85
- You can see login page at:
86
- http://you_domain/express_translate/login
75
+ #### Reset data
76
+ ``rails g express_translate:reset``
87
77
 
88
- * e.g: http://localhost:3000/express_translate/login
89
-
90
- ### Packages management
91
- You can see at:
92
- http://you_domain/express_translate
78
+ #### i18next
79
+ Add script to header page
80
+ ``<script src="http://you_domain/express_translate/i18n/package_id"></script>``
81
+ Note:
82
+ * you_domain: e.g ``localhost:3000``
83
+ * package_id: is a package id.
93
84
 
94
- * e.g: http://localhost:3000/express_translate
95
-
96
- Note: You can see before login. Account for login in config file ("/config/express_translate.yml").
97
-
98
- ##Support
85
+ ## Support
99
86
 
100
- ### Files
101
- #### Import
102
- * CSV file
103
- * YML file
87
+ ### Import files
88
+ * CSV file
89
+ * YML file
104
90
 
105
- #### Export
106
- * CSV file
91
+ ### Export files
92
+ * CSV file
107
93
 
108
94
  ### Application
109
- Backend for Ruby on Rails
110
- <!-- Get data with json (for Javascript) => Development -->
95
+ * Backend for Ruby on Rails
96
+ * Frontend (Single Page Application) with I18next (can you see more info: http://i18next.com)
97
+
98
+ ## Contributing to formnestic
99
+
100
+ - Contribution, Suggestion and Issues are very much appreciated :). Please also fork and send your pull request!
101
+ - Make sure to add tests for it when sending for pull requests. This is important so I don't break it in a future version unintentionally.
102
+
103
+ ## Copyright
104
+
105
+ Copyright (c) 2014 Karl, released under the MIT license
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.8
1
+ 1.0.9
@@ -42,10 +42,7 @@ class ExpressTranslate::Ajax::LanguagesController < ActionController::Base
42
42
  if check['success'] == true
43
43
  @selects = YAML.load_file("#{ExpressTranslate.root}/config/languages.yml")
44
44
  @origin = Language.get_origin(params[:packages])
45
- @origin_keys = []
46
- LanguageDetail.info(@origin).all.each do |item|
47
- @origin_keys.push(item["code"])
48
- end
45
+ @origin_keys = LanguageDetail.info(@origin).all.collect{|x| x['code']}
49
46
  @languages = Package.find(params[:packages])['language']
50
47
  @max = @origin.nil? ? 1 : LanguageDetail.info(@origin).all.count
51
48
  @LanguageDetail = LanguageDetail
@@ -3,12 +3,14 @@ class ExpressTranslate::BaseController < ActionController::Base
3
3
 
4
4
  # Check login status by cookie
5
5
  def check_authentication
6
- token_store = getCookie(request.headers["HTTP_COOKIE"], "token")
6
+ token_store = Utils.getCookie(request.headers["HTTP_COOKIE"], "token")
7
7
  return (token_store.present? and Account.find_by_token(token_store).present?)
8
8
  end
9
-
9
+ end
10
+
11
+ class Utils
10
12
  # Get cookie form header action
11
- def getCookie(string, key)
13
+ def self.getCookie(string, key)
12
14
  if string.present?
13
15
  string.split(";").each do |cookie|
14
16
  cookie.strip!
@@ -20,4 +22,6 @@ class ExpressTranslate::BaseController < ActionController::Base
20
22
  end
21
23
  return ""
22
24
  end
23
- end
25
+ end
26
+
27
+ # Utils.get_cookie("token=value; token2=value2", key).should == "value1,value2"
@@ -4,7 +4,6 @@
4
4
  <title>Express Translate</title>
5
5
  <%= stylesheet_link_tag "express_translate/application", :media => "all" %>
6
6
  <%= javascript_include_tag "express_translate/application" %>
7
- <script src="http://localhost:3000/express_translate/i18n/be"></script>
8
7
  <%= csrf_meta_tags %>
9
8
  </head>
10
9
  <body id="express_translate">
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "express_translate"
8
- s.version = "1.0.8"
8
+ s.version = "1.0.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Karl"]
@@ -4,7 +4,7 @@ module ExpressTranslate
4
4
  require 'redis'
5
5
 
6
6
  def self.redis
7
- @redis = Redis.new(host: ExpressTranslate.config["connect"]["host"], port: ExpressTranslate.config["connect"]["port"], db: ExpressTranslate.config["connect"]["db"])
7
+ @redis ||= Redis.new(host: ExpressTranslate.config["connect"]["host"], port: ExpressTranslate.config["connect"]["port"], db: ExpressTranslate.config["connect"]["db"])
8
8
  end
9
9
 
10
10
  def self.set(key, obj)
@@ -27,4 +27,4 @@ module ExpressTranslate
27
27
  end
28
28
  end
29
29
  end
30
- end
30
+ end
@@ -16,6 +16,7 @@ module ExpressTranslate
16
16
  # Seed data for redis database
17
17
  def seeds_data
18
18
  ExpressTranslate.seeds
19
+ Account.reset
19
20
  end
20
21
  end
21
22
  end
@@ -1,4 +1,4 @@
1
1
  require 'spec_helper'
2
- describe ExpressTranslate::Ajax::CodesController do
2
+ describe 'ExpressTranslate::Ajax::CodesController' do
3
3
 
4
4
  end
@@ -1,4 +1,4 @@
1
1
  require 'spec_helper'
2
2
  describe ExpressTranslate::OptionsController do
3
3
 
4
- end
4
+ end
data/spec/spec_helper.rb CHANGED
@@ -27,4 +27,21 @@ include ExpressTranslate
27
27
  RSpec.configure do |config|
28
28
  config.include FactoryGirl::Syntax::Methods
29
29
  # Rails.env = "test"
30
+
31
+ Redis.stub(:new).and_return({})
32
+ Redis.class_eval do
33
+ @memory_redis = {}
34
+ alias_method :original_set, :set
35
+ def set(key, obj)
36
+ @memory_redis[key] = obj.to_json
37
+ end
38
+
39
+ def get(key)
40
+ @memory_redis[key]
41
+ end
42
+
43
+ def del(key)
44
+ @memory_redis.delete(:key)
45
+ end
46
+ end
30
47
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: express_translate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -409,7 +409,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
409
409
  version: '0'
410
410
  segments:
411
411
  - 0
412
- hash: -4525537380864736496
412
+ hash: 2191332962475855690
413
413
  required_rubygems_version: !ruby/object:Gem::Requirement
414
414
  none: false
415
415
  requirements: