Module: Applocale
- Defined in:
- lib/applocale/Core/setting.rb,
lib/applocale.rb,
lib/applocale/version.rb,
lib/applocale/Core/init.rb,
lib/applocale/Util/lang.rb,
lib/applocale/Command/init.rb,
lib/applocale/Util/platform.rb,
lib/applocale/Util/file_util.rb,
lib/applocale/Util/error_util.rb,
lib/applocale/Util/error_util.rb,
lib/applocale/Util/error_util.rb,
lib/applocale/Util/error_util.rb,
lib/applocale/Util/regex_util.rb,
lib/applocale/Util/config_util.rb,
lib/applocale/Util/compare_util.rb,
lib/applocale/Util/convert_util.rb,
lib/applocale/Core/ParseCSV/parse_csv.rb,
lib/applocale/Core/ParseXLSX/parse_xlsx.rb,
lib/applocale/Core/ParseXLSX/parse_xlsx.rb,
lib/applocale/Core/convert_to_localefile.rb,
lib/applocale/Core/GoogleHepler/google_helper.rb,
lib/applocale/Core/ParseXLSX/parse_xlsx_module.rb,
lib/applocale/Core/ParseXLSX/parse_xlsx_module.rb,
lib/applocale/Core/ParseModel/parse_model_module.rb,
lib/applocale/Core/ParserStringFile/parse_xml_file.rb,
lib/applocale/Core/ParserStringFile/parse_strings_file.rb,
lib/applocale/Core/CompareStringFile/compare_string_file.rb,
lib/applocale/Core/CompareStringFile/compare_string_files.rb,
lib/applocale/Core/ParserStringFile/parse_localized_resource.rb
Overview
module Applocale
class Setting
class <<self
attr_accessor :link, :platform, :keystr, :langlist, :xlsxpath
end
def self.printlog
puts ' In Setting'
puts " link = #{self.link}"
puts " platform = #{self.platform}"
puts " keystr = #{self.keystr}"
puts " langlist = #{self.langlist}"
puts " xlsxpath = #{self.xlsxpath}"
end
end
end
Defined Under Namespace
Modules: Config, ErrorUtil, Locale, ParseModelModule, ParseXLSXModule, Platform
Classes: Command, CompareStringFile, CompareStringFiles, ContentUtil, ConvertFile, ConvertToStrFile, FilePathUtil, GoogleHelper, Injeust, ParseCSV, ParseLocalizedResource, ParseStringsFile, ParseXLSX, ParseXMLFile, ValidKey
Constant Summary
collapse
- VERSION =
"0.4.4"
Class Method Summary
collapse
-
.compare(file1, file2) ⇒ Object
-
.compare_local(file1, file2, projpath = Dir.pwd, result_file) ⇒ Object
-
.create_config_file(platformStr = nil, projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename) ⇒ Object
-
.findkey(key, projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename) ⇒ Object
-
.start_local_update(asetting = nil, projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename.to_s) ⇒ Object
-
.start_reverse(is_skip, projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename) ⇒ Object
-
.start_update(projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename) ⇒ Object
Class Method Details
.compare(file1, file2) ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/applocale/Core/init.rb', line 109
def self.compare(file1, file2)
file1_path = Applocale::FilePathUtil.get_proj_absoluat_path(file1)
file2_path = Applocale::FilePathUtil.get_proj_absoluat_path(file2)
unless File.exist?(file1_path)
ErrorUtil::FileNotExist.new.raise
end
unless File.exist?(file2_path)
ErrorUtil::FileNotExist.new.raise
end
ext1 = File.extname(file1).strip.downcase[1..-1]
ext2 = File.extname(file2).strip.downcase[1..-1]
if ext1 != ext2
ErrorUtil::FileMustSameExt.new.raise
end
if ext1 == 'strings'
platformsybom = Platform::IOS
elsif ext2 == 'xml'
platformsybom = Platform::ANDROID
end
Applocale::CompareStringFile.new(platformsybom,file1_path,file2_path).compare
end
|
.compare_local(file1, file2, projpath = Dir.pwd, result_file) ⇒ Object
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/applocale/Core/init.rb', line 135
def self.compare_local(file1, file2, projpath = Dir.pwd, result_file)
puts 'Reminder: run `update` for both files before `compare`'.yellow
proj_path = projpath
proj_path = Dir.pwd if projpath.nil?
proj_apath = Applocale::FilePathUtil.get_proj_absoluat_path(proj_path)
obj1 = Applocale::Config::ConfigUtil.new(proj_apath, file1)
obj2 = Applocale::Config::ConfigUtil.new(proj_apath, file2)
setting1 = obj1.load_configfile_to_setting(false)
setting2 = obj2.load_configfile_to_setting(false)
platform1 = setting1.platform
platform2 = setting2.platform
if platform1 != platform2
ErrorUtil::FileMustSamePlatform.new.raise
end
if result_file.nil?
ErrorUtil::MissingComparisonResultFilePath.new.raise
end
if File.extname(result_file).strip.downcase[1..-1].downcase != 'csv'
ErrorUtil::NotSupportComparisonResultFileExtension.new.raise
end
result_file_path = File.join(proj_apath, FilePathUtil.default_mainfolder, result_file)
Applocale::CompareStringFiles.new(platform1, file1, file2, setting1, setting2, result_file_path)
end
|
.create_config_file(platformStr = nil, projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/applocale/Core/init.rb', line 18
def self.create_config_file( platformStr = nil, projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename)
configfile_name = configFile
configfile_name = FilePathUtil.default_config_filename if configfile_name.nil?
proj_path = projpath
proj_path = Dir.pwd if projpath.nil?
proj_apath = Applocale::FilePathUtil.get_proj_absoluat_path(proj_path)
if platformStr.nil?
if Dir.glob("#{proj_apath}/**/*.xcodeproj").length > 0 || Dir.glob("#{proj_apath}/*.xcworkspace").length > 0
platformsybom = Platform::IOS
elsif Dir.glob("#{proj_apath}/**/*.gradle").length > 0
platformsybom = Platform::ANDROID
else
Applocale::ErrorUtil::CommandError.new("Missing [platform] : ios | android | json").raise
end
else
platformsybom = Platform.init(platformStr.strip)
end
if platformsybom.nil?
ErrorUtil::CommandError.new("Invalid [platform] : ios | android | json").raise
else
Applocale::Config::ConfigUtil.create_configfile_ifneed(platformsybom,proj_apath.to_s, configfile_name )
end
end
|
.findkey(key, projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename) ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/applocale/Core/init.rb', line 97
def self.findkey( key, projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename)
configfile_name = configFile
configfile_name = FilePathUtil.default_config_filename if configfile_name.nil?
proj_path = projpath
proj_path = Dir.pwd if projpath.nil?
proj_apath = Applocale::FilePathUtil.get_proj_absoluat_path(proj_path)
obj = Applocale::Config::ConfigUtil.new(proj_apath, configfile_name)
report_folder = File.dirname(obj.configfile_pathstr)
findobj = FindStrKey::FindValue.new(Applocale::Platform::IOS, proj_apath, report_folder, key)
findobj.find
end
|
.start_local_update(asetting = nil, projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename.to_s) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/applocale/Core/init.rb', line 66
def self.start_local_update(asetting = nil, projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename.to_s)
configfile_name = configFile
configfile_name = FilePathUtil.default_config_filename if configfile_name.nil?
proj_path = projpath
proj_path = Dir.pwd if projpath.nil?
proj_apath = Applocale::FilePathUtil.get_proj_absoluat_path(proj_path)
setting = asetting
if setting.nil?
obj = Applocale::Config::ConfigUtil.new(proj_apath, configfile_name)
setting = obj.load_configfile_to_setting
end
case setting.export_format
when 'csv'
parser = Applocale::ParseCSV.new(setting)
when 'xlsx'
parser = Applocale::ParseXLSX.new(setting)
end
ConvertToStrFile.convert(setting, parser.result)
end
|
.start_reverse(is_skip, projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename) ⇒ Object
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/applocale/Core/init.rb', line 86
def self.start_reverse( is_skip, projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename)
configfile_name = configFile
configfile_name = FilePathUtil.default_config_filename if configfile_name.nil?
proj_path = projpath
proj_path = Dir.pwd if projpath.nil?
proj_apath = Applocale::FilePathUtil.get_proj_absoluat_path(proj_path)
obj = Applocale::Config::ConfigUtil.new(proj_apath, configfile_name)
setting = obj.load_configfile_to_setting
Applocale::ParseLocalizedResource.new(is_skip,setting.platform,setting.xlsxpath, setting.lang_path_list, setting.sheet_obj_list, setting.convert_file )
end
|
.start_update(projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/applocale/Core/init.rb', line 42
def self.start_update(projpath = Dir.pwd, configFile = FilePathUtil.default_config_filename)
configfile_name = configFile
configfile_name = FilePathUtil.default_config_filename if configfile_name.nil?
proj_path = projpath
proj_path = Dir.pwd if projpath.nil?
proj_apath = Applocale::FilePathUtil.get_proj_absoluat_path(proj_path)
obj = Applocale::Config::ConfigUtil.new(proj_apath, configfile_name)
setting = obj.load_configfile_to_setting
if setting.link.to_s.length <= 0
ErrorUtil::ConfigFileInValid.new('[link] is missing in config file ').raise
end
if Applocale::GoogleHelper.is_googlelink(setting.link)
if setting.google_credentials_path.to_s.length <= 0
setting.google_credentials_path = File.expand_path(FilePathUtil.default_google_credentials_filename, File.dirname(setting.configfile_pathstr))
end
googleobj = Applocale::GoogleHelper.new(setting.link, setting.google_credentials_path, setting.xlsxpath)
googleobj.download(setting.sheet_obj_list, export_format: setting.export_format, export_to: setting.export_to)
else
download = open(setting.link)
IO.copy_stream(download, setting.xlsxpath)
end
Applocale.start_local_update(setting, proj_path, configfile_name)
end
|