Class: PlatformosCheck::TranslationFile
- Inherits:
-
YamlFile
show all
- Defined in:
- lib/platformos_check/translation_file.rb
Constant Summary
collapse
- DIR_PREFIX =
%r{\A/?((marketplace_builder|app)/(translations)/|(app/)?modules/((\w|-)*)/(private|public)/(translations)/)}
- TRANSLATION_FILTERS =
Set.new(%w[t t_escape translate translate_escape]).freeze
Instance Attribute Summary collapse
Attributes inherited from AppFile
#storage, #version
Instance Method Summary
collapse
Methods inherited from YamlFile
#content, #content_to_string, #initialize, #parse_error, #write, #yaml?
Methods inherited from AppFile
#==, #build_name, #dir_names, #graphql?, #initialize, #liquid?, #module_name, #module_original_file?, #module_original_file_path, #module_overwrite_file?, #module_overwrite_file_path, #module_prefix, #name, #page?, #partial?, #path, #relative_path, #remove_extension, #source, #yaml?
Instance Attribute Details
#language ⇒ Object
Returns the value of attribute language.
7
8
9
|
# File 'lib/platformos_check/translation_file.rb', line 7
def language
@language
end
|
Instance Method Details
#after_load ⇒ Object
19
20
21
22
23
24
|
# File 'lib/platformos_check/translation_file.rb', line 19
def after_load
@language = @content&.keys&.first
return if module_name.nil?
@content[@language].transform_keys! { |key| key.start_with?(module_prefix) ? key : "#{module_prefix}#{key}" }
end
|
#before_load ⇒ Object
15
16
17
|
# File 'lib/platformos_check/translation_file.rb', line 15
def before_load
@storage.platformos_app.instance_variable_set(:@translations_hash, nil) unless @loaded
end
|
#dir_prefix ⇒ Object
38
39
40
|
# File 'lib/platformos_check/translation_file.rb', line 38
def dir_prefix
DIR_PREFIX
end
|
#language_from_path ⇒ Object
26
27
28
|
# File 'lib/platformos_check/translation_file.rb', line 26
def language_from_path
@language_from_path ||= name.sub(module_prefix, '').split(File::SEPARATOR).first
end
|
#load! ⇒ Object
9
10
11
12
13
|
# File 'lib/platformos_check/translation_file.rb', line 9
def load!
before_load
super
after_load
end
|
#translation? ⇒ Boolean
42
43
44
|
# File 'lib/platformos_check/translation_file.rb', line 42
def translation?
true
end
|
#update_contents(new_content = {}) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/platformos_check/translation_file.rb', line 30
def update_contents(new_content = {})
before_load
super(new_content)
@loaded = true
after_load
end
|