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_filename_generator ⇒ Object
Adjust filenames before exporting to Lokalise.
-
.export_opts ⇒ Object
Return export options.
-
.export_preprocessor ⇒ Object
Preprocess content during exporting to Lokalise.
-
.file_ext_regexp ⇒ Object
Return the regex for file extensions.
-
.import_async ⇒ Object
Return whether import should be performed asynchronously.
-
.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
48 49 50 |
# File 'lib/lokalise_manager/global_config.rb', line 48 def additional_client_opts @additional_client_opts || {} end |
.api_token ⇒ Object
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 |
.branch ⇒ Object
Return the project branch
43 44 45 |
# File 'lib/lokalise_manager/global_config.rb', line 43 def branch @branch || '' end |
.export_filename_generator ⇒ Object
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_opts ⇒ Object
Return export options
82 83 84 |
# File 'lib/lokalise_manager/global_config.rb', line 82 def export_opts @export_opts || {} end |
.export_preprocessor ⇒ Object
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_regexp ⇒ Object
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_async ⇒ Object
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_opts ⇒ Object
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_mode ⇒ Object
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_inferer ⇒ Object
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_path ⇒ Object
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_export ⇒ Object
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_import ⇒ Object
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_id ⇒ Object
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_fail ⇒ Object
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_mode ⇒ Object
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_export ⇒ Object
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_converter ⇒ Object
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_loader ⇒ Object
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_token ⇒ Object
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
18 19 20 |
# File 'lib/lokalise_manager/global_config.rb', line 18 def config yield self end |