i18n-timezones 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c3336350e66420d09755a05cf6f7d6805694a85895185413c1ecdc48089ee73
4
- data.tar.gz: 67117506ef062078433e135328f653602731546ce7641f938fd6577d4720d5eb
3
+ metadata.gz: 316a94519472c2c0de46cbd89b4ddeb170428d3792a25164b0d5c81ee0820d77
4
+ data.tar.gz: 387cb70b1a1cbc7c88a3fa1ebdee7c6ee44f17c6f0d6e337cc3ebca2b259af6b
5
5
  SHA512:
6
- metadata.gz: 328bed103d34669cd1ad626906801662e1a49a2eb9f8623a73def0067b22fbccd8d60c56cdd5dc50acc3addc9726d4f69f23f1533e7dfd522484273de3b82e57
7
- data.tar.gz: 044ecf1d80515ef1041d0e13e2a8bcc053b6e379b05610b39483435e8d5de75253537feceed5edd57a3a8a690c44a2917f5c7f7e4e99640b74c865a102feea87
6
+ metadata.gz: 43ac0910b91d5495b21e87c32817f9be22118736784ae800eeeafa600af13f838a36c8bff926fbc8ef7deab7768c0b70a580ca80bb077b005133322fe8bb08d1
7
+ data.tar.gz: e58489e408b865aa1ef77bc24ca1461a814b0473dd1137fdb69a2726cca1ef17289cedfcdd99543f026ac2fe08624f043f5098068946ecf63391b1b090c6206d
data/README.md CHANGED
@@ -23,6 +23,8 @@ Add to your Gemfile:
23
23
  gem 'i18n-timezones'
24
24
  ```
25
25
 
26
+ Translation data is provided by the [`i18n-timezones-data`](https://github.com/onomojo/i18n-timezones-data) gem, which is installed automatically as a dependency.
27
+
26
28
  ## Usage
27
29
 
28
30
  Timezones are automatically translated to the current locale:
@@ -46,42 +48,57 @@ You can also use translations directly:
46
48
  I18n.locale = :de
47
49
  ActiveSupport::TimeZone["Tokyo"].to_s
48
50
  # => "(GMT+09:00) Tokio"
51
+
52
+ I18n.locale = :ja
53
+ ActiveSupport::TimeZone["Tokyo"].to_s
54
+ # => "(GMT+09:00) 東京"
49
55
  ```
50
56
 
51
57
  ## Supported Locales
52
58
 
53
- Translations are provided for 36 locales:
59
+ Translations are provided for **36 locales** covering all 152 Rails timezones:
54
60
 
55
61
  ar, bn, ca, cs, da, de, el, en, es, eu, fi, fr, he, hi, hr, hu, id, it, ja, ko, ms, nl, no, pl, pt, pt-BR, ro, ru, sq, sv, th, tr, uk, vi, zh-CN, zh-TW
56
62
 
63
+ ## How It Works
64
+
65
+ This gem uses a [Railtie](https://api.rubyonrails.org/classes/Rails/Railtie.html) to automatically load translations after Rails initializes. Translations are loaded from the [`i18n-timezones-data`](https://github.com/onomojo/i18n-timezones-data) gem via `I18n.backend.store_translations`, scoped under `timezones:`.
66
+
67
+ If your app sets `config.i18n.available_locales`, only the matching locales will be loaded.
68
+
57
69
  ## Without Rails
58
70
 
59
- If you're using ActiveSupport without Rails, load the locale files manually:
71
+ If you're using ActiveSupport without Rails, load translations manually:
60
72
 
61
73
  ```ruby
62
74
  require "i18n"
75
+ require "yaml"
63
76
  require "active_support"
64
77
  require "i18n_timezones/timezone"
78
+ require "i18n_timezones_data"
65
79
 
66
- I18n.load_path += Dir[File.join(Gem.loaded_specs["i18n-timezones"].full_gem_path, "rails/locale/*.yml")]
80
+ Dir[File.join(I18nTimezonesData.data_dir, "*.yml")].each do |file|
81
+ locale = File.basename(file, ".yml").to_sym
82
+ translations = YAML.safe_load(File.read(file))
83
+ I18n.backend.store_translations(locale, timezones: translations)
84
+ end
67
85
  ```
68
86
 
69
87
  ## Contributing
70
88
 
71
- ### Adding a new locale
72
-
73
- 1. Copy `rails/locale/en.yml` to `rails/locale/<locale>.yml`
74
- 2. Translate all timezone names
75
- 3. Run tests: `bundle exec rake spec`
76
- 4. Submit a pull request
89
+ Translation data lives in the [`i18n-timezones-data`](https://github.com/onomojo/i18n-timezones-data) repo. To add or fix translations, submit a pull request there.
77
90
 
78
91
  ### Running tests
79
92
 
80
93
  ```bash
81
94
  bundle install
82
- bundle exec rake spec
95
+ bundle exec rspec
83
96
  ```
84
97
 
98
+ ## Also Available for JavaScript
99
+
100
+ - [`i18n-timezones-js`](https://www.npmjs.com/package/i18n-timezones-js) — The same translations for JavaScript/TypeScript projects
101
+
85
102
  ## Known Limitations
86
103
 
87
104
  - `TimeZone#to_s` is translated, but `TimeZone#name` intentionally returns the original English name. The English name is used as a lookup key for translations and must remain stable.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rails/railtie"
4
- require "yaml"
4
+ require "json"
5
5
  require "i18n_timezones_data"
6
6
 
7
7
  module I18nTimezones
@@ -10,11 +10,11 @@ module I18nTimezones
10
10
  data_dir = I18nTimezonesData.data_dir
11
11
  locales = Rails.application.config.i18n.available_locales
12
12
 
13
- Dir[File.join(data_dir, "*.yml")].each do |file|
14
- locale = File.basename(file, ".yml").to_sym
13
+ Dir[File.join(data_dir, "*.json")].each do |file|
14
+ locale = File.basename(file, ".json").to_sym
15
15
  next if locales.present? && !locales.include?(locale)
16
16
 
17
- translations = YAML.safe_load(File.read(file))
17
+ translations = JSON.parse(File.read(file))
18
18
  I18n.backend.store_translations(locale, timezones: translations)
19
19
  end
20
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module I18nTimezones
4
- VERSION = "2.2.0"
4
+ VERSION = "2.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-timezones
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian McQuay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-07 00:00:00.000000000 Z
11
+ date: 2026-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -76,14 +76,14 @@ dependencies:
76
76
  requirements:
77
77
  - - "~>"
78
78
  - !ruby/object:Gem::Version
79
- version: '1.0'
79
+ version: '1.1'
80
80
  type: :runtime
81
81
  prerelease: false
82
82
  version_requirements: !ruby/object:Gem::Requirement
83
83
  requirements:
84
84
  - - "~>"
85
85
  - !ruby/object:Gem::Version
86
- version: '1.0'
86
+ version: '1.1'
87
87
  description: Provides timezone translations for ActiveSupport::TimeZone. Translates
88
88
  timezone names via I18n for use with time_zone_select and similar helpers.
89
89
  email:
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.4.22
126
+ rubygems_version: 3.2.3
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: I18n Timezone Translations