Class: LokaliseManager::GlobalConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/lokalise_manager/global_config.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_tokenObject

Returns the value of attribute api_token.



6
7
8
# File 'lib/lokalise_manager/global_config.rb', line 6

def api_token
  @api_token
end

.branchObject

Project branch to use



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

def branch
  @branch || ''
end

.export_optsObject

Options for export rake task



66
67
68
# File 'lib/lokalise_manager/global_config.rb', line 66

def export_opts
  @export_opts || {}
end

.file_ext_regexpObject

Regular expression used to select translation files with proper extensions



49
50
51
# File 'lib/lokalise_manager/global_config.rb', line 49

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

.import_optsObject

Options for import rake task



54
55
56
57
58
59
60
61
62
63
# File 'lib/lokalise_manager/global_config.rb', line 54

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



71
72
73
# File 'lib/lokalise_manager/global_config.rb', line 71

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

.lang_iso_infererObject

Infers lang ISO for the given translation file



90
91
92
# File 'lib/lokalise_manager/global_config.rb', line 90

def lang_iso_inferer
  @lang_iso_inferer || ->(data) { YAML.safe_load(data)&.keys&.first }
end

.locales_pathObject

Full path to directory with translation files



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

def locales_path
  @locales_path || "#{Dir.getwd}/locales"
end

.max_retries_exportObject

Maximum number of retries for file exporting



39
40
41
# File 'lib/lokalise_manager/global_config.rb', line 39

def max_retries_export
  @max_retries_export || 5
end

.max_retries_importObject

Maximum number of retries for file importing



44
45
46
# File 'lib/lokalise_manager/global_config.rb', line 44

def max_retries_import
  @max_retries_import || 5
end

.project_idObject

Returns the value of attribute project_id.



6
7
8
# File 'lib/lokalise_manager/global_config.rb', line 6

def project_id
  @project_id
end

.skip_file_exportObject

Additional file skip criteria to apply when performing export



76
77
78
# File 'lib/lokalise_manager/global_config.rb', line 76

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

.timeoutsObject

Set request timeouts for the Lokalise API client



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

def timeouts
  @timeouts || {}
end

.translations_converterObject

Converts translations data to the proper format



85
86
87
# File 'lib/lokalise_manager/global_config.rb', line 85

def translations_converter
  @translations_converter || ->(raw_data) { raw_data.to_yaml }
end

.translations_loaderObject



80
81
82
# File 'lib/lokalise_manager/global_config.rb', line 80

def translations_loader
  @translations_loader || ->(raw_data) { YAML.safe_load raw_data }
end

.use_oauth2_tokenObject

When enabled, will use OAuth 2 Lokalise client and will require to provide a token obtained via OAuth 2 flow rather than via Lokalise profile



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

def use_oauth2_token
  @use_oauth2_token || false
end

Class Method Details

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

Main interface to provide configuration options

Yields:

  • (_self)

Yield Parameters:



13
14
15
# File 'lib/lokalise_manager/global_config.rb', line 13

def config
  yield self
end