diff options
author | Ralph Amissah <ralph@amissah.com> | 2011-05-04 22:19:42 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2011-05-04 22:41:19 -0400 |
commit | 46eebe8bbf6c0102c2f921f65778a99121c91ff2 (patch) | |
tree | ffd8084f66aa9a7c57eaf24d336ba0501ab9c41f /lib/sisu/v3/sysenv.rb | |
parent | v3: concordance, output path, screen info correction (diff) |
v3: options, language setting, based on directory structure or filename
* affects multiple libraries
Diffstat (limited to 'lib/sisu/v3/sysenv.rb')
-rw-r--r-- | lib/sisu/v3/sysenv.rb | 141 |
1 files changed, 84 insertions, 57 deletions
diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 1b621c61..ac584e80 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -444,7 +444,7 @@ module SiSU_Env end self end - def document_language_versions_found + def document_language_versions_found #REVISIT @fn={} unless (@fns.nil? \ or @fns.empty?) @@ -499,12 +499,12 @@ module SiSU_Env fns_c="#{@fn[:m]}~#{lng.code}.#{@fn[:t]}" fns_l="#{@fn[:m]}~#{lng.name}.#{@fn[:t]}" if FileTest.file?(fns_c) - fn_set_lang=SiSU_Env::Standardise_language.new.file_to_language(fns_c) + fn_set_lang=SiSU_Env::Standardise_language.new.file_to_language(fns_c) #reconsider file_to_language lng=fn_set_lang[:l] fn=SiSU_Env::Env_call.new(fns_c).lang(fn_set_lang[:c]) @m << { m: fn[:manifest], l: lng } elsif FileTest.file?(fns_l) - fn_set_lang=SiSU_Env::Standardise_language.new.file_to_language(fns_l) + fn_set_lang=SiSU_Env::Standardise_language.new.file_to_language(fns_l) #reconsider file_to_language @fnl=dir.i18n.lang_filename(fn_set_lang[:c]) fn=SiSU_Env::Env_call.new(fns_l).lang(fn_set_lang[:c]) @m << { m: fn[:manifest], l: lng } @@ -796,48 +796,67 @@ module SiSU_Env @language=Info_env.new.defaults[:language] end end - def language #use ISO_639-2 + def language lang={} case @language - when /American|^us$/i; d,c,l=false,'en','American English' #depreciated, see iso 639-2 - when /English|^en$/i; d,c,l=false,'en','English' - when /French|Francais|^fr$/i; d,c,l=false,'fr','French' - when /German|^de$/i; d,c,l=false,'de','German' - when /Italian|^it$/i; d,c,l=false,'it','Italian' - when /Spanish|Espanol|^es$/i; d,c,l=false,'es','Spanish' - when /Brazilian(?: Portuguese)?|^br$/i; d,c,l=false,'pt','Brazilian Portuguese' #depreciated, see iso 639-2 - when /Portuguese|^pt$/i; d,c,l=false,'pt','Portuguese' - when /Swedish|Svensk|^sv$/i; d,c,l=false,'sv','Swedish' - when /Danish|Dansk|^da$/i; d,c,l=false,'da','Danish' - when /Finnish|Finsk|Suomi|^fi$/i; d,c,l=false,'fi','Finnish' - when /Norwegian|Norsk|^no$/i; d,c,l=false,'no','Norwegian' - when /Icelandic|^is$/i; d,c,l=false,'is','Icelandic' - when /Dutch|^nl$/i; d,c,l=false,'nl','Dutch' - when /Estonian|^et$/i; d,c,l=false,'et','Estonian' - when /Hungarian|^hu$/i; d,c,l=false,'hu','Hungarian' - when /Polish|^pl$/i; d,c,l=false,'pl','Polish' - when /Romanian|^ro$/i; d,c,l=false,'ro','Romanian' - when /Russian|^ru$/i; d,c,l=false,'ru','Russian' - when /Greek|^el$/i; d,c,l=false,'el','Greek' - when /Ukranian|^uk$/i; d,c,l=false,'uk','Ukranian' - when /Turkish|^tr$/i; d,c,l=false,'tr','Turkish' - #when /Serbian/i; d,c,l=false,'', 'Serbian' - #when /Welsh/i; d,c,l=false,'', 'Welsh' - #when /Basque/i; d,c,l=false,'', 'Basque' - #when /Breton/i; d,c,l=false,'', 'Breton' - #when /Catalan/i; d,c,l=false,'', 'Catalan' - #when /Galician/i; d,c,l=false,'', 'Galician' - #when /Saa?mi/i; d,c,l=false,'', 'Saami' - #when /Hebrew/i; d,c,l=false,'', 'Hebrew' - #when /Latin/i; d,c,l=false,'', 'Latin' - #when /Esperanto/i; d,c,l=false,'', 'Esperanto' - when /Slovenian|^sl$/i; d,c,l=false,'sl','Slovenian' - when /Croatian|^hr$/i; d,c,l=false,'hr','Croatian' - when /Slovak(?:ian)?|^sk$/i; d,c,l=false,'sk','Slovakian' - when /Czech|^cs$/i; d,c,l=false,'cs','Czech' - when /Bulgarian|^bg$/i; d,c,l=false,'bg','Bulgarian' - else d,c,l=true,'en','English (default)' - #else d,c,l=true,'xx','Default' + when /^am$|Amharic/i; d,c,l=false,'am','Amharic' + when /^bg$|Bulgarian/i; d,c,l=false,'bg','Bulgarian' + when /^br$|Breton/i; d,c,l=false,'br','Breton' + when /^ca$|Catalan/i; d,c,l=false,'ca','Catalan' + when /^cs$|Czech/i; d,c,l=false,'cs','Czech' + when /^cy$|Welsh/i; d,c,l=false,'cy','Welsh' + when /^da$|Danish|Dansk/i; d,c,l=false,'da','Danish' + when /^de$|German/i; d,c,l=false,'de','German' + when /^el$|Greek/i; d,c,l=false,'el','Greek' + when /^en$|English/i; d,c,l=false,'en','English' + when /^eo$|Esperanto/i; d,c,l=false,'eo','Esperanto' + when /^es$|Spanish|Espanol/i; d,c,l=false,'es','Spanish' + when /^et$|Estonian/i; d,c,l=false,'et','Estonian' + when /^eu$|Basque/i; d,c,l=false,'eu','Basque' + when /^fi$|Finnish|Finsk|Suomi/i; d,c,l=false,'fi','Finnish' + when /^fr$|French|Francais/i; d,c,l=false,'fr','French' + when /^ga$|Irish/i; d,c,l=false,'ga','Irish' + when /^gl$|Galician/i; d,c,l=false,'gl','Galician' + when /^he$|Hebrew/i; d,c,l=false,'he','Hebrew' + when /^hi$|Hindi/i; d,c,l=false,'hi','Hindi' + when /^hr$|Croatian/i; d,c,l=false,'hr','Croatian' + when /^hy$|Armenian/i; d,c,l=false,'hy','Armenian' + when /^ia$|Interlingua/i; d,c,l=false,'ia','Interlingua' + when /^is$|Icelandic/i; d,c,l=false,'is','Icelandic' + when /^it$|Italian/i; d,c,l=false,'it','Italian' + when /^la$|Latin/i; d,c,l=false,'la','Latin' + when /^lo$|Lao/i; d,c,l=false,'lo','Lao' + when /^lt$|Lithuanian/i; d,c,l=false,'lt','Lithuanian' + when /^lv$|Latvian/i; d,c,l=false,'lv','Latvian' + when /^ml$|Malayalam/i; d,c,l=false,'ml','Malayalam' + when /^mr$|Marathi/i; d,c,l=false,'mr','Marathi' + when /^nl$|Dutch/i; d,c,l=false,'nl','Dutch' + when /^no$|Norwegian|Norsk/i; d,c,l=false,'no','Norwegian' + when /^nn$|Norwegian Nynorsk/i; d,c,l=false,'nn','Norwegian Nynorsk' + when /^oc$|Occitan/i; d,c,l=false,'oc','Occitan' + when /^pl$|Polish/i; d,c,l=false,'pl','Polish' + when /^pt$|Portuguese/i; d,c,l=false,'pt','Portuguese' + when /^pt_BR$|Portuguese Brazil/i; d,c,l=false,'pt_BR','Portuguese Brazil' + when /^ro$|Romanian/i; d,c,l=false,'ro','Romanian' + when /^ru$|Russian/i; d,c,l=false,'ru','Russian' + when /^sa$|Sanskrit/i; d,c,l=false,'sa','Sanskrit' + when /^se$|Sami/i; d,c,l=false,'se','Sami' + when /^sk$|Slovak/i; d,c,l=false,'sk','Slovak' + when /^sl$|Slovenian/i; d,c,l=false,'sl','Slovenian' + when /^sq$|Albanian/i; d,c,l=false,'sq','Albanian' + when /^sr$|Serbian/i; d,c,l=false,'sr','Serbian' + when /^sv$|Swedish|Svensk/i; d,c,l=false,'sv','Swedish' + when /^ta$|Tamil/i; d,c,l=false,'ta','Tamil' + when /^te$|Telugu/i; d,c,l=false,'te','Telugu' + when /^th$|Thai/i; d,c,l=false,'th','Thai' + when /^tk$|Turkmen/i; d,c,l=false,'tk','Turkmen' + when /^tr$|Turkish/i; d,c,l=false,'tr','Turkish' + when /^uk$|Ukranian/i; d,c,l=false,'uk','Ukranian' + when /^ur$|Urdu/i; d,c,l=false,'ur','Urdu' + #when /^us$|/i; d,c,l=false,'us','' + when /^vi$|Vietnamese/i; d,c,l=false,'vi','Vietnamese' + else d,c,l=true,'en','English (default)' + #else d,c,l=true,'xx','Default' end lang[:d],lang[:c],lang[:l]=d,c,l lang @@ -851,7 +870,7 @@ module SiSU_Env def code language[:c] end - def file_to_language(file) + def file_to_language(file) # used, fix and remove m=/.+?\~(\w{2,3})\.(?:-|ssm\.)?sst$/ @language=if file =~m ; file[m,1] else '' @@ -859,7 +878,15 @@ module SiSU_Env language end def codes - codes=['us','en','fr','de','it','es','br','pt','sv','da','fi','no','is','nl','et','hu','pl','ro','ru','el','uk','tr','sk','hr','sl','cs','bg'] # remove us and br see iso-639-2 + # Language List po4a + # <http://www.debian.org/international/l10n/po/> + # Px[:lng_lst]=%w[am bg bn br ca cs cy da de el en eo es et eu fi fr ga gl he hi hr hy ia is it la lo lt lv ml mr nl nn no oc pl pt pt_BR ro ru sa se sk sl sq sr sv ta te th tk tr uk ur us vi] + # see polyglossia for subset + # <http://mirrors.ctan.org/macros/xetex/latex/polyglossia/polyglossia.pdf> + # also note ISO_639-2 + # <http://en.wikipedia.org/wiki/ISO_639-2> + # <http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes> + Px[:lng_lst] # constants.rb end end class Info_env < Env_call @@ -3382,14 +3409,9 @@ WOK end self end - def lang_part - (@md.opt.f_pth[:lng]) \ - ? @md.opt.f_pth[:lng] \ - : @md.i18n[0] - end def set_path_abc(ft) if @env.output_dir_structure.by_language_code? - "#{output_path.base}/#{lang_part}/#{ft}" + "#{output_path.base}/#{@md.opt.lng}/#{ft}" elsif @env.output_dir_structure.by_filetype? "#{output_path.base}/#{ft}" else @@ -3398,14 +3420,14 @@ WOK end def set_path_ab(ft) if @env.output_dir_structure.by_language_code? - "#{output_path.base}/#{lang_part}/#{ft}" + "#{output_path.base}/#{@md.opt.lng}/#{ft}" else "#{output_path.base}/#{ft}" end end def set_path_ab_src(ft) if @env.output_dir_structure.by_language_code? - "#{output_path.base}/#{ft}/#{lang_part}" + "#{output_path.base}/#{ft}/#{@md.opt.lng}" else "#{output_path.base}/#{ft}" end @@ -3429,14 +3451,14 @@ WOK path=set_path_ab_src(ft) end def po - "#{output_path.base}/po4a/#{@md.fnb}/po/#{lang_part}" + "#{output_path.base}/po4a/#{@md.fnb}/po/#{@md.opt.lng}" end def pot "#{output_path.base}/po4a/#{@md.fnb}/pot" end def po_git ft=Gt[:po] - pth=@env.processing_path.git + '/' + @md.fnb + '/' + ft + '/' + lang_part + pth=@env.processing_path.git + '/' + @md.fnb + '/' + ft + '/' + @md.opt.lng mkdir_p(pth) unless FileTest.directory?(pth) pth end @@ -3512,6 +3534,9 @@ WOK ft='sitemaps' path=set_path_ab(ft) end + def sqlite + path=output_path.base + end self end end @@ -3638,8 +3663,10 @@ WOK @@pwd ||=Dir.pwd @pwd=Dir.pwd @env=SiSU_Env::Info_env.new - m=/.+\/(?:src\/)?(\S+)/m # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m - @pwd_stub=@pwd[m,1] + pt=Pathname.new(@pwd) + r=Px[:lng_lst].join('|') + u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/ + @pwd_stub=pt.realpath.to_s[u,1] @rc=@@rc ||=Get_init.instance.sisu_yaml.rc @defaults=Info_env.new.defaults end |