Module: LokaliseRails
- Defined in:
- lib/lokalise_rails.rb,
lib/lokalise_rails/railtie.rb,
lib/lokalise_rails/version.rb,
lib/lokalise_rails/task_definition/base.rb,
lib/lokalise_rails/task_definition/exporter.rb,
lib/lokalise_rails/task_definition/importer.rb,
lib/generators/lokalise_rails/install_generator.rb
Defined Under Namespace
Modules: Generators, TaskDefinition Classes: Railtie
Constant Summary collapse
- VERSION =
'1.3.0'
Class Attribute Summary collapse
-
.api_token ⇒ Object
Returns the value of attribute api_token.
-
.branch ⇒ Object
Project branch to use.
-
.export_opts ⇒ Object
Options for export rake task.
-
.file_ext_regexp ⇒ Object
Regular expression used to select translation files with proper extensions.
-
.import_opts ⇒ Object
Options for import rake task.
-
.import_safe_mode ⇒ Object
Enables safe mode for import.
-
.lang_iso_inferer ⇒ Object
Infers lang ISO for the given translation file.
-
.locales_path ⇒ Object
Full path to directory with translation files.
-
.project_id ⇒ Object
Returns the value of attribute project_id.
-
.skip_file_export ⇒ Object
Additional file skip criteria to apply when performing export.
-
.timeouts ⇒ Object
Set request timeouts for the Lokalise API client.
-
.translations_converter ⇒ Object
Converts translations data to the proper format.
- .translations_loader ⇒ Object
Class Method Summary collapse
-
.config {|_self| ... } ⇒ Object
Main interface to provide configuration options for rake tasks.
Class Attribute Details
.api_token ⇒ Object
Returns the value of attribute api_token.
9 10 11 |
# File 'lib/lokalise_rails.rb', line 9 def api_token @api_token end |
.branch ⇒ Object
Project branch to use
25 26 27 |
# File 'lib/lokalise_rails.rb', line 25 def branch @branch || 'master' end |
.export_opts ⇒ Object
Options for export rake task
52 53 54 |
# File 'lib/lokalise_rails.rb', line 52 def export_opts @export_opts || {} end |
.file_ext_regexp ⇒ Object
Regular expression used to select translation files with proper extensions
35 36 37 |
# File 'lib/lokalise_rails.rb', line 35 def file_ext_regexp @file_ext_regexp || /\.ya?ml\z/i end |
.import_opts ⇒ Object
Options for import rake task
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/lokalise_rails.rb', line 40 def import_opts @import_opts || { format: 'yaml', placeholder_format: :icu, yaml_include_root: true, original_filenames: true, directory_prefix: '', indentation: '2sp' } end |
.import_safe_mode ⇒ Object
Enables safe mode for import. When enabled, will check whether the target folder is empty or not
57 58 59 |
# File 'lib/lokalise_rails.rb', line 57 def import_safe_mode @import_safe_mode.nil? ? false : @import_safe_mode end |
.lang_iso_inferer ⇒ Object
Infers lang ISO for the given translation file
76 77 78 |
# File 'lib/lokalise_rails.rb', line 76 def lang_iso_inferer @lang_iso_inferer || ->(data) { YAML.safe_load(data)&.keys&.first } end |
.locales_path ⇒ Object
Full path to directory with translation files
20 21 22 |
# File 'lib/lokalise_rails.rb', line 20 def locales_path @locales_path || "#{Rails.root}/config/locales" end |
.project_id ⇒ Object
Returns the value of attribute project_id.
9 10 11 |
# File 'lib/lokalise_rails.rb', line 9 def project_id @project_id end |
.skip_file_export ⇒ Object
Additional file skip criteria to apply when performing export
62 63 64 |
# File 'lib/lokalise_rails.rb', line 62 def skip_file_export @skip_file_export || ->(_) { false } end |
.timeouts ⇒ Object
Set request timeouts for the Lokalise API client
30 31 32 |
# File 'lib/lokalise_rails.rb', line 30 def timeouts @timeouts || {} end |
.translations_converter ⇒ Object
Converts translations data to the proper format
71 72 73 |
# File 'lib/lokalise_rails.rb', line 71 def translations_converter @translations_converter || ->(raw_data) { raw_data.to_yaml } end |
.translations_loader ⇒ Object
66 67 68 |
# File 'lib/lokalise_rails.rb', line 66 def translations_loader @translations_loader || ->(raw_data) { YAML.safe_load raw_data } end |
Class Method Details
.config {|_self| ... } ⇒ Object
Main interface to provide configuration options for rake tasks
15 16 17 |
# File 'lib/lokalise_rails.rb', line 15 def config yield self end |