instant18n 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 465dcacde7df00da6da5fc38d2f586ed6b2b5b64fd1ab766806019a635e097c4
4
- data.tar.gz: 6c3d7cd6b3a276dddb874a7cddfcb299d4239b576ab194b17bb5be5929dff017
3
+ metadata.gz: 2375fc582bc3fbd99f0370e6fcc883e98f5f8b36f8c4fe4b8ccead708d867e0a
4
+ data.tar.gz: 5c81c81dbe323386e89a8ea16058b50dd6523277c4bd4f5dc3f7155f17eacd1f
5
5
  SHA512:
6
- metadata.gz: cfe944f349d421c653ac423ef61bfb355a4f3c6c3f805a9a620d34f5b6bea44c20cfb04d212754d0a46f2db74f1f50df26bce32e0417778e317c4cfdeeffcaea
7
- data.tar.gz: 94499545a01fd9ba0946a1675530532a093416147eeab06be1027b765db6ea9c403f33d76f1a8769651715549f8df9382ba3c9c22602b6c0e681f22795dd3806
6
+ metadata.gz: 57083e56ea937cd29504000bbf72875ba203f117437fe6b532a6d3fbc2aaaf85e984c640238ee60ef24ce85b2231375b589948ab7145ea422884c5fe4683c07f
7
+ data.tar.gz: 23620ccdd52174fab272fce5d9c662bc662c123dc019b8cb7b50a82ae37fe2837be2e3881653a1aff7b4840ea7a1138bfcf4305e4dab288516c5680e2aac7a5c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- instant18n (0.1.0)
4
+ instant18n (0.2.0)
5
5
  actionview
6
6
  activesupport
7
7
  railties
data/README.md CHANGED
@@ -50,6 +50,10 @@ Additional options that are passed to the GPT-3 API:
50
50
 
51
51
  Full description of these options is available [here](https://platform.openai.com/docs/api-reference/chat/create).
52
52
 
53
+ ### View Helper
54
+
55
+ This gem mixes in an `it` helper method into `ActionView::Base`. For convenience, the helper method assumes the presence of a `current_user` object with a `preferred_language` attribute. If `current_user` is nil, it will use the value of `I18n.default_language` instead.
56
+
53
57
  ### Default Language
54
58
 
55
59
  The default language is set to `English`. For performance and practical reasons, if you pass in the default language, GPT is not invoked. Change the default language in an initializer or at runtime by changing the value of the `default_language` property on the `I18n` module.
@@ -49,7 +49,7 @@ module I18n
49
49
  chat(prompt % { key: key, lang: lang }, directive: DIRECTIVE, **opts)
50
50
  end
51
51
  end.then do |text|
52
- text = text.gsub(/^"+|"+$/, '') # remove wrapper double quotes
52
+ text = text.to_s.gsub(/^"+|"+$/, '') # remove wrapper double quotes
53
53
  if opts[:class].present?
54
54
  tag.div(text, class: "instant18n #{lang.parameterize} #{opts[:class]}")
55
55
  else
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "action_view"
4
+
5
+ module Instant18n
6
+ module Helper
7
+ def it(key, **opts)
8
+ lang = current_user&.preferred_language
9
+ lang ||= I18n.default_language
10
+ I18n.it(key, lang, **opts)
11
+ end
12
+ end
13
+ end
14
+
15
+ ActionView::Base.include Instant18n::Helper
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Instant18n
4
- VERSION = "0.1.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instant18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Obie Fernandez
@@ -74,7 +74,6 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - ".env"
78
77
  - ".rspec"
79
78
  - ".rubocop.yml"
80
79
  - CHANGELOG.md
@@ -87,6 +86,7 @@ files:
87
86
  - instant18n.gemspec
88
87
  - lib/i18n_extensions.rb
89
88
  - lib/instant18n.rb
89
+ - lib/instant18n/helper.rb
90
90
  - lib/instant18n/version.rb
91
91
  - log/development.log
92
92
  - sig/instant18n.rbs
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
- rubygems_version: 3.4.10
116
+ rubygems_version: 3.4.12
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Instant18n is a gem that makes it drop-dead simple to internationalize your
data/.env DELETED
@@ -1 +0,0 @@
1
- OPENAI_ACCESS_TOKEN=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