flame-r18n 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/flame/r18n.rb +53 -0
  3. metadata +80 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a3ab672711c49e894eca42bd80be0a348a007f81
4
+ data.tar.gz: 2dfd1dfb5beca69259e6cbdf5a38e968895e2de9
5
+ SHA512:
6
+ metadata.gz: abb035608d7408040ef65776248777e9f28e057d8e7c8524f204035c43911a457aec197a0aba6601651fcb6b11aaddf1167b05b8e95f7cc9f60e474d427b1d9f
7
+ data.tar.gz: 76b6f00d4aec61853f1f723e855b6bbfda194855133f68c29e608a4ecbc5927b718b758566cfc1c041de5641cc62fdf9ea14056a47af5dc19d2853315a1ec1a9
@@ -0,0 +1,53 @@
1
+ require 'r18n-core'
2
+
3
+ module Flame
4
+ # Module for Flame::R18n extension with helper methods and base class
5
+ module R18n
6
+ include ::R18n::Helpers
7
+
8
+ def self.config(app)
9
+ app.config[:default_locale] = proc { ::R18n::I18n.default }
10
+ app.config[:locales] = proc { ::R18n.default_places }
11
+ app.config[:locales_dir] = proc do
12
+ File.join(app.config[:root_dir], 'locales')
13
+ end
14
+
15
+ ::R18n.default_places { app.config[:locales_dir] }
16
+ end
17
+
18
+ def execute(method)
19
+ load_r18n
20
+ super
21
+ end
22
+
23
+ private
24
+
25
+ def init_r18n
26
+ ::R18n::I18n.new(
27
+ locales_from_env,
28
+ ::R18n.default_places,
29
+ off_filters: :untranslated,
30
+ on_filters: :untranslated_html
31
+ )
32
+ end
33
+
34
+ def locales_from_env
35
+ locales = ::R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE'])
36
+ if params[:locale]
37
+ locales.insert(0, params[:locale])
38
+ elsif session[:locale]
39
+ locales.insert(0, session[:locale])
40
+ end
41
+ end
42
+
43
+ def load_r18n
44
+ ::R18n.clear_cache! if config[:environment] == 'development'
45
+
46
+ ::R18n.thread_set do
47
+ ::R18n::I18n.default = config[:default_locale] if config[:default_locale]
48
+
49
+ init_r18n
50
+ end
51
+ end
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flame-r18n
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Popov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: flame
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 4.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '4.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 4.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: r18n-core
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2'
47
+ description: Flame extension which provides i18n support to translate your web application.
48
+ It is a wrapper for R18n core library. See R18n documentation for more information.
49
+ email:
50
+ - alex.wayfer@gmail.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - lib/flame/r18n.rb
56
+ homepage: https://gitlab.com/AlexWayfer/flame-r18n
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.5.1
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: R18n plugin for Flame-framework
80
+ test_files: []