imap-backup 16.4.2 → 16.5.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 +4 -4
- data/bin/imap-backup +3 -0
- data/docs/TODO.md +16 -0
- data/docs/i18n.md +153 -0
- data/imap-backup.gemspec +3 -0
- data/lib/imap/backup/cli/helpers.rb +7 -9
- data/lib/imap/backup/cli/local/check.rb +1 -1
- data/lib/imap/backup/cli/local.rb +2 -2
- data/lib/imap/backup/cli/remote.rb +5 -2
- data/lib/imap/backup/cli/restore.rb +1 -1
- data/lib/imap/backup/cli/stats.rb +5 -5
- data/lib/imap/backup/cli/transfer.rb +14 -15
- data/lib/imap/backup/cli/utils.rb +6 -3
- data/lib/imap/backup/cli.rb +1 -1
- data/lib/imap/backup/configuration.rb +4 -7
- data/lib/imap/backup/locales/en.yml +166 -0
- data/lib/imap/backup/locales/it.yml +167 -0
- data/lib/imap/backup/setup/account/header.rb +18 -18
- data/lib/imap/backup/setup/account.rb +28 -23
- data/lib/imap/backup/setup/asker.rb +9 -5
- data/lib/imap/backup/setup/backup_path.rb +4 -4
- data/lib/imap/backup/setup/folder_chooser.rb +9 -11
- data/lib/imap/backup/setup/global_options/download_strategy_chooser.rb +13 -41
- data/lib/imap/backup/setup/global_options.rb +11 -6
- data/lib/imap/backup/setup.rb +8 -7
- data/lib/imap/backup/translator.rb +48 -0
- data/lib/imap/backup/version.rb +2 -2
- metadata +34 -1
data/lib/imap/backup/setup.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "highline"
|
|
2
|
+
require "i18n"
|
|
2
3
|
|
|
3
4
|
require "imap/backup/account"
|
|
4
5
|
require "imap/backup/email/provider"
|
|
@@ -41,21 +42,21 @@ module Imap::Backup
|
|
|
41
42
|
def show_menu
|
|
42
43
|
self.class.highline.choose do |menu|
|
|
43
44
|
menu.header = <<~MENU.chomp
|
|
44
|
-
#{helpers.title_prefix}
|
|
45
|
+
#{helpers.title_prefix} #{I18n.t('setup.main_menu.title')}
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
#{I18n.translate('setup.main_menu.choose_action')}
|
|
47
48
|
MENU
|
|
48
49
|
account_items menu
|
|
49
50
|
add_account_item menu
|
|
50
51
|
modify_global_options menu
|
|
51
52
|
if config.modified?
|
|
52
|
-
menu.choice("
|
|
53
|
+
menu.choice(I18n.t("setup.main_menu.save_and_exit")) do
|
|
53
54
|
config.save
|
|
54
55
|
throw :done
|
|
55
56
|
end
|
|
56
|
-
menu.choice("
|
|
57
|
+
menu.choice(I18n.t("setup.main_menu.exit_without_saving")) { throw :done }
|
|
57
58
|
else
|
|
58
|
-
menu.choice("
|
|
59
|
+
menu.choice(I18n.t("setup.main_menu.quit")) { throw :done }
|
|
59
60
|
menu.hidden("quit") { throw :done }
|
|
60
61
|
end
|
|
61
62
|
end
|
|
@@ -74,7 +75,7 @@ module Imap::Backup
|
|
|
74
75
|
end
|
|
75
76
|
|
|
76
77
|
def add_account_item(menu)
|
|
77
|
-
menu.choice("
|
|
78
|
+
menu.choice(I18n.t("setup.main_menu.add_account")) do
|
|
78
79
|
username = Asker.email
|
|
79
80
|
edit_account username
|
|
80
81
|
end
|
|
@@ -82,7 +83,7 @@ module Imap::Backup
|
|
|
82
83
|
|
|
83
84
|
def modify_global_options(menu)
|
|
84
85
|
changed = config.download_strategy_modified? ? " *" : ""
|
|
85
|
-
menu.choice("
|
|
86
|
+
menu.choice("#{I18n.t('setup.main_menu.modify_global_options')}#{changed}") do
|
|
86
87
|
GlobalOptions.new(config: config).run
|
|
87
88
|
end
|
|
88
89
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require "i18n"
|
|
2
|
+
require "locale"
|
|
3
|
+
|
|
4
|
+
module Imap; end
|
|
5
|
+
|
|
6
|
+
module Imap::Backup
|
|
7
|
+
# Handles internationalization (i18n) setup and locale detection.
|
|
8
|
+
class Translator
|
|
9
|
+
FALLBACK_LOCALE = :en
|
|
10
|
+
|
|
11
|
+
# Initializes i18n with the detected locale.
|
|
12
|
+
# Sets up load paths and configures fallbacks.
|
|
13
|
+
def setup
|
|
14
|
+
I18n.load_path = locale_files
|
|
15
|
+
I18n.backend.load_translations
|
|
16
|
+
I18n.default_locale = FALLBACK_LOCALE
|
|
17
|
+
I18n.locale = detect_locale
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def locale_files
|
|
23
|
+
locales_path = File.expand_path("locales", __dir__)
|
|
24
|
+
Dir.glob(File.join(locales_path, "*.yml"))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def detect_locale
|
|
28
|
+
# LANG=C should use English
|
|
29
|
+
return FALLBACK_LOCALE if ENV["LANG"] == "C"
|
|
30
|
+
|
|
31
|
+
tags = Locale.candidates
|
|
32
|
+
|
|
33
|
+
# Find the first locale we have translations for
|
|
34
|
+
tags.each do |tag|
|
|
35
|
+
locale_symbol = tag.language.to_sym
|
|
36
|
+
return locale_symbol if available_locales.include?(locale_symbol)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
FALLBACK_LOCALE
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def available_locales
|
|
43
|
+
locale_files.map do |file|
|
|
44
|
+
File.basename(file, ".yml").to_sym
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/imap/backup/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: imap-backup
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 16.
|
|
4
|
+
version: 16.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joe Yates
|
|
@@ -23,6 +23,34 @@ dependencies:
|
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: i18n
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: locale
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
26
54
|
- !ruby/object:Gem::Dependency
|
|
27
55
|
name: logger
|
|
28
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -174,9 +202,11 @@ files:
|
|
|
174
202
|
- LICENSE
|
|
175
203
|
- README.md
|
|
176
204
|
- bin/imap-backup
|
|
205
|
+
- docs/TODO.md
|
|
177
206
|
- docs/delimiters-and-prefixes.md
|
|
178
207
|
- docs/development.md
|
|
179
208
|
- docs/documentation.md
|
|
209
|
+
- docs/i18n.md
|
|
180
210
|
- docs/performance.md
|
|
181
211
|
- docs/testing.md
|
|
182
212
|
- imap-backup.gemspec
|
|
@@ -223,6 +253,8 @@ files:
|
|
|
223
253
|
- lib/imap/backup/file_mode.rb
|
|
224
254
|
- lib/imap/backup/flag_refresher.rb
|
|
225
255
|
- lib/imap/backup/local_only_message_deleter.rb
|
|
256
|
+
- lib/imap/backup/locales/en.yml
|
|
257
|
+
- lib/imap/backup/locales/it.yml
|
|
226
258
|
- lib/imap/backup/lockfile.rb
|
|
227
259
|
- lib/imap/backup/logger.rb
|
|
228
260
|
- lib/imap/backup/migrator.rb
|
|
@@ -257,6 +289,7 @@ files:
|
|
|
257
289
|
- lib/imap/backup/setup/helpers.rb
|
|
258
290
|
- lib/imap/backup/text/sanitizer.rb
|
|
259
291
|
- lib/imap/backup/thunderbird/mailbox_exporter.rb
|
|
292
|
+
- lib/imap/backup/translator.rb
|
|
260
293
|
- lib/imap/backup/uploader.rb
|
|
261
294
|
- lib/imap/backup/version.rb
|
|
262
295
|
homepage: https://github.com/joeyates/imap-backup
|