diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v3/options.rb | 18 | ||||
-rw-r--r-- | lib/sisu/v3/sysenv.rb | 33 |
2 files changed, 27 insertions, 24 deletions
diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index 6626870f..5b179a57 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -62,11 +62,12 @@ module SiSU_commandline require_relative 'sysenv' # sysenv.rb @@base_path=nil class Options - attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:base_path,:base_stub,:paths,:lngs,:f_pth,:pth,:fns,:fnb,:fnc,:fncb,:lng,:what + attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:base_path,:base_stub,:paths,:lngs,:f_pth,:pth,:fns,:fnb,:fnc,:fncb,:lng,:lng_base,:what def initialize(a) - @cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what,@lng,@base_path,@base_stub='','','','','','','','','','','','' + @cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what,@lng,@lng_base,@base_path,@base_stub='','','','','','','','','','','','','' @f_pths,@files,@paths,@mod,@act=Array.new(5){[]} @env=SiSU_Env::Info_env.new + @lng_base=@env.language_default_set @dir_structure_by=SiSU_Env::Env_call.new.output_dir_structure.by? @@base_path ||=Dir.pwd @base_path=@@base_path @@ -134,7 +135,7 @@ module SiSU_commandline end end r=Px[:lng_lst].join('|') - r.gsub!(/\|en\|/,'|') + r.gsub!(/\|#{@lng_base}\|/,'|') @lang_regx=%r{(?:#{r})} z=if find_flag if f.length > 0 @@ -144,7 +145,7 @@ module SiSU_commandline end elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \ && a.inspect =~/"#{@lang_regx}\/?"/ \ - && a.inspect =~/"en\/\S+?\.ss[tm]"/ + && a.inspect =~/"#{@lng_base}\/\S+?\.ss[tm]"/ init_selected_lang_dirs(a) else b end @@ -154,7 +155,7 @@ module SiSU_commandline def init_selected_lang_dirs(a) @z=[] a.each do |y| - if y =~/^en\/(\S+?\.ss[tm])$/ + if y =~/^#{@lng_base}\/(\S+?\.ss[tm])$/ @fn=$1 @z << y elsif y =~/^#{@lang_regx}\/?$/ @@ -219,13 +220,13 @@ module SiSU_commandline l_p elsif x =~/~(#{r})\.ss[tm]/ $1 - else 'en' + else lng_base end lng_is =if l_p l_p elsif x =~/~(#{r})\.ss[tm]/ $1 - else 'en' + else lng_base end f_pths << { pth: pt.split[0].realpath.to_s, @@ -588,6 +589,9 @@ module SiSU_commandline def lng @lng end + def lng_base + @lng_base + end def fns @fns end diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 30ff2e9b..c265b010 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -154,8 +154,8 @@ module SiSU_Env PROCESSING_ENCODING=:processing_encoding PROCESSING_GIT=:processing_git PAPERSIZE=:papersize - LANGUAGE=:language - LANGUAGE_CODE=:language_code + #LANGUAGE=:language + #LANGUAGE_CODE=:language_code MULTILINGUAL=:multilingual BUNDLE=:bundle CONCORD_MAX=:concord_max @@ -198,8 +198,8 @@ module SiSU_Env PROCESSING_GIT => processing_git, #TEXINFO_STUB => 'texinfo', PAPERSIZE => 'A4', #A4, US_letter, book_b5, book_a5, US_legal - LANGUAGE => 'English', - LANGUAGE_CODE => 'en', #change, unecessary duplication though currently used + #LANGUAGE => 'English', + #LANGUAGE_CODE => 'en', #change, unecessary duplication though currently used MULTILINGUAL => false, BUNDLE => false, CONCORD_MAX => 260000, @@ -823,10 +823,9 @@ module SiSU_Env class Standardise_language require_relative 'i18n' # i18n.rb def initialize(l='') - @language=l - if @language.empty? - @language=Info_env.new.defaults[:language] - end + @language=(l.nil? || l.empty?) \ + ? Info_env.new.language_default_set + : l @r=%{(?:#{Px[:lng_lst].join('|')})} @lang_info=SiSU_i18n::Languages.new end @@ -907,19 +906,12 @@ module SiSU_Env lng end def name - #lang(@language)[:n].downcase - #lang[@language][:n].downcase - #language[:n].downcase language[:n].downcase end def title - #lang(@language)[:n] - #lang[@language][:n] language[:n] end def code - #lang[@language][:c] - #lang(@language)[:c] language[:c] end def tex_name @@ -986,12 +978,13 @@ module SiSU_Env @stub_md= @stub_pwd + '/sisu_site_metadata' pt=Pathname.new(Dir.pwd) stub=if output_dir_structure.by_language_code? - stub=if Dir.pwd =~/.+?\/([^\/]+)(?:\/(en|fr|es)$)/ + r=Px[:lng_lst].join('|') + stub=if Dir.pwd =~/.+?\/([^\/]+)(?:\/(#{r})$)/ lng=pt.split[-1].to_s lng_part='/' + lng base=pt.split[0].split[-1].to_s else - lng_part='/' + 'en' #fix default language + lng_part='/' + language_default_set base=pt.split[-1].to_s end base + lng_part @@ -1026,6 +1019,12 @@ module SiSU_Env ? @rc['processing']['concord_max'] \ : (defaults[:concord_max]) end + def language_default_set #set directory (default) language + ((defined? @rc['default']['language']) \ + && @rc['default']['language'] =~/\S+/) \ + ? @rc['default']['language'] \ + : 'en' + end def markup_emphasis if defined? @rc['default']['emphasis'] \ and @rc['default']['emphasis'] \ |