diff options
| author | Ralph Amissah <ralph@amissah.com> | 2014-12-30 18:59:26 -0500 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2015-01-07 22:42:40 -0500 | 
| commit | dd224ef3679701304003b60ebfbf7789a0edc1cb (patch) | |
| tree | 62f8e429d7f07e748f22fab0d28017f036613af4 | |
| parent | d: po4a, stub for auto-translate (diff) | |
d: po4a, reorganize a bit
| -rw-r--r-- | lib/sisu/develop/po4a.rb | 176 | 
1 files changed, 95 insertions, 81 deletions
| diff --git a/lib/sisu/develop/po4a.rb b/lib/sisu/develop/po4a.rb index 3a93c7fd..4b41f1da 100644 --- a/lib/sisu/develop/po4a.rb +++ b/lib/sisu/develop/po4a.rb @@ -64,7 +64,7 @@ module SiSU_Po4a    include SiSU_Param    class Source      @@opt_src,@@opt_trn,@@opt_src_,@@opt_trn_,@@md_src,@@md_trn= -      nil,nil,nil,nil,nil,nil +          nil,      nil,       nil,       nil,     nil,     nil      @@auto_translation_ = :go      def initialize(opt,fn=nil)        @opt,@fn=opt,fn @@ -86,6 +86,95 @@ module SiSU_Po4a          @@md_src=SiSU_Param::Parameters.new(opt).get        end      end +    def wrap_width_set(md,env) +      if defined? md.make.plaintext_wrap \ +      and md.make.plaintext_wrap +        md.make.plaintext_wrap +      elsif defined? env.plaintext_wrap \ +      and env.plaintext_wrap +        env.plaintext_wrap +      else 78 +      end +    end +    def process_file(md,env,file,wrap_width,fn) +      unless @opt.act[:quiet][:set]==:on +        tool=(@opt.act[:verbose][:set]==:on \ +        || @opt.act[:verbose_plus][:set]==:on \ +        || @opt.act[:maintenance][:set]==:on) \ +        ? "#{env.program.text_editor} #{file.output_path.pot.dir}/" +        : @opt.fns +        (@opt.act[:verbose][:set]==:on \ +        || @opt.act[:verbose_plus][:set]==:on \ +        || @opt.act[:maintenance][:set]==:on) \ +        ? SiSU_Screen::Ansi.new( +            @opt.act[:color_state][:set], +            'Pot po4a', +            tool +          ).green_hi_blue +        : SiSU_Screen::Ansi.new( +            @opt.act[:color_state][:set], +            'Pot po4a', +            tool +          ).green_title_hi +        if (@opt.act[:verbose][:set]==:on \ +        || @opt.act[:verbose_plus][:set]==:on \ +        || @opt.act[:maintenance][:set]==:on) +          SiSU_Screen::Ansi.new( +            @opt.act[:color_state][:set], +            @opt.fns, +            file.output_path.pot.dir +          ).flow +        end +      end +      if @opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \ +      or @opt.f_pth[:lng] !=@opt.lng_base +        opt_lang_trn_fn=fn +        @ao_arr_lang_trans= +          SiSU_AO::Source.new(@opt,opt_lang_trn_fn,:po4a).get # ao file drawn here +        opt_lang_src_fn=(fn =~/\S+?~\S{2}(?:_\S{2})?\.ss[mti]/) \ +        ? (fn.gsub(/(\S+?)~\S{2}(?:_\S{2})?(\.ss[mti])/,'\1\2')) #check i +        : fn +        transdir,srcdir=Dir.pwd,Dir.pwd +        if Dir.pwd.to_s =~/\/#{@lang_regx}$/ +          transdir=Dir.pwd +          srcdir=transdir. +            gsub(/\/#{@lang_regx}$/, +              "/#{@opt.lng_base}") +          if FileTest.directory?(srcdir) +            Dir.chdir(srcdir) +          end +        else nil +        end +        if FileTest.file?("#{srcdir}/#{opt_lang_src_fn}") +          @ao_arr_lang_src= +            SiSU_AO::Source.new( +              @@opt_src, +              opt_lang_src_fn, +              :po4a +            ).get # ao file drawn here +        else +          puts "no identified source document" +          exit +        end +        Dir.chdir(transdir) if transdir +      else +        @ao_arr_lang_src= +          SiSU_AO::Source.new( +            @opt, +            fn, +            :po4a +          ).get # ao file drawn here +        @ao_arr_lang_trans=nil +      end +      SiSU_Po4a::Source::Scroll.new( +        fn, +        @ao_arr_lang_src, +        @ao_arr_lang_trans, +        @@md_src, +        @@md_trn, +        wrap_width +      ).songsheet +    end      def read        begin          src={} @@ -97,86 +186,11 @@ module SiSU_Po4a            [@opt.fns]          end          md=SiSU_Param::Parameters.new(@opt).get +        env=SiSU_Env::InfoEnv.new(@opt.fns) +        file=SiSU_Env::FileOp.new(md) +        wrap_width=wrap_width_set(md,env)          src[:files].each do |fn| -          env=SiSU_Env::InfoEnv.new(@opt.fns) -          file=SiSU_Env::FileOp.new(md) -          m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/ #watch added match for sss -          @fnn,@fnb,@fnt=fn[m,1],fn[m,2],fn[m,3] -          unless @opt.act[:quiet][:set]==:on -            tool=(@opt.act[:verbose][:set]==:on \ -            || @opt.act[:verbose_plus][:set]==:on \ -            || @opt.act[:maintenance][:set]==:on) \ -            ? "#{env.program.text_editor} #{file.output_path.pot.dir}/" -            : @opt.fns -            (@opt.act[:verbose][:set]==:on \ -            || @opt.act[:verbose_plus][:set]==:on \ -            || @opt.act[:maintenance][:set]==:on) \ -            ? SiSU_Screen::Ansi.new( -                @opt.act[:color_state][:set], -                'Pot po4a', -                tool -              ).green_hi_blue -            : SiSU_Screen::Ansi.new( -                @opt.act[:color_state][:set], -                'Pot po4a', -                tool -              ).green_title_hi -            if (@opt.act[:verbose][:set]==:on \ -            || @opt.act[:verbose_plus][:set]==:on \ -            || @opt.act[:maintenance][:set]==:on) -              SiSU_Screen::Ansi.new( -                @opt.act[:color_state][:set], -                @opt.fns, -                file.output_path.pot.dir -              ).flow -            end -          end -          if @opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \ -          or @opt.f_pth[:lng] !=@opt.lng_base -            opt_lang_trn_fn=fn -            @ao_array_lang_translation= -              SiSU_AO::Source.new(@opt,opt_lang_trn_fn,:po4a).get # ao file drawn here -            opt_lang_src_fn=if fn =~/\S+?~\S{2}(?:_\S{2})?\.ss[mti]/ -              fn.gsub(/(\S+?)~\S{2}(?:_\S{2})?(\.ss[mti])/,'\1\2') #check i -            else fn -            end -            transdir,srcdir=Dir.pwd,Dir.pwd -            if Dir.pwd.to_s =~/\/#{@lang_regx}$/ -              transdir=Dir.pwd -              srcdir=transdir.gsub(/\/#{@lang_regx}$/,"/#{@opt.lng_base}") -              if FileTest.directory?(srcdir) -                 Dir.chdir(srcdir) -              end -            else nil -            end -            if FileTest.file?("#{srcdir}/#{opt_lang_src_fn}") -              @ao_array_lang_src= -                SiSU_AO::Source.new(@@opt_src,opt_lang_src_fn,:po4a).get # ao file drawn here -            else -              puts "no identified source document" -              exit -            end -            Dir.chdir(transdir) if transdir -          else -            @ao_array_lang_src= -              SiSU_AO::Source.new(@opt,fn,:po4a).get # ao file drawn here -            @ao_array_lang_translation=nil -          end -          wrap_width=if defined? md.make.plaintext_wrap \ -          and md.make.plaintext_wrap -            md.make.plaintext_wrap -          elsif defined? env.plaintext_wrap \ -          and env.plaintext_wrap -            env.plaintext_wrap -          else 78 -          end -          SiSU_Po4a::Source::Scroll.new( -            fn, -            @ao_array_lang_src, -            @ao_array_lang_translation, -            @@md_src,@@md_trn, -            wrap_width -          ).songsheet +          process_file(md,env,file,wrap_width,fn)          end        rescue          SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do @@ -215,7 +229,7 @@ module SiSU_Po4a          pot=pot_markup(@data_src,@data_trn)          publish(fn,pot)        end -      def extract_endnotes(dob='')                                             #% used for extraction of endnotes from paragraphs +      def extract_endnotes(dob='')               #% used for extraction of endnotes from paragraphs          notes_a=dob.obj.scan(/#{Mx[:en_a_o]}([\d]+\s+.+?)#{Mx[:en_a_c]}/)          ##notes_a=dob.obj.scan(/#{Mx[:en_a_o]}([\d*+]+\s+.+?)#{Mx[:en_a_c]}/)          #notes_b=dob.obj.scan(/#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/) | 
