From d87f4ffff1d3d00f5acf02ebb73dbb85be94ab8e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 17 May 2011 18:07:38 -0400 Subject: v3: options, expand name of source file for selected language directories * only use for single file(name) available in multiple languages e.g. sisu3 -hv en/free_culture.lawrence_lessig.sst es fr * english assumed as default language, make default configurable later * particularly useful for po4a --- lib/sisu/v3/options.rb | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index 30f857f6..aabbd946 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -63,43 +63,35 @@ module SiSU_commandline class Options attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:paths,:lngs,:f_pth,:pth,:fns,:fnb,:fnc,:fncb,:lng,:what def initialize(a) - @a=a + @x=a @cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what,@lng='','','','','','','','','','' @f_pths,@files,@paths,@mod,@act=Array.new(5){[]} @env=SiSU_Env::Info_env.new @dir_structure_by=SiSU_Env::Env_call.new.output_dir_structure.by? r=Px[:lng_lst].join('|') - #r.gsub!(/\|en\|/,'|') + r.gsub!(/\|en\|/,'|') @lang_regx=%r{(?:#{r})} - if a.inspect =~/"(?:-\S|--\S+?)"/ \ - and a.inspect =~/"#{@lang_regx}"/ \ - and a.inspect =~/"en\/\S+?\.ss[tm]"/ - init_po + @a=if a.inspect =~/"(?:-\S+?|--\S+?)"/ \ + && a.inspect =~/"#{@lang_regx}\/?"/ \ + && a.inspect =~/"en\/\S+?\.ss[tm]"/ + init_selected_lang_dirs(a) + else @x end + @a.freeze init end - def init_po - a=@a - if a.inspect =~/"(?:-\S|--\S+?)"/ \ - and a.inspect =~/"#{@lang_regx}"/ \ - and a.inspect =~/"en\/\S+?\.ss[tm]"/ - x,z=[],[] - l=nil - a.each do |y| - if y =~/^(?:-\S|--\S+?)$/ - x << y - elsif y =~/^en\/(\S+?\.ss[tm])$/ - l=$1 - x << y - elsif y =~/^#{@lang_regx}$/ - z = x.dup - z << y + '/' + l - SiSU_commandline::Options.new(z) - z=[] - end + def init_selected_lang_dirs(a) + @z=[] + a.each do |y| + if y =~/^en\/(\S+?\.ss[tm])$/ + @fn=$1 + @z << y + elsif y =~/^#{@lang_regx}\/?$/ + @z << "#{y}/#{@fn}" + else @z << y end end - self + @z end def init a=@a @@ -414,7 +406,8 @@ module SiSU_commandline true else false end - act[:po4a]=if mod.inspect =~/"--po4a"|"--po"/ + act[:po4a]=if cmd =~/P/ \ + or mod.inspect =~/"--po4a"|"--pot?"/ true else false end -- cgit v1.2.3