# Localized templates in rails 2.1

**URL:** <https://www.ruby-forum.com/t/localized-templates-in-rails-2-1/171957>\
**Category:** Rails\
**Created:** [July 12, 2009, 11:09am UTC](https://www.ruby-forum.com/t/localized-templates-in-rails-2-1/171957 "2009-07-12T11:09:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/48db29/32.png) [@ntk](https://www.ruby-forum.com/u/ntk)\
**Post date:** [July 12, 2009, 11:09am UTC](https://www.ruby-forum.com/t/localized-templates-in-rails-2-1/171957/1 "2009-07-12T11:09:13Z")

</div>

I’m trying to implement localized templates in rails 2.1. The background  
is I have a large codebase which among other things uses engines plugin,  
making it a mess to upgrade to rails 2.3 which includes this. Therefore  
I wanted to change the rendering behaviour in rails 2.1 so that it  
searches for files like

index.fr.html.erb or /views/fr/base/index.html.erb if Locale.code (using  
Globalite) is fr.

First I tried coding a :before\_filter in my Application controller and  
using  
prepend\_view\_path(“views/localized/#{@Locale.code}”  
to add a new search path for views. I couldn’t get this to work, it  
seems to have no effect.

The Localized Templates plugin by Jose Valim  
([http://github.com/josevalim/localized\_templates](http://github.com/josevalim/localized_templates)) looks very good, and  
seems it must have been coded before rails 2.2 came out (released sep  
2008). However I get problems with calls to memoize, and if I remove  
those calls, to the \_view paths array. Any ideas? (I thought memoize was  
rails 2.2 feature…) Alternative ways for localized templates?

This is my first time working inside rails and I’m banging my head  
against a wall:p

Memoize error:  
C:/Documents and Settings/dkleman/My  
Documents/NetBeansProjects/myCaddieCommunity/vendor/plugins/localized\_templates-0.2.0/lib/localized\_templates/actionview/base.rb:60:  
undefined method `memoize’ for ActionView::Base:Class (NoMethodError)

If I remove the calls to memoize I get problems with view\_paths array:  
ActionView::TemplateError (undefined method `view\_paths’ for  
#ActionView::Base:0x66a8e38) on line #7 of  
app/views/base/site\_index.html.haml

Cheers,  
David
