i18n-toml 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5564adc08ff224c2ab72ccc7a4c5233165a2322455cd7db00e133c343d9e664e
4
+ data.tar.gz: 27133a7dd888f80af8cb18a6db7b13f19158af6405213ed8eb06e03dbbcce1f3
5
+ SHA512:
6
+ metadata.gz: 7f42a6a97ed1c9ef09ff6e42cf27e33aafc133e2b0bc76a8343e3d40938e684cdda0608b247971fe660896f6ae4eec47d1e606738a07fdaeedb66da5cd2ef8d0
7
+ data.tar.gz: e7c79fabfdacbb3b3a580a88bf12887ecb55e01464754440d1c1f8ef12295f67a694ff8c8a8577cdb1a07a50e30387199440568e1d13297993fe5c714f931c49
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-01-23
4
+
5
+ - Initial release
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # i18n-toml
2
+
3
+ A quick bridge to use [TOML](https://toml.io/en/) files as I18n translations in Ruby on Rails applications.
4
+
5
+ Using TOML for translations has some nice benefits over the traditional YAML format:
6
+
7
+ - TOML does not require indentation, which can be error-prone and tedious in YAML.
8
+ - TOML can define namespaces which resemble the learned structure of Rails I18n.
9
+ - TOML does not restrict the use of comments, which can be useful for documenting translations.
10
+ - TOML supports multiple top-level keys, which can be useful for organizing translations by topic rather than by locale.
11
+
12
+ # Example
13
+
14
+ ```toml
15
+ # config/locales/translations.toml
16
+ [en.welcome.header]
17
+ title = "Welcome to %{app_name}!"
18
+ subtitle = "The best place to be."
19
+
20
+ [de.welcome.header]
21
+ title = "Willkommen bei %{app_name}!"
22
+ subtitle = "Der beste Ort zum sein." # Thank you copilot for this shiny example :trollface:
23
+ ```
24
+
25
+ ## Installation
26
+
27
+ Install the gem and add to the application's Gemfile by executing:
28
+
29
+ ```bash
30
+ bundle add i18n-toml
31
+ ```
32
+
33
+ If bundler is not being used to manage dependencies, install the gem by executing:
34
+
35
+ ```bash
36
+ gem install i18n-toml
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ No need for any setup, just start placing .toml files in the `config/locales` directory of your Rails application.
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ 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`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/xijo/i18n-toml.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module I18n
4
+ module Toml
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
data/lib/i18n/toml.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'toml-rb'
4
+ require_relative 'toml/version'
5
+
6
+ module I18n
7
+ module Backend
8
+ class Simple
9
+ def load_toml(filename)
10
+ TomlRB.load_file filename
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ class I18n::Toml::Railtie < ::Rails::Railtie
17
+ initializer('i18n/toml') do |app|
18
+ Dir.glob(Rails.root.join('config', 'locales', '**/*.toml')).each { |f| I18n.load_path << f }
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i18n-toml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Johannes Opper
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-01-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: toml-rb
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description:
28
+ email:
29
+ - xijo@pm.me
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rspec"
35
+ - CHANGELOG.md
36
+ - README.md
37
+ - Rakefile
38
+ - lib/i18n/toml.rb
39
+ - lib/i18n/toml/version.rb
40
+ homepage: https://github.com/xijo/i18n-toml
41
+ licenses: []
42
+ metadata:
43
+ homepage_uri: https://github.com/xijo/i18n-toml
44
+ source_code_uri: https://github.com/xijo/i18n-toml
45
+ changelog_uri: https://github.com/xijo/i18n-toml/CHANGELOG.md
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.1.0
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubygems_version: 3.5.16
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Use TOML files as I18n backends in Rails
65
+ test_files: []