Class: LokaliseManager::GlobalConfig

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

Overview

GlobalConfig provides a central place to manage configuration settings for LokaliseManager. It allows setting various operational parameters such as API tokens, paths, and behavior modifiers.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_tokenObject

Returns the value of attribute api_token.



8
9
10
# File 'lib/lokalise_manager/global_config.rb', line 8

def api_token
  @api_token
end

.branchObject

Return the project branch



41
42
43
# File 'lib/lokalise_manager/global_config.rb', line 41

def branch
  @branch || ''
end

.export_optsObject

Return export options



78
79
80
# File 'lib/lokalise_manager/global_config.rb', line 78

def export_opts
  @export_opts || {}
end

.file_ext_regexpObject

Return the regex for file extensions



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

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

.import_optsObject

Return import options with defaults



66
67
68
69
70
71
72
73
74
75
# File 'lib/lokalise_manager/global_config.rb', line 66

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

.import_safe_modeObject

Return whether import should check if target is empty



83
84
85
# File 'lib/lokalise_manager/global_config.rb', line 83

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

.lang_iso_infererObject

Infer language ISO code from translation file



103
104
105
# File 'lib/lokalise_manager/global_config.rb', line 103

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

.locales_pathObject

Return the path to locales



36
37
38
# File 'lib/lokalise_manager/global_config.rb', line 36

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

.max_retries_exportObject

Return the max retries for export



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

def max_retries_export
  @max_retries_export || 5
end

.max_retries_importObject

Return the max retries for import



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

def max_retries_import
  @max_retries_import || 5
end

.project_idObject

Returns the value of attribute project_id.



8
9
10
# File 'lib/lokalise_manager/global_config.rb', line 8

def project_id
  @project_id
end

.raise_on_export_failObject

Return whether to raise on export failure



21
22
23
# File 'lib/lokalise_manager/global_config.rb', line 21

def raise_on_export_fail
  @raise_on_export_fail.nil? ? true : @raise_on_export_fail
end

.silent_modeObject

Return whether debugging information is suppressed



26
27
28
# File 'lib/lokalise_manager/global_config.rb', line 26

def silent_mode
  @silent_mode || false
end

.skip_file_exportObject

Return whether to skip file export based on a lambda condition



88
89
90
# File 'lib/lokalise_manager/global_config.rb', line 88

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

.timeoutsObject

Return API request timeouts



46
47
48
# File 'lib/lokalise_manager/global_config.rb', line 46

def timeouts
  @timeouts || {}
end

.translations_converterObject

Convert raw translation data to YAML format



98
99
100
# File 'lib/lokalise_manager/global_config.rb', line 98

def translations_converter
  @translations_converter || ->(raw_data) { YAML.dump(raw_data).gsub('\\\\n', '\n') }
end

.translations_loaderObject

Load translations from raw data



93
94
95
# File 'lib/lokalise_manager/global_config.rb', line 93

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

.use_oauth2_tokenObject

Return whether to use OAuth2 tokens instead of regular API tokens



31
32
33
# File 'lib/lokalise_manager/global_config.rb', line 31

def use_oauth2_token
  @use_oauth2_token || false
end

Class Method Details

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

Yield self to block for configuration

Yields:

  • (_self)

Yield Parameters:



16
17
18
# File 'lib/lokalise_manager/global_config.rb', line 16

def config
  yield self
end