lokalise_rails 0.0.2.3 → 1.1.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/CHANGELOG.md +20 -5
- data/README.md +79 -27
- data/lib/generators/lokalise_rails/install_generator.rb +2 -2
- data/lib/generators/templates/lokalise_rails_config.rb +36 -25
- data/lib/lokalise_rails.rb +54 -19
- data/lib/lokalise_rails/railtie.rb +2 -5
- data/lib/lokalise_rails/task_definition/base.rb +50 -6
- data/lib/lokalise_rails/task_definition/exporter.rb +80 -0
- data/lib/lokalise_rails/task_definition/importer.rb +57 -15
- data/lib/lokalise_rails/version.rb +2 -2
- data/lib/tasks/lokalise_rails_tasks.rake +14 -0
- data/lokalise_rails.gemspec +1 -2
- data/spec/dummy/config/application.rb +4 -2
- data/spec/dummy/config/lokalise_rails.rb +7 -0
- data/spec/lib/generators/lokalise_rails/install_generator_spec.rb +1 -1
- data/spec/lib/lokalise_rails/task_definition/base_spec.rb +85 -0
- data/spec/lib/lokalise_rails/task_definition/exporter_spec.rb +166 -0
- data/spec/lib/lokalise_rails/task_definition/importer_spec.rb +49 -0
- data/spec/lib/lokalise_rails_spec.rb +44 -7
- data/spec/lib/tasks/export_task_spec.rb +7 -0
- data/spec/lib/tasks/import_task_spec.rb +46 -20
- data/spec/spec_helper.rb +8 -4
- data/spec/support/file_manager.rb +81 -0
- data/spec/support/rake_utils.rb +4 -0
- data/spec/support/spec_addons.rb +8 -0
- metadata +18 -36
- data/spec/dummy/config/initializers/lokalise_rails.rb +0 -29
- data/spec/lib/lokalise_rails/importer_spec.rb +0 -30
- data/spec/support/file_utils.rb +0 -27
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'lokalise_rails'
|
4
|
-
|
5
|
-
# These are mandatory options that you must set before running rake tasks:
|
6
|
-
LokaliseRails.api_token = ENV['LOKALISE_API_TOKEN']
|
7
|
-
LokaliseRails.project_id = ENV['LOKALISE_PROJECT_ID']
|
8
|
-
|
9
|
-
# Import options have the following defaults:
|
10
|
-
# LokaliseRails.import_opts = {
|
11
|
-
# format: 'yaml',
|
12
|
-
# placeholder_format: :icu,
|
13
|
-
# yaml_include_root: true,
|
14
|
-
# original_filenames: true,
|
15
|
-
# directory_prefix: '',
|
16
|
-
# indentation: '2sp'
|
17
|
-
# }
|
18
|
-
|
19
|
-
# Safe mode is disabled by default:
|
20
|
-
# LokaliseRails.import_safe_mode = false
|
21
|
-
|
22
|
-
# Provide a custom path to the directory with your translation files:
|
23
|
-
# class LokaliseRails
|
24
|
-
# class << self
|
25
|
-
# def locales_path
|
26
|
-
# "#{Rails.root}/config/locales"
|
27
|
-
# end
|
28
|
-
# end
|
29
|
-
# end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe LokaliseRails::TaskDefinition::Importer do
|
4
|
-
describe '.download_files' do
|
5
|
-
it 'returns a proper download URL' do
|
6
|
-
response = VCR.use_cassette('download_files') do
|
7
|
-
described_class.download_files
|
8
|
-
end
|
9
|
-
|
10
|
-
expect(response['project_id']).to eq('189934715f57a162257d74.88352370')
|
11
|
-
expect(response['bundle_url']).to include('s3-eu-west-1.amazonaws.com')
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '.import!' do
|
16
|
-
it 'halts when the API key is not set' do
|
17
|
-
expect(LokaliseRails).to receive(:api_token).and_return(nil)
|
18
|
-
result = described_class.import!
|
19
|
-
expect(result).to include('API token is not set')
|
20
|
-
expect(count_translations).to eq(0)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'halts when the project_id is not set' do
|
24
|
-
expect(LokaliseRails).to receive(:project_id).and_return(nil)
|
25
|
-
result = described_class.import!
|
26
|
-
expect(result).to include('Project ID is not set')
|
27
|
-
expect(count_translations).to eq(0)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/spec/support/file_utils.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FileUtils
|
4
|
-
def mkdir_locales
|
5
|
-
FileUtils.mkdir_p(LokaliseRails.locales_path) unless File.directory?(LokaliseRails.locales_path)
|
6
|
-
end
|
7
|
-
|
8
|
-
def rm_translation_files
|
9
|
-
FileUtils.rm_rf locales_dir
|
10
|
-
end
|
11
|
-
|
12
|
-
def locales_dir
|
13
|
-
Dir["#{LokaliseRails.locales_path}/*"]
|
14
|
-
end
|
15
|
-
|
16
|
-
def count_translations
|
17
|
-
locales_dir.count { |file| File.file?(file) }
|
18
|
-
end
|
19
|
-
|
20
|
-
def remove_config
|
21
|
-
FileUtils.remove_file config_file if File.file?(config_file)
|
22
|
-
end
|
23
|
-
|
24
|
-
def config_file
|
25
|
-
"#{Rails.root}/config/initializers/lokalise_rails.rb"
|
26
|
-
end
|
27
|
-
end
|