diff options
-rw-r--r-- | data/doc/sisu/CHANGELOG_v6 | 2 | ||||
-rw-r--r-- | lib/sisu/develop/po4a.rb | 74 | ||||
-rw-r--r-- | lib/sisu/develop/se_file_op.rb | 24 |
3 files changed, 99 insertions, 1 deletions
diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index 1d4fe844..22b0ad9c 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -90,7 +90,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.4.0.orig.tar.xz * po4a, reinstate possibility to initialize po4a management of translated marked up documents, i.e. to place translated versions of a sisu document - under po4a management + under po4a management (provide po4a.cfg file) * utils_composite, composite documents (.ssm) extract the list of insert files 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 |