aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/develop/po4a.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/develop/po4a.rb')
-rw-r--r--lib/sisu/develop/po4a.rb74
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/sisu/develop/po4a.rb b/lib/sisu/develop/po4a.rb
index 5cc36886..285132a5 100644
--- a/lib/sisu/develop/po4a.rb
+++ b/lib/sisu/develop/po4a.rb
@@ -63,6 +63,7 @@ module SiSU_Po4a
require_relative 'po4a_set' # po4a_set.rb
include SiSU_Param
require_relative 'object_munge' # object_munge.rb
+ require_relative 'utils_composite' # utils_composite.rb
class Source
include SiSU_Object_Munge
@@opt_src,@@opt_trn,@@opt_src_,@@opt_trn_,@@md_src,@@md_trn=
@@ -190,6 +191,7 @@ module SiSU_Po4a
md=SiSU_Param::Parameters.new(@opt).get
env=SiSU_Env::InfoEnv.new(@opt.fns)
file=SiSU_Env::FileOp.new(md)
+ Po4aCfg.new(@opt,file).po4a_cfg
wrap_width=wrap_width_set(md,env)
src[:files].each do |fn|
process_file(md,env,file,wrap_width,fn)
@@ -1065,6 +1067,78 @@ GSUB
@@endnotes={ para: [], end: [] }
end
end
+ class Po4aCfg
+ include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test
+ def initialize(opt,file)
+ @opt,@file=opt,file
+ end
+ def po4a_cfg_filename
+ 'po4a.cfg'
+ end
+ def dir
+ def pwd
+ Dir.pwd
+ end
+ def po4a_
+ 'po4a/' # ''
+ end
+ def pot
+ po4a_ + 'pot'
+ end
+ def po
+ po4a_ + 'po'
+ end
+ self
+ end
+ def po4a_cfg_file
+ File.open("#{Dir.pwd}/#{po4a_cfg_filename}",'w')
+ end
+ def language
+ def sisu_languages_available
+ Px[:lng_lst]
+ end
+ def translation_languages_selected
+ @opt.act[:po4a_lang_trans][:trn] \
+ ? @opt.act[:po4a_lang_trans][:trn]
+ : []
+ end
+ def translation_languages_available
+ translation_languages_selected & sisu_languages_available
+ end
+ def source_language_selected_str
+ @opt.act[:po4a_lang_trans][:src] \
+ ? @opt.act[:po4a_lang_trans][:src]
+ : 'en'
+ end
+ def translation_languages_available_str
+ translation_languages_available.join(' ')
+ end
+ def translation_languages_selected_str
+ @opt.act[:po4a_lang_trans][:trn].join(' ')
+ end
+ self
+ end
+ def po4a_cfg
+ doc_import_list=composite_and_imported_filenames_array(@opt.fno)
+ po4a_cfg_arr=[]
+ po4a_cfg_arr \
+ << "[po4a_langs] #{language.translation_languages_available_str}"
+ po4a_cfg_arr \
+ << "[po4a_paths] #{dir.pot}/$master.pot $lang:#{dir.po}/$lang/$master.po"
+ doc_import_list.each do |file_src|
+ file_src_fn=
+ file_src.gsub(/#{language.source_language_selected_str}\//,'')
+ po4a_cfg_arr \
+ << "[type: text] #{file_src} $lang:$lang/#{file_src_fn}"
+ end
+ file=@file.write_file.po4a_cfg
+ po4a_cfg_arr.each do |txt|
+ puts txt
+ file << txt << "\n"
+ end
+ file.close
+ end
+ end
class Output <Source
include SiSU_Param
include SiSU_Env