[Nitro] Localization

rob rob at motionpath.com
Sat Feb 18 06:26:56 EST 2006

Can you please zip up attachments to the list? They get mangled  

I don't think Localization should be in the default pipe, it's very  
easy to change the pipeline if you need it and most of us don't need  
Localization in 90% of our projects. I am against it, but not  
strongly so as it is just as easy for me to remove it from the  
pipeline as it is for you to add it.

On 18 Feb 2006, at 07:46, Michael Fellinger wrote:

> Hey List,
> I've been playing around with localization now for a while and  
> noticedsome, well, a bit annoying problems.First of all,  
> Localization is not in the default-pipeline. I know thisdecision  
> was made a while ago and just want to confirm that this isreally  
> what everyone wants.IMHO localization is one of the important  
> things every moderatly largeproject needs, although most of the  
> nitro-pages are stillenglish-only, it might be a nice addition to  
> all of them to have it athand when you need it.Well, i don't want  
> to clutter the pipeline, but mine looks atm like that:
> Compiler.setup_template_transform do |template|  template =  
> StaticInclude.transform(template)  template = Morphing.transform 
> (template, self)  template = Elements.transform(template, self)   
> template = Markup.transform(template)  template =  
> ScriptCompiler.transform(template, self)  template =  
> Localization.transform(template)  template = Cleanup.transform 
> (template)  template = Template.transform(template)end
> all of that only to get localization running... and everytime  
> thedefault-pipline changes i have to reflect all the changes in  
> here,making upgrades a bit tiresome...How large would be the  
> overhead of having the localization in the default?
> Well, another thing is, i have made a nice little interface to  
> updatethe localization on the fly, while the application is  
> running. I addedthe controller and template below.My question is,  
> could we integrate this one in the part/admin to beused only when  
> the localization is included? i'm not sure how to checkfor that, so  
> i would like to ask someone to give me a hint on that andif it is  
> wanted at all - at least it's making the whole localization abit  
> less tiresome - imagine having to restart the server all the timeto  
> only change a word :)oh, and if you take a closer look at the  
> template, it's a bit weirdbut the only way i could make this work...
> thx in prev~~~~manveru
> ###### controller.rb::edit_locales ######
>   def edit_locales    if request.post?      langs = {}       
> $languages.each{|l| langs.merge!({l[0] => {}})}      arr = Array.new 
> (request.params.size/$languages.size){{}}      request.params.each{| 
> param|        key = param[0].split('_')        if key[1] == 'key'  
> && !param[1].nil?          $languages.each{|l|            langs[l 
> [0]].merge!({param[1] =>request.params["#{key[0]}_#{l 
> [0]}"]})          }        end      }      Glue::Localization.add 
> (langs)      langs.each_pair{|lang, vals|        File.open("conf/# 
> {lang}_locales.yaml", "w") {|fd|          fd.write(YAML::dump 
> (vals))        }      }    end    redirect_to_referer  end
> ###### localization.xhtml ######<Page><?rheader = ['Key']+ 
> $languages.map{|x| x[1]}locales = @lc.map{|lc| lc }.sorti = 0? 
> ><form action="edit_locales" method="post"><table><tr>  <?r for  
> head in header do ?>    <td>#{head}</td>  <?r end ?></tr><?r for  
> row in locales do ?>  <tr>    <td><input name="#{i}_key"  
> type="text" value="#{row[0]}"/></td>    <?r for lang in $languages  
> do ?>      <td>        <textarea name="#{i}_#{lang[0]}"  
> rows="3"cols="40">#{Glue::Localization.get(lang[0])[row[0]]}</ 
> textarea>      </td>    <?r end ?>  </tr><?r i+=1; end ? 
> ><tr><td><input type="text" name="#{i}_key"/></td>  <?r for lang in  
> $languages do ?>    <td><textarea name="#{i}_#{lang[0]}" rows="3"  
> cols="40"></textarea></td>  <?r end ?></tr><tr><td colspan="# 
> {$languages.size+1}"><input style="width:100%;"type="submit"  
> value="[[save locales]]"/></td></tr></table></form></Page>
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general

More information about the Nitro-general mailing list