Class: Vocab::Extractor::Android
- Inherits:
-
Base
- Object
- Base
- Vocab::Extractor::Android
show all
- Defined in:
- lib/vocab/extractor/android.rb
Constant Summary
collapse
- DIFF =
'strings.diff.xml'
- FULL =
'strings.full.xml'
- STRINGS_XML =
'res/values/strings.xml'
Class Method Summary
collapse
Methods inherited from Base
diff, extract, git_path, git_root, mkdir_examples, previous_file, update_settings
Class Method Details
.current_plurals(path = nil) ⇒ Object
.current_strings(path = nil) ⇒ Object
.examples(locales_dir = nil) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/vocab/extractor/android.rb', line 43
def examples( locales_dir = nil )
locales_dir ||= "#{Vocab.root}/res/values"
return Vocab::Translator::Android.locales( locales_dir ).collect do |locale|
"tmp/translations/values-#{locale}"
end
end
|
.previous_plurals(path = nil) ⇒ Object
.previous_strings(path = nil) ⇒ Object
.print_instructions(values = {}) ⇒ Object
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/vocab/extractor/android.rb', line 50
def print_instructions( values = {} )
values[ :diff ] = DIFF
values[ :full ] = FULL
values[ :tree ] = <<-EOS
tmp/translations/values-es/strings.xml
tmp/translations/values-zh-rCN/strings.xml
EOS
super( values )
end
|
.tmp_file(path) ⇒ Object
61
62
63
64
65
66
67
68
|
# File 'lib/vocab/extractor/android.rb', line 61
def tmp_file( path )
sha = Vocab.settings.last_translation
xml = previous_file( path, sha )
tmpfile = "#{Vocab.root}/tmp/last_translation/#{File.basename(path)}"
FileUtils.mkdir_p( File.dirname( tmpfile ) )
File.open( tmpfile, 'w' ) { |f| f.write( xml ) }
return tmpfile
end
|
.write_diff(strings, plurals, path = nil) ⇒ Object
33
34
35
36
|
# File 'lib/vocab/extractor/android.rb', line 33
def write_diff( strings, plurals, path = nil )
path ||= "#{Vocab.root}/#{DIFF}"
Vocab::Translator::Android.write( strings, plurals, path )
end
|
.write_full(strings, plurals, path = nil) ⇒ Object
38
39
40
41
|
# File 'lib/vocab/extractor/android.rb', line 38
def write_full( strings, plurals, path = nil )
path ||= "#{Vocab.root}/#{FULL}"
Vocab::Translator::Android.write( strings, plurals, path )
end
|