aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2015-01-13 17:04:45 -0500
committerRalph Amissah <ralph@amissah.com>2015-01-19 23:46:16 -0500
commit6ae231652eab49b41d3209960095a67dbd927822 (patch)
treeb0bd56a6397e9f1a95a91a5c60d5d4e39ee68481 /lib
parentbin/sisu-misc-utils + c&d: lib sisu_thor_lib currently only po4a (diff)
d: po4a, provide po4a.cfg file
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/develop/po4a.rb74
-rw-r--r--lib/sisu/develop/se_file_op.rb24
2 files changed, 98 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
diff --git a/lib/sisu/develop/se_file_op.rb b/lib/sisu/develop/se_file_op.rb
index 22a6f778..6b134635 100644
--- a/lib/sisu/develop/se_file_op.rb
+++ b/lib/sisu/develop/se_file_op.rb
@@ -462,6 +462,12 @@ module SiSU_File_Op
fn=base_filename.manifest_txt
make_file(path,fn)
end
+ def po4a_cfg
+ path=output_path.po4a.dir
+ make_path(path)
+ fn=base_filename.po4a_cfg
+ make_file(path,fn)
+ end
def pot
path=output_path.pot.dir
make_path(path)
@@ -1446,6 +1452,9 @@ module SiSU_File_Op
def src
@md.fno
end
+ def po4a_cfg
+ 'po4a.cfg'
+ end
def po #check
(@fno.empty?) \
? (@md.fn[:po])
@@ -1747,6 +1756,21 @@ module SiSU_File_Op
end
self
end
+ def po4a
+ def dir
+ output_path.base.dir + '/' \
+ + Gt[:src] + '/' \
+ + @md.opt.fng + '/po4a'
+ end
+ def url
+ output_path.base.url + '/po4a/' \
+ + @md.fnb
+ end
+ def rcp
+ #p "#{output_path.base.dir}/po4a/#{@md.fnb}"
+ end
+ self
+ end
def po(lng=@md.opt.lng)
@lng=lng
def dir