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.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_tokenObject

Returns the value of attribute api_token.



9
10
11
# File 'lib/lokalise_rails.rb', line 9

def api_token
  @api_token
end

.branchObject

Project branch to use



24
25
26
# File 'lib/lokalise_rails.rb', line 24

def branch
  @branch || 'master'
end

.export_optsObject

Options for export rake task



51
52
53
# File 'lib/lokalise_rails.rb', line 51

def export_opts
  @export_opts || {}
end

.file_ext_regexpObject

Regular expression used to select translation files with proper extensions



34
35
36
# File 'lib/lokalise_rails.rb', line 34

def file_ext_regexp
  @file_ext_regexp || /\.ya?ml\z/i
end

.import_optsObject

Options for import rake task



39
40
41
42
43
44
45
46
47
48
# File 'lib/lokalise_rails.rb', line 39

def import_opts
  @import_opts || {
    format: 'yaml',
    placeholder_format: :icu,
    yaml_include_root: true,
    original_filenames: true,
    directory_prefix: '',
    indentation: '2sp'
  }
end

.import_safe_modeObject

Enables safe mode for import. When enabled, will check whether the target folder is empty or not



56
57
58
# File 'lib/lokalise_rails.rb', line 56

def import_safe_mode
  @import_safe_mode.nil? ? false : @import_safe_mode
end

.locales_pathObject

Full path to directory with translation files



19
20
21
# File 'lib/lokalise_rails.rb', line 19

def locales_path
  @locales_path || "#{Rails.root}/config/locales"
end

.project_idObject

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_exportObject

Additional file skip criteria to apply when performing export



61
62
63
# File 'lib/lokalise_rails.rb', line 61

def skip_file_export
  @skip_file_export || ->(_) { false }
end

.timeoutsObject

Set request timeouts for the Lokalise API client



29
30
31
# File 'lib/lokalise_rails.rb', line 29

def timeouts
  @timeouts || {}
end

Class Method Details

.config {|_self| ... } ⇒ Object

Main interface to provide configuration options for rake tasks

Yields:

  • (_self)

Yield Parameters:

  • _self (LokaliseRails)

    the object that the method was called on



14
15
16
# File 'lib/lokalise_rails.rb', line 14

def config
  yield self
end