arango_i18n 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +82 -0
- data/Rakefile +2 -0
- data/arango_i18n.gemspec +26 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/arango_i18n.rb +5 -0
- data/lib/arango_i18n/store.rb +35 -0
- data/lib/arango_i18n/version.rb +3 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6d66762cb6e7661f3ab131304313df3527285113
|
4
|
+
data.tar.gz: f3f8e6bd4b5f58873e6442a496bac59da87458d2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 02e6e3b91d2dd0b29c12ab9b6df1e21a9ca96c16a9b8d7fcf612fd7cc7e159e2afb5a5f2d60b74e69015f2a7c62a1925a2272fc974320339e95ad71ced6c2cbf
|
7
|
+
data.tar.gz: 879a472af93a7b792673374578b55ef01c073ab382e38c1f46f62590cee05749d14629361d343a0cb4fa1232db28996fd3c7d2b6448003dbb02b8aec93fd1a10
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Mike Williamson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# ArangoI18n
|
2
|
+
|
3
|
+
This gem lets you use the [ArangoDB](https://www.arangodb.com/)
|
4
|
+
multi-modal database as an I18n backend in your Ruby projects.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'arango_i18n'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install arango_i18n
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Using this gem with a Rails project might look something like this:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
# config/initializers/i18n_backend.rb
|
28
|
+
|
29
|
+
database = Ashikawa::Core::Database.new do |config|
|
30
|
+
config.url = "http://localhost:8529"
|
31
|
+
config.database_name = 'my_app_i18n'
|
32
|
+
config.username = ""
|
33
|
+
config.password = ""
|
34
|
+
end
|
35
|
+
|
36
|
+
# database.collection("i18n") will return a collection object
|
37
|
+
# The collection will be created if it does not exist
|
38
|
+
I18n.backend = I18n::Backend::KeyValue.new(ArangoI18n::Store.new(database.collection("i18n")))
|
39
|
+
```
|
40
|
+
|
41
|
+
If there are existing translations lurking in config/locales/\*.yml you
|
42
|
+
probably will want to load them in with this:
|
43
|
+
|
44
|
+
```
|
45
|
+
I18n.backend.load_translations
|
46
|
+
```
|
47
|
+
|
48
|
+
Then end result of the code above is that the my_app_i18n database would
|
49
|
+
have a collection called "i18n" which contains a bunch of documents that
|
50
|
+
look something like this:
|
51
|
+
|
52
|
+
```
|
53
|
+
{ "key": "en.hello", "value": "\"Hello world\"" }
|
54
|
+
{ "key": "fr.hello", "value": "\"Bonjour le monde\"" }
|
55
|
+
```
|
56
|
+
Your translations then work as normal:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
[3] pry(#<#<Class:0x007f06e47ef788>>)> t("hello")
|
60
|
+
=> "Hello world"
|
61
|
+
[4] pry(#<#<Class:0x007f06e47ef788>>)> I18n.locale = :fr
|
62
|
+
=> :fr
|
63
|
+
[5] pry(#<#<Class:0x007f06e47ef788>>)> t("hello")
|
64
|
+
=> "Bonjour le monde"
|
65
|
+
```
|
66
|
+
|
67
|
+
## Development
|
68
|
+
|
69
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
70
|
+
|
71
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
If you see something that can be improved, let me know.
|
76
|
+
Open an issue, or send a pull request.
|
77
|
+
|
78
|
+
1. Fork it ( https://github.com/sleepycat/arango_i18n/fork )
|
79
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
80
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
81
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
82
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/arango_i18n.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'arango_i18n/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "arango_i18n"
|
8
|
+
spec.version = ArangoI18n::VERSION
|
9
|
+
spec.authors = ["Mike Williamson"]
|
10
|
+
spec.email = ["mike@korora.ca"]
|
11
|
+
|
12
|
+
spec.summary = "Use ArangoDB as your I18n backend."
|
13
|
+
spec.description = "Use the multi-modal ArangoDB as your I18n backend."
|
14
|
+
spec.homepage = "http://github.com/sleepycat/arango_i18n"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_runtime_dependency "ashikawa-core", "~> 0.14.0"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
26
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "arango_i18n"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/arango_i18n.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'ashikawa-core'
|
2
|
+
module ArangoI18n
|
3
|
+
|
4
|
+
class Store
|
5
|
+
|
6
|
+
attr_accessor :collection
|
7
|
+
|
8
|
+
def initialize collection
|
9
|
+
@collection = collection
|
10
|
+
end
|
11
|
+
|
12
|
+
def []= key, value
|
13
|
+
@collection.create_document(key: key, value: value)
|
14
|
+
value
|
15
|
+
end
|
16
|
+
|
17
|
+
def [] key
|
18
|
+
@collection.query.execute("FOR i IN @@collection FILTER i.key == @key RETURN i.value", bind_vars: {"@collection": @collection.name, key: key}).to_a.first
|
19
|
+
end
|
20
|
+
|
21
|
+
def keys
|
22
|
+
@collection.query.execute("FOR i IN @@collection COLLECT keys = i.key RETURN keys", bind_vars: {"@collection": @collection.name}).to_a
|
23
|
+
end
|
24
|
+
|
25
|
+
def del key
|
26
|
+
@collection.query.execute("FOR i IN @@collection FILTER i.key == @key REMOVE i IN @@collection", bind_vars: {"@collection": @collection.name, key: key}).to_a
|
27
|
+
end
|
28
|
+
|
29
|
+
def available_locales
|
30
|
+
@collection.query.execute("LET all_locales = (FOR i IN @@collection RETURN SPLIT(i.key, '.')[0]) RETURN UNIQUE(all_locales)", bind_vars: {"@collection": @collection.name}).to_a.first
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: arango_i18n
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Williamson
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ashikawa-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.14.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.14.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.2'
|
69
|
+
description: Use the multi-modal ArangoDB as your I18n backend.
|
70
|
+
email:
|
71
|
+
- mike@korora.ca
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- arango_i18n.gemspec
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- lib/arango_i18n.rb
|
88
|
+
- lib/arango_i18n/store.rb
|
89
|
+
- lib/arango_i18n/version.rb
|
90
|
+
homepage: http://github.com/sleepycat/arango_i18n
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.4.5
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Use ArangoDB as your I18n backend.
|
114
|
+
test_files: []
|