Module: SiSU_Po4a_Actions

Includes:
SiSU_Response
Defined in:
lib/sisu/sisu_thor_lib.rb

Constant Summary collapse

@@source =
@@targets=nil

Instance Method Summary collapse

Methods included from SiSU_Response

#answer?, #available_selections_, #query, #response?, #response_short, #response_strict, #selection_options, #selections_available_

Instance Method Details

#allObject



337
338
339
# File 'lib/sisu/sisu_thor_lib.rb', line 337

def all
  Dir.glob("#{language.source_language_selected}/*{.ssm,.sst,.ssi}").sort
end

#cleanObject



393
394
395
396
397
# File 'lib/sisu/sisu_thor_lib.rb', line 393

def clean
  #rm -f po/*/*.po~
  #rm -rf ../build
  FileUtils.rm_f Dir.glob("./#{dir.po}/*/*.po~")
end

#configureObject

po4a_cfg



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'lib/sisu/sisu_thor_lib.rb', line 346

def configure #po4a_cfg
  po4a_cfg_arr=[]
  po4a_cfg_arr \
    << "[po4a_langs] #{language.translation_languages_selected_that_are_available_str}"
  po4a_cfg_arr \
    << "[po4a_paths] #{dir.pot}/$master.pot $lang:#{dir.po}/$lang/$master.po"
  files_src.ssm.each do |file_src|
    file_src_fn=file_src.gsub(/#{language.source_language_selected}\//,'')
    po4a_cfg_arr \
      << "[type: text] #{file_src} $lang:$lang/#{file_src_fn}"
  end
  files_src.sst.each do |file_src|
    file_src_fn=file_src.gsub(/#{language.source_language_selected}\//,'')
    po4a_cfg_arr \
      << "[type: text] #{file_src} $lang:$lang/#{file_src_fn}"
  end
  files_src.ssi.each do |file_src|
    file_src_fn=file_src.gsub(/#{language.source_language_selected}\//,'')
    po4a_cfg_arr \
      << "[type: text] #{file_src} $lang:$lang/#{file_src_fn}"
  end
  file=po4a_cfg_file
  po4a_cfg_arr.each do |txt|
  puts txt
    file << txt << "\n"
  end
  file.close
  cmd='po4a --keep 0 ' \
  + po4a_flags.normal + ' ' \
  + filename.po4a_cfg
  #cmd='po4a --keep 0 --no-backups --package-name ' \
  #+ 'sisu-manual' + ' ' \
  #+ po4a_flags.normal + ' ' \
  #+ filename.po4a_cfg
  system(cmd); puts cmd
end

#debugObject



189
190
191
# File 'lib/sisu/sisu_thor_lib.rb', line 189

def debug
  '-d -v'
end

#default(selection = nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/sisu/sisu_thor_lib.rb', line 29

def default(selection=nil)
  selections=:strict #selections=:short
  ans=if selection
    case selection
    when selection.is_a?(String)
      selections=:strict
      <<-WOK
  #{project_details.setup_project}
Default action selected - "#{selection} #{project_details.name}"
#{warn_and_proceed?}
      WOK
    when :make
      selections=:strict
      <<-WOK
  #{project_details.setup_project}
"--#{selection}" selected - #{selection} #{project_details.name}
selected (or configured) languages to be used
  source language: #{language.source_language_available_str}
  target languages: #{language.translation_languages_selected_that_are_available.inspect}

WARNING: this action assumes (and places) this project is under po4a
(translation) management. It will create sub-directories for the
selected (or configured) target languages:
  #{language.translation_languages_selected_that_are_available.inspect}
& the po4a configuration file: #{filename.po4a_cfg}
in the current directory:
  #{Dir.pwd}
It will populate the sub-directories with translation files created from
the pot and po files found under the corresponding language
sub-directories, (under #{dir.pot}/ & #{dir.po}/).
(OVERWRITING any existing translated .ssm .sst .ssi files
in language subdirectories that are not under po4a management).

You should backup the current directory:
  #{Dir.pwd}

#{warn_and_proceed?}
      WOK
    when :clean
      selections=:strict
      <<-WOK
  #{project_details.setup_project}
"--#{selection}" selected - #{selection} #{project_details.name}
#{warn_and_proceed?}
      WOK
    when :distclean
      selections=:strict
      <<-WOK
  #{project_details.setup_project}
"--#{selection}" selected - #{selection} #{project_details.name}
WARNING: this action assumes (and places) this project is under po4a
(translation) management. It will remove the sub-directories (if they exist):
  #{language.possible_translations.inspect}

  #{language.translation_languages_selected_that_are_available.inspect}
& file: #{filename.po4a_cfg}
in the current directory:
  #{Dir.pwd}
Note: these sub-directories & the config file #{filename.po4a_cfg}
should be auto-generated from pot and po files if this project translation
is under po4a management.
This query is to give you the chance to make sure you know what you are doing.
#{warn_and_proceed?}
      WOK
    when :rebuild
      selections=:strict
      <<-WOK
  #{project_details.setup_project}
"--#{selection}" selected - #{selection} #{project_details.name}
WARNING: this action assumes (and places) this project is under po4a
(translation) management. It will destroy/clobber and then create again the
sub-directories:
  #{language.translation_languages_selected_that_are_available.inspect}
populating them with translation files created from the pot and po files
found under the corresponding language sub-directories in (#{dir.pot}/
& #{dir.po}/).
It will also generate the file: #{filename.po4a_cfg}
These actions will be taken in the current directory:
  #{Dir.pwd}
This query is to give you the chance to make sure you know what you are doing.
#{warn_and_proceed?}
      WOK
    else
      selections=:strict
      <<-WOK
  #{project_details.setup_project}
Default action selected - "#{selection} #{project_details.name}"
#{warn_and_proceed?}
      WOK
    end
  else
    selections=:strict
    <<-WOK
  #{project_details.setup_project}
Default action selected - "install and to setup #{project_details.name}"
#{warn_and_proceed?}
    WOK
  end
  exit unless query.answer?(ans)
end

#dirObject



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/sisu/sisu_thor_lib.rb', line 170

def dir
  def pwd
    Dir.pwd
  end
  def po4a_
    'po4a/' # ''
  end
  def pot
    po4a_ + 'pot'
  end
  def po
    po4a_ + 'po'
  end
  self
end

#dir_mk(dir) ⇒ Object



185
186
187
# File 'lib/sisu/sisu_thor_lib.rb', line 185

def dir_mk(dir)
  FileUtils::mkdir_p(dir) unless FileTest.directory?(dir)
end

#distcleanObject



398
399
400
401
402
403
# File 'lib/sisu/sisu_thor_lib.rb', line 398

def distclean
  #rm -f po4a.cfg
  #rm -rf $(LANGUAGES)
  FileUtils::rm_f(filename.po4a_cfg)
  FileUtils::rm_r(language.possible_translations,:force => true)
end

#filenameObject



160
161
162
163
164
165
166
167
168
169
# File 'lib/sisu/sisu_thor_lib.rb', line 160

def filename
  def languages_src_tgt
    #'translation_languages'
    'languages_source_and_targets'
  end
  def po4a_cfg
    'po4a.cfg'
  end
  self
end

#files_srcObject



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/sisu/sisu_thor_lib.rb', line 327

def files_src
  def ssm
    Dir.glob("#{language.source_language_selected}/*.ssm").sort
  end
  def sst
    Dir.glob("#{language.source_language_selected}/*.sst").sort
  end
  def ssi
    Dir.glob("#{language.source_language_selected}/*.ssi").sort
  end
  def all
    Dir.glob("#{language.source_language_selected}/*{.ssm,.sst,.ssi}").sort
  end
  self
end

#generateObject



151
152
153
154
155
156
157
158
159
# File 'lib/sisu/sisu_thor_lib.rb', line 151

def generate
  def readme
    system(%{ruby ../../../../../bin/sisu6 --txt -v --no-manifest --dump='../../../../../..' en/README.ssm})
  end
  def manpage
    system(%{ruby ../../../../../bin/sisu6 --manpage -v --no-manifest --dump='../../../../../../man/man1' en/sisu.ssm})
  end
  self
end

#info_on_selectionObject



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/sisu/sisu_thor_lib.rb', line 282

def info_on_selection
  if translation_languages_selected != translation_languages_selected_that_are_available
    <<-WOK
WARNING: language selections mismatch

The current language translation selection appears to be: #{translation_languages_selected_str}
Of which the following are valid (available) selections:  #{translation_languages_selected_that_are_available_str}

sisu available language list: #{sisu_languages_available_str}

the following will be used: #{translation_languages_selected_that_are_available_str}
The languages selected are located in the file:    #{filename.languages_src_tgt}
    WOK
  else
    <<-WOK
The current language translation selection is:  #{translation_languages_selected_str}
The languages selected are located in the file: #{filename.languages_src_tgt}

sisu available language list: #{sisu_languages_available_str}
    WOK
  end
end

#languageObject



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/sisu/sisu_thor_lib.rb', line 249

def language
  def source_language_selected(src=nil)
    @@source=if not @@source.nil? \
    and @@source.is_a?(String) \
    and @@source =~/\w{2,4}/
      @@source
    elsif (src \
    && src.is_a?(String) \
    && src.length > 1)
      src
    else
      src=languages_from_file.language_source
    end
  end
  def translation_languages_selected(targets=nil) #translation_languages
    @@targets=if not @@targets.nil? \
    and @@targets.is_a?(Array) \
    and @@targets.length > 0
      @@targets
    elsif (targets \
    && targets.is_a?(Array) \
    && targets.length > 0)
      targets
    else
      targets=languages_from_file.language_targets
    end
  end
  def source_language_available
    [source_language_selected] & sisu_languages_available
  end
  def translation_languages_selected_that_are_available
    translation_languages_selected & sisu_languages_available
  end
  def info_on_selection
    if translation_languages_selected != translation_languages_selected_that_are_available
      <<-WOK
WARNING: language selections mismatch

The current language translation selection appears to be: #{translation_languages_selected_str}
Of which the following are valid (available) selections:  #{translation_languages_selected_that_are_available_str}

sisu available language list: #{sisu_languages_available_str}

the following will be used: #{translation_languages_selected_that_are_available_str}
The languages selected are located in the file:    #{filename.languages_src_tgt}
      WOK
    else
      <<-WOK
The current language translation selection is:  #{translation_languages_selected_str}
The languages selected are located in the file: #{filename.languages_src_tgt}

sisu available language list: #{sisu_languages_available_str}
      WOK
    end
  end
  def sisu_languages_available
    $SiSU_Language_Codes.language_list.codes
  end
  def possible_translations
    sisu_languages_available -  [source_language_selected]
  end
  def translation_languages_selected_str
    language.translation_languages_selected.join(' ')
  end
  def source_language_available_str
    source_language_available.join
  end
  def translation_languages_selected_that_are_available_str
    language.translation_languages_selected_that_are_available.join(' ')
  end
  def sisu_languages_available_str
    language.sisu_languages_available.join(' ')
  end
  def posible_translations_str
    language.posible_translations.join(' ')
  end
  self
end

#language_sourceObject



201
202
203
204
205
206
207
# File 'lib/sisu/sisu_thor_lib.rb', line 201

def language_source
  if @@source.is_a?(String) \
  and @@source =~ /w{2,4}/
  else languages_extract_from_file
  end
  @@source
end

#language_targetsObject



208
209
210
211
212
213
214
# File 'lib/sisu/sisu_thor_lib.rb', line 208

def language_targets
  if @@targets.is_a?(Array) \
  and @@targets.length > 0
  else languages_extract_from_file
  end
  @@targets
end

#languages_extract_from_fileObject



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/sisu/sisu_thor_lib.rb', line 215

def languages_extract_from_file
  if (@@source.is_a?(String) \
  and @@source =~/\w{2,4}/) \
  and (@@targets.is_a?(Array) \
  and @@targets.length > 0)
  else
    if FileTest.file?(filename.languages_src_tgt)
      puts 'file: "' + filename.languages_src_tgt + '" found and used (unless overridden)'
      langs=IO.read(filename.languages_src_tgt, mode: 'r:utf-8').scan(/source:\s+\w+|target:\s+\w.+/)
      langs.each do |sel|
        case sel
        when /source:/
          source=sel.split(/source:\s*|\s+/).join
          source=(source =~/\w{2,4}/) ? source : nil
          @@source=unless @@source.is_a?(String) \
          and @@source =~/\w{2,4}/
            source
          else @@source
          end
        when /target:/
          @@targets=unless @@targets.is_a?(Array)
            sel.split(/targets?:\s*|\s+/) - ['']
          else @@targets
          end
        end
      end
    else
      puts %{(create) missing instruction file: "#{filename.languages_src_tgt}"\n  contents e.g.:\n    source: en\n    target: de fr es ja ru zh\n  no po target languages found}
      exit
    end
  end
end

#languages_from_fileObject



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/sisu/sisu_thor_lib.rb', line 200

def languages_from_file
  def language_source
    if @@source.is_a?(String) \
    and @@source =~ /w{2,4}/
    else languages_extract_from_file
    end
    @@source
  end
  def language_targets
    if @@targets.is_a?(Array) \
    and @@targets.length > 0
    else languages_extract_from_file
    end
    @@targets
  end
  def languages_extract_from_file
    if (@@source.is_a?(String) \
    and @@source =~/\w{2,4}/) \
    and (@@targets.is_a?(Array) \
    and @@targets.length > 0)
    else
      if FileTest.file?(filename.languages_src_tgt)
        puts 'file: "' + filename.languages_src_tgt + '" found and used (unless overridden)'
        langs=IO.read(filename.languages_src_tgt, mode: 'r:utf-8').scan(/source:\s+\w+|target:\s+\w.+/)
        langs.each do |sel|
          case sel
          when /source:/
            source=sel.split(/source:\s*|\s+/).join
            source=(source =~/\w{2,4}/) ? source : nil
            @@source=unless @@source.is_a?(String) \
            and @@source =~/\w{2,4}/
              source
            else @@source
            end
          when /target:/
            @@targets=unless @@targets.is_a?(Array)
              sel.split(/targets?:\s*|\s+/) - ['']
            else @@targets
            end
          end
        end
      else
        puts %{(create) missing instruction file: "#{filename.languages_src_tgt}"\n  contents e.g.:\n    source: en\n    target: de fr es ja ru zh\n  no po target languages found}
        exit
      end
    end
  end
  self
end

#languages_src_tgtObject



161
162
163
164
# File 'lib/sisu/sisu_thor_lib.rb', line 161

def languages_src_tgt
  #'translation_languages'
  'languages_source_and_targets'
end

#makeObject



385
386
387
388
389
390
391
392
# File 'lib/sisu/sisu_thor_lib.rb', line 385

def make
  dir_mk(dir.pot)
  language.translation_languages_selected_that_are_available.each do |lang_dir|
    dir_lang="#{Dir.pwd}/#{dir.po}/#{lang_dir}"
    dir_mk(dir_lang)
  end
  po4a_create.configure
end

#manpageObject



155
156
157
# File 'lib/sisu/sisu_thor_lib.rb', line 155

def manpage
  system(%{ruby ../../../../../bin/sisu6 --manpage -v --no-manifest --dump='../../../../../../man/man1' en/sisu.ssm})
end

#nameObject



6
7
8
# File 'lib/sisu/sisu_thor_lib.rb', line 6

def name
  'SiSU translations under po4a management'
end

#name_warningObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/sisu/sisu_thor_lib.rb', line 9

def name_warning
  <<-WOK
#{name}

WARNING all sisu markup files (.ssm, .sst, .ssi) in languages other than #{language.source_language_selected}
are managed by po4a, through translations of the source language to other languages.

#{language.info_on_selection}
  WOK
end

#normalObject



192
193
194
# File 'lib/sisu/sisu_thor_lib.rb', line 192

def normal
  ''
end

#noticeObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/sisu/sisu_thor_lib.rb', line 24

def notice
  def warn_and_proceed?
    '*WARNING* this software module creates, destroys, overwrites directories' + "\n" \
    + '*WARNING*: Use this Software at your own risk!'
  end
  def default(selection=nil)
    selections=:strict #selections=:short
    ans=if selection
      case selection
      when selection.is_a?(String)
        selections=:strict
        <<-WOK
#{project_details.setup_project}
  Default action selected - "#{selection} #{project_details.name}"
#{warn_and_proceed?}
        WOK
      when :make
        selections=:strict
        <<-WOK
#{project_details.setup_project}
  "--#{selection}" selected - #{selection} #{project_details.name}
  selected (or configured) languages to be used
    source language: #{language.source_language_available_str}
    target languages: #{language.translation_languages_selected_that_are_available.inspect}

  WARNING: this action assumes (and places) this project is under po4a
  (translation) management. It will create sub-directories for the
  selected (or configured) target languages:
    #{language.translation_languages_selected_that_are_available.inspect}
  & the po4a configuration file: #{filename.po4a_cfg}
  in the current directory:
    #{Dir.pwd}
  It will populate the sub-directories with translation files created from
  the pot and po files found under the corresponding language
  sub-directories, (under #{dir.pot}/ & #{dir.po}/).
  (OVERWRITING any existing translated .ssm .sst .ssi files
  in language subdirectories that are not under po4a management).

  You should backup the current directory:
    #{Dir.pwd}

#{warn_and_proceed?}
        WOK
      when :clean
        selections=:strict
        <<-WOK
#{project_details.setup_project}
  "--#{selection}" selected - #{selection} #{project_details.name}
#{warn_and_proceed?}
        WOK
      when :distclean
        selections=:strict
        <<-WOK
#{project_details.setup_project}
  "--#{selection}" selected - #{selection} #{project_details.name}
  WARNING: this action assumes (and places) this project is under po4a
  (translation) management. It will remove the sub-directories (if they exist):
    #{language.possible_translations.inspect}

    #{language.translation_languages_selected_that_are_available.inspect}
  & file: #{filename.po4a_cfg}
  in the current directory:
    #{Dir.pwd}
  Note: these sub-directories & the config file #{filename.po4a_cfg}
  should be auto-generated from pot and po files if this project translation
  is under po4a management.
  This query is to give you the chance to make sure you know what you are doing.
#{warn_and_proceed?}
        WOK
      when :rebuild
        selections=:strict
        <<-WOK
#{project_details.setup_project}
  "--#{selection}" selected - #{selection} #{project_details.name}
  WARNING: this action assumes (and places) this project is under po4a
  (translation) management. It will destroy/clobber and then create again the
  sub-directories:
    #{language.translation_languages_selected_that_are_available.inspect}
  populating them with translation files created from the pot and po files
  found under the corresponding language sub-directories in (#{dir.pot}/
  & #{dir.po}/).
  It will also generate the file: #{filename.po4a_cfg}
  These actions will be taken in the current directory:
    #{Dir.pwd}
  This query is to give you the chance to make sure you know what you are doing.
#{warn_and_proceed?}
        WOK
      else
        selections=:strict
        <<-WOK
#{project_details.setup_project}
  Default action selected - "#{selection} #{project_details.name}"
#{warn_and_proceed?}
        WOK
      end
    else
      selections=:strict
      <<-WOK
#{project_details.setup_project}
  Default action selected - "install and to setup #{project_details.name}"
#{warn_and_proceed?}
      WOK
    end
    exit unless query.answer?(ans)
  end
  def project_help
    puts <<-WOK
#{project_details.name}
#{project_details.setup_project}

This setup file is primarily to assist with having sisu markup files under po4a
translation management. It assumes that the source language files are placed
under the sub-directory identifying the source language set, which is currently
#{language.source_language_selected}
The files there are used to make the source translation file in the directory #{dir.pot}/
Which is then used to create files for translation under the directory #{dir.po}/
in sub-directories bearing the translation languages ISO code.

The current language translation selection is:  #{translation_languages_selected_str}
The languages selected are located in the file: #{filename.languages_src_tgt}

sisu available language list: #{sisu_languages_available_str}

    WOK
  end
  self
end

#poObject



180
181
182
# File 'lib/sisu/sisu_thor_lib.rb', line 180

def po
  po4a_ + 'po'
end

#po4a_Object



174
175
176
# File 'lib/sisu/sisu_thor_lib.rb', line 174

def po4a_
  'po4a/' # ''
end

#po4a_cfgObject



165
166
167
# File 'lib/sisu/sisu_thor_lib.rb', line 165

def po4a_cfg
  'po4a.cfg'
end

#po4a_cfg_fileObject



342
343
344
# File 'lib/sisu/sisu_thor_lib.rb', line 342

def po4a_cfg_file
  File.open("#{Dir.pwd}/#{filename.po4a_cfg}",'w')
end

#po4a_createObject



345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/sisu/sisu_thor_lib.rb', line 345

def po4a_create
  def configure #po4a_cfg
    po4a_cfg_arr=[]
    po4a_cfg_arr \
      << "[po4a_langs] #{language.translation_languages_selected_that_are_available_str}"
    po4a_cfg_arr \
      << "[po4a_paths] #{dir.pot}/$master.pot $lang:#{dir.po}/$lang/$master.po"
    files_src.ssm.each do |file_src|
      file_src_fn=file_src.gsub(/#{language.source_language_selected}\//,'')
      po4a_cfg_arr \
        << "[type: text] #{file_src} $lang:$lang/#{file_src_fn}"
    end
    files_src.sst.each do |file_src|
      file_src_fn=file_src.gsub(/#{language.source_language_selected}\//,'')
      po4a_cfg_arr \
        << "[type: text] #{file_src} $lang:$lang/#{file_src_fn}"
    end
    files_src.ssi.each do |file_src|
      file_src_fn=file_src.gsub(/#{language.source_language_selected}\//,'')
      po4a_cfg_arr \
        << "[type: text] #{file_src} $lang:$lang/#{file_src_fn}"
    end
    file=po4a_cfg_file
    po4a_cfg_arr.each do |txt|
    puts txt
      file << txt << "\n"
    end
    file.close
    cmd='po4a --keep 0 ' \
    + po4a_flags.normal + ' ' \
    + filename.po4a_cfg
    #cmd='po4a --keep 0 --no-backups --package-name ' \
    #+ 'sisu-manual' + ' ' \
    #+ po4a_flags.normal + ' ' \
    #+ filename.po4a_cfg
    system(cmd); puts cmd
  end
  self
end

#po4a_flagsObject



188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/sisu/sisu_thor_lib.rb', line 188

def po4a_flags
  def debug
    '-d -v'
  end
  def normal
    ''
  end
  def quiet
    '-q'
  end
  self
end

#posible_translations_strObject



322
323
324
# File 'lib/sisu/sisu_thor_lib.rb', line 322

def posible_translations_str
  language.posible_translations.join(' ')
end

#possible_translationsObject



307
308
309
# File 'lib/sisu/sisu_thor_lib.rb', line 307

def possible_translations
  sisu_languages_available -  [source_language_selected]
end

#potObject



177
178
179
# File 'lib/sisu/sisu_thor_lib.rb', line 177

def pot
  po4a_ + 'pot'
end

#projectObject



384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'lib/sisu/sisu_thor_lib.rb', line 384

def project
  def make
    dir_mk(dir.pot)
    language.translation_languages_selected_that_are_available.each do |lang_dir|
      dir_lang="#{Dir.pwd}/#{dir.po}/#{lang_dir}"
      dir_mk(dir_lang)
    end
    po4a_create.configure
  end
  def clean
    #rm -f po/*/*.po~
    #rm -rf ../build
    FileUtils.rm_f Dir.glob("./#{dir.po}/*/*.po~")
  end
  def distclean
    #rm -f po4a.cfg
    #rm -rf $(LANGUAGES)
    FileUtils::rm_f(filename.po4a_cfg)
    FileUtils::rm_r(language.possible_translations,:force => true)
  end
  self
end

#project_detailsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sisu/sisu_thor_lib.rb', line 5

def project_details
  def name
    'SiSU translations under po4a management'
  end
  def name_warning
    <<-WOK
#{name}

WARNING all sisu markup files (.ssm, .sst, .ssi) in languages other than #{language.source_language_selected}
are managed by po4a, through translations of the source language to other languages.

#{language.info_on_selection}
    WOK
  end
  def setup_project
    "Setup file for placing #{name}"
  end
  self
end

#project_helpObject



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/sisu/sisu_thor_lib.rb', line 129

def project_help
  puts <<-WOK
#{project_details.name}
#{project_details.setup_project}

This setup file is primarily to assist with having sisu markup files under po4a
translation management. It assumes that the source language files are placed
under the sub-directory identifying the source language set, which is currently
#{language.source_language_selected}
The files there are used to make the source translation file in the directory #{dir.pot}/
Which is then used to create files for translation under the directory #{dir.po}/
in sub-directories bearing the translation languages ISO code.

The current language translation selection is:  #{translation_languages_selected_str}
The languages selected are located in the file: #{filename.languages_src_tgt}

sisu available language list: #{sisu_languages_available_str}

  WOK
end

#pwdObject



171
172
173
# File 'lib/sisu/sisu_thor_lib.rb', line 171

def pwd
  Dir.pwd
end

#quietObject



195
196
197
# File 'lib/sisu/sisu_thor_lib.rb', line 195

def quiet
  '-q'
end

#readmeObject



152
153
154
# File 'lib/sisu/sisu_thor_lib.rb', line 152

def readme
  system(%{ruby ../../../../../bin/sisu6 --txt -v --no-manifest --dump='../../../../../..' en/README.ssm})
end

#setup_projectObject



19
20
21
# File 'lib/sisu/sisu_thor_lib.rb', line 19

def setup_project
  "Setup file for placing #{name}"
end

#sisu_languages_availableObject



304
305
306
# File 'lib/sisu/sisu_thor_lib.rb', line 304

def sisu_languages_available
  $SiSU_Language_Codes.language_list.codes
end

#sisu_languages_available_strObject



319
320
321
# File 'lib/sisu/sisu_thor_lib.rb', line 319

def sisu_languages_available_str
  language.sisu_languages_available.join(' ')
end

#source_language_availableObject



276
277
278
# File 'lib/sisu/sisu_thor_lib.rb', line 276

def source_language_available
  [source_language_selected] & sisu_languages_available
end

#source_language_available_strObject



313
314
315
# File 'lib/sisu/sisu_thor_lib.rb', line 313

def source_language_available_str
  source_language_available.join
end

#source_language_selected(src = nil) ⇒ Object



250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/sisu/sisu_thor_lib.rb', line 250

def source_language_selected(src=nil)
  @@source=if not @@source.nil? \
  and @@source.is_a?(String) \
  and @@source =~/\w{2,4}/
    @@source
  elsif (src \
  && src.is_a?(String) \
  && src.length > 1)
    src
  else
    src=languages_from_file.language_source
  end
end

#ssiObject



334
335
336
# File 'lib/sisu/sisu_thor_lib.rb', line 334

def ssi
  Dir.glob("#{language.source_language_selected}/*.ssi").sort
end

#ssmObject



328
329
330
# File 'lib/sisu/sisu_thor_lib.rb', line 328

def ssm
  Dir.glob("#{language.source_language_selected}/*.ssm").sort
end

#sstObject



331
332
333
# File 'lib/sisu/sisu_thor_lib.rb', line 331

def sst
  Dir.glob("#{language.source_language_selected}/*.sst").sort
end

#translation_languages_selected(targets = nil) ⇒ Object

translation_languages



263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/sisu/sisu_thor_lib.rb', line 263

def translation_languages_selected(targets=nil) #translation_languages
  @@targets=if not @@targets.nil? \
  and @@targets.is_a?(Array) \
  and @@targets.length > 0
    @@targets
  elsif (targets \
  && targets.is_a?(Array) \
  && targets.length > 0)
    targets
  else
    targets=languages_from_file.language_targets
  end
end

#translation_languages_selected_strObject



310
311
312
# File 'lib/sisu/sisu_thor_lib.rb', line 310

def translation_languages_selected_str
  language.translation_languages_selected.join(' ')
end

#translation_languages_selected_that_are_availableObject



279
280
281
# File 'lib/sisu/sisu_thor_lib.rb', line 279

def translation_languages_selected_that_are_available
  translation_languages_selected & sisu_languages_available
end

#translation_languages_selected_that_are_available_strObject



316
317
318
# File 'lib/sisu/sisu_thor_lib.rb', line 316

def translation_languages_selected_that_are_available_str
  language.translation_languages_selected_that_are_available.join(' ')
end

#warn_and_proceed?Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/sisu/sisu_thor_lib.rb', line 25

def warn_and_proceed?
  '*WARNING* this software module creates, destroys, overwrites directories' + "\n" \
  + '*WARNING*: Use this Software at your own risk!'
end