lokalise_rails 0.0.1
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 +7 -0
- data/.github/CODE_OF_CONDUCT.md +46 -0
- data/.github/CONTRIBUTING.md +14 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +11 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +9 -0
- data/LICENSE +22 -0
- data/README.md +92 -0
- data/Rakefile +21 -0
- data/lib/generators/lokalise_rails/install_generator.rb +17 -0
- data/lib/generators/templates/lokalise_rails_config.rb +29 -0
- data/lib/lokalise_rails.rb +31 -0
- data/lib/lokalise_rails/railtie.rb +9 -0
- data/lib/lokalise_rails/task_definition/base.rb +19 -0
- data/lib/lokalise_rails/task_definition/importer.rb +51 -0
- data/lib/lokalise_rails/version.rb +5 -0
- data/lokalise_rails.gemspec +44 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/helpers/application_helper.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +5 -0
- data/spec/dummy/config/application.rb +34 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/environment.rb +7 -0
- data/spec/dummy/config/environments/development.rb +56 -0
- data/spec/dummy/config/environments/production.rb +100 -0
- data/spec/dummy/config/environments/test.rb +40 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +9 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +29 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/spec/dummy/config/initializers/inflections.rb +17 -0
- data/spec/dummy/config/initializers/lokalise_rails.rb +29 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
- data/spec/dummy/config/puma.rb +40 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/db/seeds.rb +8 -0
- data/spec/lib/generators/lokalise_rails/install_generator_spec.rb +19 -0
- data/spec/lib/lokalise_rails/importer_spec.rb +30 -0
- data/spec/lib/lokalise_rails_spec.rb +36 -0
- data/spec/lib/tasks/import_task_spec.rb +82 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/support/file_utils.rb +27 -0
- data/spec/support/rake_utils.rb +11 -0
- data/spec/support/vcr.rb +11 -0
- metadata +317 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'boot'
|
4
|
+
|
5
|
+
require 'rails'
|
6
|
+
# Pick the frameworks you want:
|
7
|
+
require 'active_model/railtie'
|
8
|
+
# require "active_job/railtie"
|
9
|
+
require 'active_record/railtie'
|
10
|
+
# require "active_storage/engine"
|
11
|
+
require 'action_controller/railtie'
|
12
|
+
# require "action_mailer/railtie"
|
13
|
+
# require "action_mailbox/engine"
|
14
|
+
# require "action_text/engine"
|
15
|
+
require 'action_view/railtie'
|
16
|
+
# require "action_cable/engine"
|
17
|
+
require 'sprockets/railtie'
|
18
|
+
# require "rails/test_unit/railtie"
|
19
|
+
|
20
|
+
# Require the gems listed in Gemfile, including any gems
|
21
|
+
# you've limited to :test, :development, or :production.
|
22
|
+
Bundler.require(*Rails.groups)
|
23
|
+
|
24
|
+
module Dummy
|
25
|
+
class Application < Rails::Application
|
26
|
+
# Settings in config/environments/* take precedence over those specified here.
|
27
|
+
# Application configuration can go into files in config/initializers
|
28
|
+
# -- all .rb files in that directory are automatically loaded after loading
|
29
|
+
# the framework and any gems in your application.
|
30
|
+
|
31
|
+
# Don't generate system test files.
|
32
|
+
config.generators.system_tests = nil
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Rails.application.configure do
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
+
|
6
|
+
# In the development environment your application's code is reloaded on
|
7
|
+
# every request. This slows down response time but is perfect for development
|
8
|
+
# since you don't have to restart the web server when you make code changes.
|
9
|
+
config.cache_classes = false
|
10
|
+
|
11
|
+
# Do not eager load code on boot.
|
12
|
+
config.eager_load = false
|
13
|
+
|
14
|
+
# Show full error reports.
|
15
|
+
config.consider_all_requests_local = true
|
16
|
+
|
17
|
+
# Enable/disable caching. By default caching is disabled.
|
18
|
+
# Run rails dev:cache to toggle caching.
|
19
|
+
if Rails.root.join('tmp', 'caching-dev.txt').exist?
|
20
|
+
config.action_controller.perform_caching = true
|
21
|
+
config.action_controller.enable_fragment_cache_logging = true
|
22
|
+
|
23
|
+
config.cache_store = :memory_store
|
24
|
+
config.public_file_server.headers = {
|
25
|
+
'Cache-Control' => "public, max-age=#{2.days.to_i}"
|
26
|
+
}
|
27
|
+
else
|
28
|
+
config.action_controller.perform_caching = false
|
29
|
+
|
30
|
+
config.cache_store = :null_store
|
31
|
+
end
|
32
|
+
|
33
|
+
# Print deprecation notices to the Rails logger.
|
34
|
+
config.active_support.deprecation = :log
|
35
|
+
|
36
|
+
# Raise an error on page load if there are pending migrations.
|
37
|
+
config.active_record.migration_error = :page_load
|
38
|
+
|
39
|
+
# Highlight code that triggered database queries in logs.
|
40
|
+
config.active_record.verbose_query_logs = true
|
41
|
+
|
42
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
43
|
+
# This option may cause significant delays in view rendering with a large
|
44
|
+
# number of complex assets.
|
45
|
+
config.assets.debug = true
|
46
|
+
|
47
|
+
# Suppress logger output for asset requests.
|
48
|
+
config.assets.quiet = true
|
49
|
+
|
50
|
+
# Raises error for missing translations.
|
51
|
+
# config.action_view.raise_on_missing_translations = true
|
52
|
+
|
53
|
+
# Use an evented file watcher to asynchronously detect changes in source code,
|
54
|
+
# routes, locales, etc. This feature depends on the listen gem.
|
55
|
+
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
56
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Rails.application.configure do
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
+
|
6
|
+
# Code is not reloaded between requests.
|
7
|
+
config.cache_classes = true
|
8
|
+
|
9
|
+
# Eager load code on boot. This eager loads most of Rails and
|
10
|
+
# your application in memory, allowing both threaded web servers
|
11
|
+
# and those relying on copy on write to perform better.
|
12
|
+
# Rake tasks automatically ignore this option for performance.
|
13
|
+
config.eager_load = true
|
14
|
+
|
15
|
+
# Full error reports are disabled and caching is turned on.
|
16
|
+
config.consider_all_requests_local = false
|
17
|
+
config.action_controller.perform_caching = true
|
18
|
+
|
19
|
+
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
20
|
+
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
21
|
+
# config.require_master_key = true
|
22
|
+
|
23
|
+
# Disable serving static files from the `/public` folder by default since
|
24
|
+
# Apache or NGINX already handles this.
|
25
|
+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
26
|
+
|
27
|
+
# Compress CSS using a preprocessor.
|
28
|
+
# config.assets.css_compressor = :sass
|
29
|
+
|
30
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
31
|
+
config.assets.compile = false
|
32
|
+
|
33
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
34
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
35
|
+
|
36
|
+
# Specifies the header that your server uses for sending files.
|
37
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
38
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
39
|
+
|
40
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
41
|
+
# config.force_ssl = true
|
42
|
+
|
43
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
44
|
+
# when problems arise.
|
45
|
+
config.log_level = :debug
|
46
|
+
|
47
|
+
# Prepend all log lines with the following tags.
|
48
|
+
config.log_tags = [:request_id]
|
49
|
+
|
50
|
+
# Use a different cache store in production.
|
51
|
+
# config.cache_store = :mem_cache_store
|
52
|
+
|
53
|
+
# Use a real queuing backend for Active Job (and separate queues per environment).
|
54
|
+
# config.active_job.queue_adapter = :resque
|
55
|
+
# config.active_job.queue_name_prefix = "dummy_production"
|
56
|
+
|
57
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
58
|
+
# the I18n.default_locale when a translation cannot be found).
|
59
|
+
config.i18n.fallbacks = true
|
60
|
+
|
61
|
+
# Send deprecation notices to registered listeners.
|
62
|
+
config.active_support.deprecation = :notify
|
63
|
+
|
64
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
65
|
+
config.log_formatter = ::Logger::Formatter.new
|
66
|
+
|
67
|
+
# Use a different logger for distributed setups.
|
68
|
+
# require 'syslog/logger'
|
69
|
+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
70
|
+
|
71
|
+
if ENV['RAILS_LOG_TO_STDOUT'].present?
|
72
|
+
logger = ActiveSupport::Logger.new($stdout)
|
73
|
+
logger.formatter = config.log_formatter
|
74
|
+
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Do not dump schema after migrations.
|
78
|
+
config.active_record.dump_schema_after_migration = false
|
79
|
+
|
80
|
+
# Inserts middleware to perform automatic connection switching.
|
81
|
+
# The `database_selector` hash is used to pass options to the DatabaseSelector
|
82
|
+
# middleware. The `delay` is used to determine how long to wait after a write
|
83
|
+
# to send a subsequent read to the primary.
|
84
|
+
#
|
85
|
+
# The `database_resolver` class is used by the middleware to determine which
|
86
|
+
# database is appropriate to use based on the time delay.
|
87
|
+
#
|
88
|
+
# The `database_resolver_context` class is used by the middleware to set
|
89
|
+
# timestamps for the last write to the primary. The resolver uses the context
|
90
|
+
# class timestamps to determine how long to wait before reading from the
|
91
|
+
# replica.
|
92
|
+
#
|
93
|
+
# By default Rails will store a last write timestamp in the session. The
|
94
|
+
# DatabaseSelector middleware is designed as such you can define your own
|
95
|
+
# strategy for connection switching and pass that into the middleware through
|
96
|
+
# these configuration options.
|
97
|
+
# config.active_record.database_selector = { delay: 2.seconds }
|
98
|
+
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
|
99
|
+
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
|
100
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The test environment is used exclusively to run your application's
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
7
|
+
|
8
|
+
Rails.application.configure do
|
9
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
10
|
+
|
11
|
+
config.cache_classes = true
|
12
|
+
|
13
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
14
|
+
# just for the purpose of running a single test. If you are using a tool that
|
15
|
+
# preloads Rails for running tests, you may have to set it to true.
|
16
|
+
config.eager_load = false
|
17
|
+
|
18
|
+
# Configure public file server for tests with Cache-Control for performance.
|
19
|
+
config.public_file_server.enabled = true
|
20
|
+
config.public_file_server.headers = {
|
21
|
+
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
|
22
|
+
}
|
23
|
+
|
24
|
+
# Show full error reports and disable caching.
|
25
|
+
config.consider_all_requests_local = true
|
26
|
+
config.action_controller.perform_caching = false
|
27
|
+
config.cache_store = :null_store
|
28
|
+
|
29
|
+
# Raise exceptions instead of rendering exception templates.
|
30
|
+
config.action_dispatch.show_exceptions = false
|
31
|
+
|
32
|
+
# Disable request forgery protection in test environment.
|
33
|
+
config.action_controller.allow_forgery_protection = false
|
34
|
+
|
35
|
+
# Print deprecation notices to the stderr.
|
36
|
+
config.active_support.deprecation = :stderr
|
37
|
+
|
38
|
+
# Raises error for missing translations.
|
39
|
+
# config.action_view.raise_on_missing_translations = true
|
40
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Be sure to restart your server when you modify this file.
|
4
|
+
|
5
|
+
# Version of your assets, change this if you want to expire all your assets.
|
6
|
+
Rails.application.config.assets.version = '1.0'
|
7
|
+
|
8
|
+
# Add additional assets to the asset load path.
|
9
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
10
|
+
|
11
|
+
# Precompile additional assets.
|
12
|
+
# application.js, application.css, and all non-JS/CSS in the app/assets
|
13
|
+
# folder are already added.
|
14
|
+
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Be sure to restart your server when you modify this file.
|
3
|
+
|
4
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
5
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
6
|
+
|
7
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
8
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Be sure to restart your server when you modify this file.
|
3
|
+
|
4
|
+
# Define an application-wide content security policy
|
5
|
+
# For further information see the following documentation
|
6
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
7
|
+
|
8
|
+
# Rails.application.config.content_security_policy do |policy|
|
9
|
+
# policy.default_src :self, :https
|
10
|
+
# policy.font_src :self, :https, :data
|
11
|
+
# policy.img_src :self, :https, :data
|
12
|
+
# policy.object_src :none
|
13
|
+
# policy.script_src :self, :https
|
14
|
+
# policy.style_src :self, :https
|
15
|
+
|
16
|
+
# # Specify URI for violation reports
|
17
|
+
# # policy.report_uri "/csp-violation-report-endpoint"
|
18
|
+
# end
|
19
|
+
|
20
|
+
# If you are using UJS then enable automatic nonce generation
|
21
|
+
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
|
22
|
+
|
23
|
+
# Set the nonce only to specific directives
|
24
|
+
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
|
25
|
+
|
26
|
+
# Report CSP violations to a specified URI
|
27
|
+
# For further information see the following documentation:
|
28
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
|
29
|
+
# Rails.application.config.content_security_policy_report_only = true
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Be sure to restart your server when you modify this file.
|
4
|
+
|
5
|
+
# Specify a serializer for the signed and encrypted cookie jars.
|
6
|
+
# Valid options are :json, :marshal, and :hybrid.
|
7
|
+
Rails.application.config.action_dispatch.cookies_serializer = :json
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Be sure to restart your server when you modify this file.
|
3
|
+
|
4
|
+
# Add new inflection rules using the following format. Inflections
|
5
|
+
# are locale specific, and you may define rules for as many different
|
6
|
+
# locales as you wish. All of these examples are active by default:
|
7
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
8
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
9
|
+
# inflect.singular /^(ox)en/i, '\1'
|
10
|
+
# inflect.irregular 'person', 'people'
|
11
|
+
# inflect.uncountable %w( fish sheep )
|
12
|
+
# end
|
13
|
+
|
14
|
+
# These inflection rules are supported but not enabled by default:
|
15
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
16
|
+
# inflect.acronym 'RESTful'
|
17
|
+
# end
|
@@ -0,0 +1,29 @@
|
|
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
|
+
# @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
|
+
# @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
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Be sure to restart your server when you modify this file.
|
4
|
+
|
5
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
6
|
+
# is enabled by default.
|
7
|
+
|
8
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
9
|
+
ActiveSupport.on_load(:action_controller) do
|
10
|
+
wrap_parameters format: [:json]
|
11
|
+
end
|
12
|
+
|
13
|
+
# To enable root element in JSON for ActiveRecord objects.
|
14
|
+
# ActiveSupport.on_load(:active_record) do
|
15
|
+
# self.include_root_in_json = true
|
16
|
+
# end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
4
|
+
# The `threads` method setting takes two numbers: a minimum and maximum.
|
5
|
+
# Any libraries that use thread pools should be configured to match
|
6
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
7
|
+
# and maximum; this matches the default thread size of Active Record.
|
8
|
+
#
|
9
|
+
max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
|
10
|
+
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
|
11
|
+
threads min_threads_count, max_threads_count
|
12
|
+
|
13
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
14
|
+
#
|
15
|
+
port ENV.fetch('PORT', 3000)
|
16
|
+
|
17
|
+
# Specifies the `environment` that Puma will run in.
|
18
|
+
#
|
19
|
+
environment ENV.fetch('RAILS_ENV', 'development')
|
20
|
+
|
21
|
+
# Specifies the `pidfile` that Puma will use.
|
22
|
+
pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid')
|
23
|
+
|
24
|
+
# Specifies the number of `workers` to boot in clustered mode.
|
25
|
+
# Workers are forked web server processes. If using threads and workers together
|
26
|
+
# the concurrency of the application would be max `threads` * `workers`.
|
27
|
+
# Workers do not work on JRuby or Windows (both of which do not support
|
28
|
+
# processes).
|
29
|
+
#
|
30
|
+
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
31
|
+
|
32
|
+
# Use the `preload_app!` method when specifying a `workers` number.
|
33
|
+
# This directive tells Puma to first boot the application and load code
|
34
|
+
# before forking the application. This takes advantage of Copy On Write
|
35
|
+
# process behavior so workers use less memory.
|
36
|
+
#
|
37
|
+
# preload_app!
|
38
|
+
|
39
|
+
# Allow puma to be restarted by `rails restart` command.
|
40
|
+
plugin :tmp_restart
|