d: po4a, provide po4a.cfg file
authorRalph Amissah <ralph@amissah.com>
Tue, 13 Jan 2015 22:04:45 +0000 (17:04 -0500)
committerRalph Amissah <ralph@amissah.com>
Tue, 20 Jan 2015 04:46:16 +0000 (23:46 -0500)
data/doc/sisu/CHANGELOG_v6
lib/sisu/develop/po4a.rb
lib/sisu/develop/se_file_op.rb

index 1d4fe844075a15833826a3eb23edbef14fa2c14b..22b0ad9cbf059d82eeb11a14f47016e1c971b42c 100644 (file)
@@ -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
 
index 5cc368865e5edf596e22abfdc6465db3ea72c545..285132a5ae72313e96e8f87fe6b9f8f17ed3fdcf 100644 (file)
@@ -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
index 22a6f778354dc13d2c1b0d7166e2eba46be0a732..6b1346353161594bd914f4f3fc19c9b4ecabaab9 100644 (file)
@@ -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