aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-07-30 21:25:48 -0400
committerRalph Amissah <ralph@amissah.com>2013-07-30 21:25:48 -0400
commit363a1c71795d6034a996eb3b4a52b20c6dedca95 (patch)
tree92fcc4c01bdddbe8265c15b8a5aede4d1c4226ef /lib/sisu/v5
parentv4 (v5): misc, minor (diff)
v5: output structure by, add monolingual alt for :filetype & :filename, step 1
Diffstat (limited to 'lib/sisu/v5')
-rw-r--r--lib/sisu/v5/hub.rb1
-rw-r--r--lib/sisu/v5/options.rb26
-rw-r--r--lib/sisu/v5/param.rb11
-rw-r--r--lib/sisu/v5/sysenv.rb48
4 files changed, 72 insertions, 14 deletions
diff --git a/lib/sisu/v5/hub.rb b/lib/sisu/v5/hub.rb
index 8b146d4b..c84c84cd 100644
--- a/lib/sisu/v5/hub.rb
+++ b/lib/sisu/v5/hub.rb
@@ -89,6 +89,7 @@ module SiSU
end
end
class OptionLoopFiles
+ attr_reader :opt
def initialize(opt)
@opt=opt
@r=Px[:lng_lst_rgx]
diff --git a/lib/sisu/v5/options.rb b/lib/sisu/v5/options.rb
index b7bf98a6..031258af 100644
--- a/lib/sisu/v5/options.rb
+++ b/lib/sisu/v5/options.rb
@@ -137,7 +137,7 @@ module SiSU_Commandline
end
end
class Options
- attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:files_mod,:base_path,:base_stub,:sub_location,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod
+ attr_accessor :cmd,:mod,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:base_path,:base_stub,:sub_location,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod
@@act=nil
def initialize(a)
@cmd,@f_pth,@pth,@fno,@fns,@fnb,@fnc,@fng,@fncb,@what,@lng,@lng_base,@base_path,@base_stub,@sub_location='','','','','','','','','','','','','',''
@@ -145,6 +145,7 @@ module SiSU_Commandline
@env=SiSU_Env::InfoEnv.new
@lng_base=@env.language_default_set
@dir_structure_by=SiSU_Env::EnvCall.new.output_dir_structure.by?
+ @lingual=SiSU_Env::EnvCall.new.mono_multi_lingual?
@@sisu_call_origin_path ||=Dir.pwd
@base_path=@@sisu_call_origin_path
r=Px[:lng_lst_rgx]
@@ -217,7 +218,7 @@ module SiSU_Commandline
end
end
end
- r=Px[:lng_lst_rgx].gsub(/\|#{@lng_base}\|/,'|')
+ r=Px[:lng_lst_rgx].gsub(/\|#{lng_base}\|/,'|')
@lang_regx=%r{(?:#{r})}
if find_flag
(f.length > 0) \
@@ -225,7 +226,7 @@ module SiSU_Commandline
: find_all(find_flag,b)
elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \
&& a.inspect =~/"#{@lang_regx}\/?"/ \
- && a.inspect =~/"#{@lng_base}\/\S+?\.ss[tm]"/
+ && a.inspect =~/"#{lng_base}\/\S+?\.ss[tm]"/
init_selected_lang_dirs(a)
else b
end
@@ -235,7 +236,7 @@ module SiSU_Commandline
def init_selected_lang_dirs(a)
@z=[]
a.each do |y|
- if y =~/^#{@lng_base}\/(\S+?\.ss[tm])$/
+ if y =~/^#{lng_base}\/(\S+?\.ss[tm])$/
@fn=$1
@z << y
elsif y =~/^#{@lang_regx}\/?$/
@@ -670,11 +671,28 @@ module SiSU_Commandline
{ bool: false, set: :off, off: off_list}
else { bool: true, set: :na, off: [] }
end
+ act[:default_language]=if mod.inspect =~/"--(?:default-)?language[-=](\S{2})"/
+ { set: :on, code: $1 }
+ elsif lng_base
+ { set: :on, code: lng_base }
+ else { set: :na, code: 'en' }
+ end
+ act[:i18n]=if mod.inspect =~/"(?:--monolingual|--i18n-mono(?:lingual)?)"/ #if monolingual possible outputs output_by :filename & :filetype only, without language code in default language name; give warning of conflict settings if monolingual & :language selected
+ @lingual=:mono
+ { set: :mono }
+ elsif mod.inspect =~/"(?:--multilingual|--i18n-multi(?:lingual)?)"/
+ @lingual=:multi
+ { set: :multi }
+ else { set: :na }
+ end
act[:output_by]=if mod.inspect =~/"--(?:output-)?by-language"/
+ @dir_structure_by=:language
{ set: :language }
elsif mod.inspect =~/"--(?:output-)?by-filename"/
+ @dir_structure_by=:filename
{ set: :filename }
elsif mod.inspect =~/"--(?:output-)?by-filetype"/
+ @dir_structure_by=:filetype
{ set: :filetype }
else { set: :na }
end
diff --git a/lib/sisu/v5/param.rb b/lib/sisu/v5/param.rb
index 18e9721e..0e24b419 100644
--- a/lib/sisu/v5/param.rb
+++ b/lib/sisu/v5/param.rb
@@ -841,16 +841,7 @@ module SiSU_Param
@authors,@topic_register_array,@papersize_array=[],[],[]
@lvs=[nil,0,0,0,0,0,0]
@emphasis_set_to='bold'
- @lang_code_insert=if @opt.act[:output_by][:set]==:language
- ''
- elsif @opt.act[:output_by][:set]==:filetype \
- or @opt.act[:output_by][:set]==:filename
- ".#{@opt.lng}"
- elsif @opt.dir_structure_by ==:language
- ''
- else
- ".#{@opt.lng}"
- end
+ @lang_code_insert=SiSU_Env::FilenameLanguageCodeInsert.new(@opt).language_code_insert
@footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } }
@rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m
@rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/
diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb
index 973e0dcc..dcf0a671 100644
--- a/lib/sisu/v5/sysenv.rb
+++ b/lib/sisu/v5/sysenv.rb
@@ -441,6 +441,32 @@ module SiSU_Env
end
@fnn,@fnb,@fnt,@flv,@fnz=@@fnn,@@fnb,@@fnt,@@flv,@@fnz
end
+ def default_language?
+ if @rc
+ if defined? @rc['language_default'] \
+ && (@rc['language_default'] =~/#{Px[:lng_lst_rgx]}/)
+ @rc['language_default']
+ else
+ 'en'
+ end
+ else
+ 'en'
+ end
+ end
+ def mono_multi_lingual?
+ if @rc
+ if defined? @rc['lingual'] \
+ && (@rc['lingual'] =~/mono(?:lingual)?/)
+ :mono
+ elsif defined? @rc['lingual'] \
+ && (@rc['lingual'] =~/multi(?:lingual)?/)
+ :multi
+ else
+ :multi
+ end
+ else :multi
+ end
+ end
def output_dir_structure
def by?
output_structure=:filename #set default output structure
@@ -5703,6 +5729,28 @@ WOK
self
end
end
+ class FilenameLanguageCodeInsert
+ def initialize(opt,lng=nil)
+ @opt,@lng=opt,lng
+ @opt=opt
+ @lng=lng ||=@opt.lng
+ end
+ def language_code_insert
+ if @opt.dir_structure_by ==:language \
+ or ((@opt.dir_structure_by ==:filetype \
+ || @opt.dir_structure_by ==:filename) \
+ and (@opt.lingual ==:mono \
+ && @opt.lng == @opt.act[:default_language][:code]))
+ ''
+ elsif (@opt.dir_structure_by ==:filetype \
+ || @opt.dir_structure_by ==:filename) \
+ and not @opt.lingual ==:mono
+ ".#{@lng}"
+ else
+ ".#{@lng}"
+ end
+ end
+ end
class CreateFile <InfoEnv #todo unify with FileOp
def initialize(fns)
begin