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

.additional_client_optsObject

Return additional API client options



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

def additional_client_opts
  @additional_client_opts || {}
end

.api_tokenObject

Returns the value of attribute api_token.



10
11
12
# File 'lib/lokalise_manager/global_config.rb', line 10

def api_token
  @api_token
end

.branchObject

Return the project branch



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

def branch
  @branch || ''
end

.export_filename_generatorObject

Adjust filenames before exporting to Lokalise



122
123
124
# File 'lib/lokalise_manager/global_config.rb', line 122

def export_filename_generator
  @export_filename_generator || ->(_full_path, relative_path) { relative_path }
end

.export_optsObject

Return export options



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

def export_opts
  @export_opts || {}
end

.export_preprocessorObject

Preprocess content during exporting to Lokalise



117
118
119
# File 'lib/lokalise_manager/global_config.rb', line 117

def export_preprocessor
  @export_preprocessor || ->(raw_data, _path) { raw_data }
end

.file_ext_regexpObject

Return the regex for file extensions



63
64
65
# File 'lib/lokalise_manager/global_config.rb', line 63

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

.import_asyncObject

Return whether import should be performed asynchronously



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

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

.import_optsObject

Return import options with defaults



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/lokalise_manager/global_config.rb', line 68

def import_opts
  defaults = {
    format: 'ruby_yaml',
    placeholder_format: :icu,
    yaml_include_root: true,
    original_filenames: true,
    directory_prefix: '',
    indentation: '2sp'
  }

  defaults.merge(@import_opts || {})
end

.import_safe_modeObject

Return whether import should check if target is empty



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

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

.lang_iso_infererObject

Infer language ISO code from translation file



112
113
114
# File 'lib/lokalise_manager/global_config.rb', line 112

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

.locales_pathObject

Return the path to locales



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

def locales_path
  @locales_path || File.join(Dir.pwd, 'locales')
end

.max_retries_exportObject

Return the max retries for export



53
54
55
# File 'lib/lokalise_manager/global_config.rb', line 53

def max_retries_export
  @max_retries_export || 5
end

.max_retries_importObject

Return the max retries for import



58
59
60
# File 'lib/lokalise_manager/global_config.rb', line 58

def max_retries_import
  @max_retries_import || 5
end

.project_idObject

Returns the value of attribute project_id.



10
11
12
# File 'lib/lokalise_manager/global_config.rb', line 10

def project_id
  @project_id
end

.raise_on_export_failObject

Return whether to raise on export failure



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

def raise_on_export_fail
  @raise_on_export_fail.nil? || @raise_on_export_fail
end

.silent_modeObject

Return whether debugging information is suppressed



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

def silent_mode
  @silent_mode || false
end

.skip_file_exportObject

Return whether to skip file export based on a lambda condition



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

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

.translations_converterObject

Convert raw translation data to YAML format



107
108
109
# File 'lib/lokalise_manager/global_config.rb', line 107

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

.translations_loaderObject

Load translations from raw data



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

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



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

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:



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

def config
  yield self
end