Class: LokaliseManager::GlobalConfig
- Inherits:
-
Object
- Object
- LokaliseManager::GlobalConfig
- 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
-
.additional_client_opts ⇒ Object
Return additional API client options.
-
.api_token ⇒ Object
Returns the value of attribute api_token.
-
.branch ⇒ Object
Return the project branch.
-
.export_opts ⇒ Object
Return export options.
-
.file_ext_regexp ⇒ Object
Return the regex for file extensions.
-
.import_opts ⇒ Object
Return import options with defaults.
-
.import_safe_mode ⇒ Object
Return whether import should check if target is empty.
-
.lang_iso_inferer ⇒ Object
Infer language ISO code from translation file.
-
.locales_path ⇒ Object
Return the path to locales.
-
.max_retries_export ⇒ Object
Return the max retries for export.
-
.max_retries_import ⇒ Object
Return the max retries for import.
-
.project_id ⇒ Object
Returns the value of attribute project_id.
-
.raise_on_export_fail ⇒ Object
Return whether to raise on export failure.
-
.silent_mode ⇒ Object
Return whether debugging information is suppressed.
-
.skip_file_export ⇒ Object
Return whether to skip file export based on a lambda condition.
-
.translations_converter ⇒ Object
Convert raw translation data to YAML format.
-
.translations_loader ⇒ Object
Load translations from raw data.
-
.use_oauth2_token ⇒ Object
Return whether to use OAuth2 tokens instead of regular API tokens.
Class Method Summary collapse
-
.config {|_self| ... } ⇒ Object
Yield self to block for configuration.
Class Attribute Details
.additional_client_opts ⇒ Object
Return additional API client options
46 47 48 |
# File 'lib/lokalise_manager/global_config.rb', line 46 def additional_client_opts @additional_client_opts || {} end |
.api_token ⇒ Object
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 |
.branch ⇒ Object
Return the project branch
41 42 43 |
# File 'lib/lokalise_manager/global_config.rb', line 41 def branch @branch || '' end |
.export_opts ⇒ Object
Return export options
78 79 80 |
# File 'lib/lokalise_manager/global_config.rb', line 78 def export_opts @export_opts || {} end |
.file_ext_regexp ⇒ Object
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_opts ⇒ Object
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_mode ⇒ Object
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_inferer ⇒ Object
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_path ⇒ Object
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_export ⇒ Object
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_import ⇒ Object
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_id ⇒ Object
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_fail ⇒ Object
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_mode ⇒ Object
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_export ⇒ Object
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 |
.translations_converter ⇒ Object
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_loader ⇒ Object
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_token ⇒ Object
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
16 17 18 |
# File 'lib/lokalise_manager/global_config.rb', line 16 def config yield self end |