Class: SiSU_Po4a_Project::Po4aProject

Inherits:
Object
  • Object
show all
Includes:
SiSU_Languages_Selected, SiSU_Response
Defined in:
lib/sisu/src_po4a_share.rb

Instance Method Summary collapse

Methods included from SiSU_Response

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

Methods included from SiSU_Languages_Selected

#language, #sisu_languages_available, #source_language_selected_str, #translation_languages_available, #translation_languages_selected, #translation_languages_selected_str, #translation_languages_selected_that_are_available, #translation_languages_selected_that_are_available_str

Constructor Details

#initialize(opt, file) ⇒ Po4aProject

Returns a new instance of Po4aProject.



153
154
155
# File 'lib/sisu/src_po4a_share.rb', line 153

def initialize(opt,file)
  @opt,@file=opt,file
end

Instance Method Details

#build_src_master_to_pot_and_po_and_srcsObject



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/sisu/src_po4a_share.rb', line 193

def build_src_master_to_pot_and_po_and_srcs
  if SiSU_Sys_Call::SystemCall.new.po4a
    pwd=Dir.pwd
    #cmd='po4a --keep 0 -M UTF-8 --no-backups ' \
    #+ '--package-name ' \
    #+ 'sisu-manual' + ' ' \
    #+ flags.normal + ' ' \
    #+ filename.po4a_cfg
    cmd='po4a --keep 0 -M UTF-8' \
    + flags.normal + ' ' \
    + @file.base_filename.po4a_cfg
    Dir.chdir(@file.output_path.po4a.dir)
    system("
      cd #{@file.output_path.po4a.dir}
      #{cmd}
      cd -
    "); puts cmd
    Dir.chdir(pwd)
  end
end

#cleanObject



245
246
247
248
249
# File 'lib/sisu/src_po4a_share.rb', line 245

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

#debugObject



182
183
184
# File 'lib/sisu/src_po4a_share.rb', line 182

def debug
  '-d -v'
end

#dir_mk(dir) ⇒ Object



236
237
238
239
240
# File 'lib/sisu/src_po4a_share.rb', line 236

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

#distcleanObject



250
251
252
253
254
255
256
# File 'lib/sisu/src_po4a_share.rb', line 250

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

#flagsObject



181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/sisu/src_po4a_share.rb', line 181

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

#gettext_if_any_build_src_trans_poObject



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/sisu/src_po4a_share.rb', line 213

def gettext_if_any_build_src_trans_po
    Dir.chdir(@file.output_path.po4a.dir)
    dirs=Dir['*/']
    dirs_language=[]
    dirs.each do |x|
      dirs_language << x.gsub(/\/$/,'')
    end
    dirs_translation = \
      (language.translation_languages_available & dirs_language)
    files_src=Dir.glob("./#{source_language_selected_str}/*.ss[tmi]")
    dirs_translation.each do |lng|
      files_src.each do |file|
        fn=file.gsub(/\.\/#{source_language_selected_str}\//,'')
        system("
          po4a-gettextize -f text -M utf-8 \
          -m ./#{source_language_selected_str}/#{fn} \
          -l ./#{lng}/#{fn} \
          -p ./po/#{lng}/#{fn}.po
        ")
        puts fn
      end
    end
end

#make_pathsObject



241
242
243
244
# File 'lib/sisu/src_po4a_share.rb', line 241

def make_paths
  dir_mk(@file.output_path.pot.dir)
  dir_mk(@file.output_path.po.dir)
end

#normalObject



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

def normal
  ''
end

#quietObject



188
189
190
# File 'lib/sisu/src_po4a_share.rb', line 188

def quiet
  '-q'
end

#songObject



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/sisu/src_po4a_share.rb', line 156

def song
  make_paths
  if FileTest.directory?(@file.output_path.po4a.dir)
    Dir.chdir(@file.output_path.po4a.dir)
    dirs=Dir['*/']
    dirs_language=[]
    dirs.each do |x|
      dirs_language << x.gsub(/\/$/,'')
    end
    dirs_translation = \
      (language.translation_languages_available & dirs_language)
  end
  if (language.translation_languages_available & [@opt.lng]).length == 1
    puts %{gettext for: #{dirs_translation}
in #{Dir.pwd}}
    ans=response?('gettext?')
    if ans
      gettext_if_any_build_src_trans_po
    end
  end
  ans=response?('build project?')
  if ans
    build_src_master_to_pot_and_po_and_srcs
  end
end