aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/sysenv.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2011-05-04 23:02:26 -0400
committerRalph Amissah <ralph@amissah.com>2011-05-04 23:08:55 -0400
commit8ece506490b3f52aa3cf241a3b3009abc8027eae (patch)
tree1276a1f60200302e4d78445b8599ec63cd931115 /lib/sisu/v3/sysenv.rb
parentv3: options, language setting, based on directory structure or filename (diff)
v3: i18n, sysenv, options, language setting changes
* must be able to set language at options stage from filename or directory * affects many files * old i18n more appropriately renamed prog_text_translation
Diffstat (limited to 'lib/sisu/v3/sysenv.rb')
-rw-r--r--lib/sisu/v3/sysenv.rb156
1 files changed, 91 insertions, 65 deletions
diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb
index ac584e80..f757233f 100644
--- a/lib/sisu/v3/sysenv.rb
+++ b/lib/sisu/v3/sysenv.rb
@@ -500,7 +500,7 @@ module SiSU_Env
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) #reconsider file_to_language
- lng=fn_set_lang[:l]
+ lng=fn_set_lang[:n]
fn=SiSU_Env::Env_call.new(fns_c).lang(fn_set_lang[:c])
@m << { m: fn[:manifest], l: lng }
elsif FileTest.file?(fns_l)
@@ -790,86 +790,110 @@ module SiSU_Env
end
end
class Standardise_language
+ require_relative 'i18n' # i18n.rb
def initialize(l='')
@language=l
if @language.empty?
@language=Info_env.new.defaults[:language]
end
+ @r=%{(?:#{Px[:lng_lst].join('|')})}
+ @lang_info=SiSU_i18n::Languages.new
+ end
+ def lang_lst # from i18n
+ @lang_info.language.list
+ end
+ def lang(l='') # from i18n
+ x=if l =~/^#{@r}$/
+ @lang_info.language.list[l]
+ elsif @language =~/^#{@r}$/
+ @lang_info.language.list[@language]
+ else nil
+ end
end
def language
- lang={}
+ lng={}
case @language
- 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
+ when /^am$|Amharic/i; d,c,l=false,lang_lst['am'][:c], lang_lst['am'][:n]
+ when /^bg$|Bulgarian/i; d,c,l=false,lang_lst['bg'][:c], lang_lst['bg'][:n]
+ when /^bn$|Bengali/i; d,c,l=false,lang_lst['bn'][:c], lang_lst['bn'][:n]
+ when /^br$|Breton/i; d,c,l=false,lang_lst['br'][:c], lang_lst['br'][:n]
+ when /^ca$|Catalan/i; d,c,l=false,lang_lst['ca'][:c], lang_lst['ca'][:n]
+ when /^cs$|Czech/i; d,c,l=false,lang_lst['cs'][:c], lang_lst['cs'][:n]
+ when /^cy$|Welsh/i; d,c,l=false,lang_lst['cy'][:c], lang_lst['cy'][:n]
+ when /^da$|Danish|Dansk/i; d,c,l=false,lang_lst['da'][:c], lang_lst['da'][:n]
+ when /^de$|German/i; d,c,l=false,lang_lst['de'][:c], lang_lst['de'][:n]
+ when /^el$|Greek/i; d,c,l=false,lang_lst['el'][:c], lang_lst['el'][:n]
+ when /^en$|English/i; d,c,l=false,lang_lst['en'][:c], lang_lst['en'][:n]
+ when /^eo$|Esperanto/i; d,c,l=false,lang_lst['eo'][:c], lang_lst['eo'][:n]
+ when /^es$|Spanish|Espanol/i; d,c,l=false,lang_lst['es'][:c], lang_lst['es'][:n]
+ when /^et$|Estonian/i; d,c,l=false,lang_lst['et'][:c], lang_lst['et'][:n]
+ when /^eu$|Basque/i; d,c,l=false,lang_lst['eu'][:c], lang_lst['eu'][:n]
+ when /^fi$|Finnish|Finsk|Suomi/i; d,c,l=false,lang_lst['fi'][:c], lang_lst['fi'][:n]
+ when /^fr$|French|Francais/i; d,c,l=false,lang_lst['fr'][:c], lang_lst['fr'][:n]
+ when /^ga$|Irish/i; d,c,l=false,lang_lst['ga'][:c], lang_lst['ga'][:n]
+ when /^gl$|Galician/i; d,c,l=false,lang_lst['gl'][:c], lang_lst['gl'][:n]
+ when /^he$|Hebrew/i; d,c,l=false,lang_lst['he'][:c], lang_lst['he'][:n]
+ when /^hi$|Hindi/i; d,c,l=false,lang_lst['hi'][:c], lang_lst['hi'][:n]
+ when /^hr$|Croatian/i; d,c,l=false,lang_lst['hr'][:c], lang_lst['hr'][:n]
+ when /^hy$|Armenian/i; d,c,l=false,lang_lst['hy'][:c], lang_lst['hy'][:n]
+ when /^ia$|Interlingua/i; d,c,l=false,lang_lst['ia'][:c], lang_lst['ia'][:n]
+ when /^is$|Icelandic/i; d,c,l=false,lang_lst['is'][:c], lang_lst['is'][:n]
+ when /^it$|Italian/i; d,c,l=false,lang_lst['it'][:c], lang_lst['it'][:n]
+ when /^la$|Latin/i; d,c,l=false,lang_lst['la'][:c], lang_lst['la'][:n]
+ when /^lo$|Lao/i; d,c,l=false,lang_lst['lo'][:c], lang_lst['lo'][:n]
+ when /^lt$|Lithuanian/i; d,c,l=false,lang_lst['lt'][:c], lang_lst['lt'][:n]
+ when /^lv$|Latvian/i; d,c,l=false,lang_lst['lv'][:c], lang_lst['lv'][:n]
+ when /^ml$|Malayalam/i; d,c,l=false,lang_lst['ml'][:c], lang_lst['ml'][:n]
+ when /^mr$|Marathi/i; d,c,l=false,lang_lst['mr'][:c], lang_lst['mr'][:n]
+ when /^nl$|Dutch/i; d,c,l=false,lang_lst['nl'][:c], lang_lst['nl'][:n]
+ when /^no$|Norwegian|Norsk/i; d,c,l=false,lang_lst['no'][:c], lang_lst['no'][:n]
+ when /^nn$|Norwegian Nynorsk/i; d,c,l=false,lang_lst['nn'][:c], lang_lst['nn'][:n]
+ when /^oc$|Occitan/i; d,c,l=false,lang_lst['oc'][:c], lang_lst['oc'][:n]
+ when /^pl$|Polish/i; d,c,l=false,lang_lst['pl'][:c], lang_lst['pl'][:n]
+ when /^pt$|Portuguese/i; d,c,l=false,lang_lst['pt'][:c], lang_lst['pt'][:n]
+ when /^pt_BR$|Portuguese Brazil/i; d,c,l=false,lang_lst['pt_BR'][:c], lang_lst['pt_BR'][:n]
+ when /^ro$|Romanian/i; d,c,l=false,lang_lst['ro'][:c], lang_lst['ro'][:n]
+ when /^ru$|Russian/i; d,c,l=false,lang_lst['ru'][:c], lang_lst['ru'][:n]
+ when /^sa$|Sanskrit/i; d,c,l=false,lang_lst['sa'][:c], lang_lst['sa'][:n]
+ when /^se$|Sami/i; d,c,l=false,lang_lst['se'][:c], lang_lst['se'][:n]
+ when /^sk$|Slovak/i; d,c,l=false,lang_lst['sk'][:c], lang_lst['sk'][:n]
+ when /^sl$|Slovenian/i; d,c,l=false,lang_lst['sl'][:c], lang_lst['sl'][:n]
+ when /^sq$|Albanian/i; d,c,l=false,lang_lst['sq'][:c], lang_lst['sq'][:n]
+ when /^sr$|Serbian/i; d,c,l=false,lang_lst['sr'][:c], lang_lst['sr'][:n]
+ when /^sv$|Swedish|Svensk/i; d,c,l=false,lang_lst['sv'][:c], lang_lst['sv'][:n]
+ when /^ta$|Tamil/i; d,c,l=false,lang_lst['ta'][:c], lang_lst['ta'][:n]
+ when /^te$|Telugu/i; d,c,l=false,lang_lst['te'][:c], lang_lst['te'][:n]
+ when /^th$|Thai/i; d,c,l=false,lang_lst['th'][:c], lang_lst['th'][:n]
+ when /^tk$|Turkmen/i; d,c,l=false,lang_lst['tk'][:c], lang_lst['tk'][:n]
+ when /^tr$|Turkish/i; d,c,l=false,lang_lst['tr'][:c], lang_lst['tr'][:n]
+ when /^uk$|Ukranian/i; d,c,l=false,lang_lst['uk'][:c], lang_lst['uk'][:n]
+ when /^ur$|Urdu/i; d,c,l=false,lang_lst['ur'][:c], lang_lst['ur'][:n]
+ when /^us|American$|/i; d,c,l=false,lang_lst['en'][:c], lang_lst['en'][:n]
+ when /^vi$|Vietnamese/i; d,c,l=false,lang_lst['vi'][:c], lang_lst['vi'][:n]
+ else d,c,l=true, lang_lst['en'][:c], lang_lst['en'][:n] #default
+ end
+ lng[:d],lng[:c],lng[:n]=d,c,l
+ lng
end
def name
- language[:l].downcase
+ #lang(@language)[:n].downcase
+ #lang[@language][:n].downcase
+ #language[:n].downcase
+ language[:n].downcase
end
def title
- language[:l]
+ #lang(@language)[:n]
+ #lang[@language][:n]
+ language[:n]
end
def code
+ #lang[@language][:c]
+ #lang(@language)[:c]
language[:c]
end
+ def tex_name
+ language[:xlp]
+ end
def file_to_language(file) # used, fix and remove
m=/.+?\~(\w{2,3})\.(?:-|ssm\.)?sst$/
@language=if file =~m ; file[m,1]
@@ -3663,6 +3687,8 @@ 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})$|$)/