Class: Locca::XcodeProject
Instance Attribute Summary collapse
Attributes inherited from Project
#base_lang, #dir
Instance Method Summary
collapse
Methods inherited from Project
#config_value_for_key, #prevent_sync_without_comments?
Constructor Details
#initialize(dir, xcode_target, config) ⇒ XcodeProject
Returns a new instance of XcodeProject.
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/locca/projects/xcode_project.rb', line 32
def initialize(dir, xcode_target, config)
super(dir, config)
@xcode_target = xcode_target
@files = Array.new()
@langs = Set.new()
@xcode_target.resources_build_phase.files_references.each { |file|
if file.display_name.end_with?(".strings") && file.is_a?(Xcodeproj::Project::Object::PBXVariantGroup)
@files.push(file)
if file.display_name == "Localizable.strings"
file.files.each { |variant_file|
@langs.add(variant_file.name)
}
end
end
}
end
|
Instance Attribute Details
#langs ⇒ Object
Returns the value of attribute langs.
30
31
32
|
# File 'lib/locca/projects/xcode_project.rb', line 30
def langs
@langs
end
|
Instance Method Details
#collection_builder ⇒ Object
83
84
85
86
|
# File 'lib/locca/projects/xcode_project.rb', line 83
def collection_builder()
parser = Babelyoda::StringsParser.new(Babelyoda::StringsLexer.new())
return CollectionBuilder.new(File, parser)
end
|
#collection_names ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/locca/projects/xcode_project.rb', line 55
def collection_names
result = Set.new()
@files.each { |file|
result.add(File.basename(file.display_name, '.strings'))
}
return result
end
|
#collection_writer ⇒ Object
88
89
90
|
# File 'lib/locca/projects/xcode_project.rb', line 88
def collection_writer()
return CollectionWriter.new(File, CollectionItemDefaultFormatter.new())
end
|
#collections_generator ⇒ Object
92
93
94
95
96
97
98
|
# File 'lib/locca/projects/xcode_project.rb', line 92
def collections_generator()
source_files = Array.new()
@xcode_target.source_build_phase.files_references.each { |file|
source_files.push(file.real_path.to_s)
}
return CollectionsGenerator.new(source_files, Genstrings.new(), collection_builder())
end
|
#full_collection_name(collection_name) ⇒ Object
64
65
66
|
# File 'lib/locca/projects/xcode_project.rb', line 64
def full_collection_name(collection_name)
return "#{collection_name}.strings"
end
|
#name ⇒ Object
51
52
53
|
# File 'lib/locca/projects/xcode_project.rb', line 51
def name
return @xcode_target.name
end
|
100
101
102
|
# File 'lib/locca/projects/xcode_project.rb', line 100
def one_sky_file_format
return "IOS_STRINGS"
end
|
#path_for_collection(collection_name, lang) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/locca/projects/xcode_project.rb', line 68
def path_for_collection(collection_name, lang)
collection_name = "#{collection_name}.strings"
@files.each { |file|
if file.display_name == collection_name
file.files.each { |variant_file|
if variant_file.name == lang
return variant_file.real_path
end
}
end
}
return nil
end
|