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 +50 -55
- data/VERSION +1 -1
- data/app/controllers/express_translate/ajax/languages_controller.rb +1 -4
- data/app/controllers/express_translate/base_controller.rb +8 -4
- data/app/views/layouts/express_translate/translate.html.erb +0 -1
- data/express_translate.gemspec +1 -1
- data/lib/express_translate/database_management.rb +2 -2
- data/lib/generators/express_translate/install_generator.rb +1 -0
- data/spec/controllers/ajax/codes_controller_spec.rb +1 -1
- data/spec/controllers/options_controller_spec.rb +1 -1
- data/spec/spec_helper.rb +17 -0
- metadata +2 -2
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.
|
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
|
-
```
|
35
|
-
|
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
|
-
```
|
42
|
-
|
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
|
-
|
51
|
+
username: "username"
|
52
|
+
password: "password"
|
50
53
|
```
|
51
54
|
|
52
|
-
###
|
55
|
+
###Advanced usage
|
56
|
+
#### Modify accounts
|
53
57
|
|
54
|
-
Account list config in
|
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: "
|
60
|
-
password: "
|
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
|
-
|
72
|
-
```
|
69
|
+
**``http://you_domain/express_translate/reset/account``**
|
73
70
|
|
74
|
-
|
75
|
-
```bash
|
76
|
-
rails g express_translate:seed
|
77
|
-
```
|
71
|
+
#### Seed data
|
78
72
|
|
79
|
-
|
80
|
-
```bash
|
81
|
-
rails g express_translate:reset
|
82
|
-
```
|
73
|
+
``rails g express_translate:seed``
|
83
74
|
|
84
|
-
|
85
|
-
|
86
|
-
http://you_domain/express_translate/login
|
75
|
+
#### Reset data
|
76
|
+
``rails g express_translate:reset``
|
87
77
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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
|
-
|
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
|
-
###
|
101
|
-
|
102
|
-
|
103
|
-
* YML file
|
87
|
+
### Import files
|
88
|
+
* CSV file
|
89
|
+
* YML file
|
104
90
|
|
105
|
-
|
106
|
-
|
91
|
+
### Export files
|
92
|
+
* CSV file
|
107
93
|
|
108
94
|
### Application
|
109
|
-
Backend for Ruby on Rails
|
110
|
-
|
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.
|
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">
|
data/express_translate.gemspec
CHANGED
@@ -4,7 +4,7 @@ module ExpressTranslate
|
|
4
4
|
require 'redis'
|
5
5
|
|
6
6
|
def self.redis
|
7
|
-
@redis
|
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
|
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.
|
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:
|
412
|
+
hash: 2191332962475855690
|
413
413
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
414
414
|
none: false
|
415
415
|
requirements:
|