<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,11 +1,11 @@
 GettextToI18n
 =============
 
-ABOUT
 This plugin will convert your complete Rails project from Gettext calls to the new i18n api calls introduced in Rails 2.2.2. NB: This plugin is higly experimental, so before running, BACKUP YOUR CODE. It will touch your code and things always can go wrong!
 
 
-EXAMPLE
+Example
+=======
 	&lt;%=_(&quot;Some string that will be translated, into %{lan}&quot; % {:lan =&gt; 'english'}) %&gt;
 
 will be converted into:
@@ -19,7 +19,8 @@ it will then place a entry:
 in the standard.yml locale file it generates.
 
 
-NAMESPACES
+About namespaces
+========
 By default the plugin walks all files in the app directory. It places the message id's into namespaces. The namespace are divided like this: 
 
 	Controllers: translation[:txt][:controller][:controller_name]
@@ -28,10 +29,17 @@ By default the plugin walks all files in the app directory. It places the messag
 	
 	
 
-USAGE
+Usage
+=======
 To convert all your views, controllers and models to the new format.
 
-rake gettext_to_i18n:transform
+	rake gettext_to_i18n:transform
+
+
+Installation
+=======
+./script/plugin install git://github.com/japetheape/gettext_to_i18n.git
+
 
 
 -------------</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -19,15 +19,22 @@ module GettextToI18n
     def transform_files!(files, type)  
       files.each do |file|
         parsed = &quot;&quot;
-        alternative_filename = Base.get_name(file, type)
-        n = Namespace.new([DEFAULT_LANGUAGE, 'txt', type, alternative_filename])
+        namespace = [DEFAULT_LANGUAGE, 'txt', type] + Base.get_namespace(file, type)
+        puts &quot;Converting: &quot; + file + &quot; into namespace: &quot;
+        puts namespace.map {|x| &quot;[\&quot;#{x}\&quot;]&quot;}.join(&quot;&quot;)
         
-        File.read(file).each do |line|
-          parsed &lt;&lt; GettextI18nConvertor.string_to_i18n(line, n)
-        end
+        n = Namespace.new(namespace)
         
+        contents = Base.get_file_as_string(file)
+        parsed &lt;&lt; GettextI18nConvertor.string_to_i18n(contents, n)
+  
+        #puts parsed
         # write the file
+        
         File.open(file, 'w') { |file| file.write(parsed)}
+        
+        
+        
         n.merge(@translations)
       end
     end
@@ -40,33 +47,46 @@ module GettextToI18n
     
     
     private 
- 
+    
+    
+    def self.get_file_as_string(filename)
+      data = ''
+      f = File.open(filename, &quot;r&quot;) 
+      f.each_line do |line|
+        data += line
+      end
+      return data
+    end
     # returns a name for a file
     # example: 
     # Base.get_name('/controllers/apidoc_controller.rb', 'controller') =&gt; 'apidoc'
-    def self.get_name(file, type)
+    def self.get_namespace(file, type)
      case type
 
        when :controller
          if result = /application\.rb/.match(file)
-           return 'application'
+           return ['application']
          else
            result = /([a-zA-Z]+)_controller.rb/.match(file)
-           return result[1]
+           return [result[1]]
          end
          return &quot;&quot;
        when :helper
          result = /([a-zA-Z]+)_helper.rb/.match(file)
-         return result[1]
+         return [result[1]]
        when :model
           result = /([a-zA-Z]+).rb/.match(file)
-          return result[1]
+          return [result[1]]
        when :view
-         result = /views\/([\_a-zA-Z]+)\//.match(file)
-         return result[1]
+         result = /views\/([\_a-zA-Z]+)\/([\_a-zA-Z]+).*\.([a-zA-Z]+)/.match(file)
+         if result[3] != &quot;erb&quot;
+           return [result[1], result[2], result[3]]
+         else
+           return [result[1], result[2]] 
+         end
         when :lib
           result = /([a-zA-Z]+).rb/.match(file)
-          return result[1]
+          return [result[1]]
      end
     end
     </diff>
      <filename>lib/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,7 +14,7 @@ module GettextToI18n
     
     # All view files
     def self.view_files
-      self.get_files('app/views', '**/*.erb')
+      self.get_files('app/views', '**/*.{erb,builder}')
     end
     
     # All view files</diff>
      <filename>lib/files.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,9 +11,16 @@ module GettextToI18n
     
     # The contents of the method call
     def contents
-      if result = /\_\([\&quot;\']?([^\'\&quot;]*)[\&quot;\']?.*\)/.match(@text)
-      #if result = /\_\([\&quot;\'](.*)[\&quot;\']\)/.match(@text)
-        return result[1]
+      #if result = /\_\([\&quot;\']?([^\'\&quot;]*)[\&quot;\']?.*\)/.match(@text)
+      
+      #if result = /\_\(([\']?([^\']*)[\'])|([\&quot;]?([^\&quot;]*)[\&quot;])?.*\)/.match(@text)
+      single_quotes = /\_\(\'([^']*)\'.*\)/.match(@text)
+      double_quotes = /\_\(\&quot;([^&quot;]*)\&quot;.*\)/.match(@text)
+      
+      if single_quotes
+        return single_quotes[1]
+      elsif double_quotes
+        return double_quotes[1]
       else
         return nil
       end
@@ -39,7 +46,7 @@ module GettextToI18n
     # return :a =&gt; 'sdf', :b =&gt; 'agh'
     def variable_part
       @variable_part_cached ||= begin
-          result = /\% \{(.*)\}/.match(@text)
+          result = /\%[\s]+\{(.*)\}/.match(@text)
           if result
               result[1]
           end
@@ -78,7 +85,7 @@ module GettextToI18n
         vsplitted = get_variables_splitted
         return nil if vsplitted.nil?
         vsplitted.map! { |v| 
-          r = v.match(/ *:(\w+) *=&gt; *(.*)/)
+          r = v.match(/\s*:(\w+)\s*=&gt;\s*(.*)/)
           {:name =&gt; r[1], :value =&gt; GettextI18nConvertor.string_to_i18n(r[2], @namespace)}
         }
       end
@@ -89,7 +96,7 @@ module GettextToI18n
     def to_i18n
       id = @namespace.consume_id!
       @namespace.set_id(id, contents_i18n)
-      output = &quot;t(:#{id}&quot;
+      output = &quot;I18n.t(:#{id}&quot;
       if !self.variables.nil?
           vars = self.variables.collect { |h| {:name =&gt; h[:name], :value =&gt; h[:value] }}
           output += &quot;, &quot; + vars.collect {|h| &quot;:#{h[:name]} =&gt; #{h[:value]}&quot;}.join(&quot;, &quot;)</diff>
      <filename>lib/gettext_i18n_convertor.rb</filename>
    </modified>
    <modified>
      <diff>@@ -31,7 +31,7 @@ module GettextToI18n
     def i18n_namespace
       @cached_i18n_namespace ||= begin
         a = @namespace.dup
-        a.delete(&quot;txt&quot;)
+        #a.delete(&quot;txt&quot;)
         a.delete(Base::DEFAULT_LANGUAGE)
         a
       end
@@ -50,6 +50,7 @@ module GettextToI18n
         arr = 'base' + loc 
         eval  arr + ' = {} if ' + arr + '.nil?' 
       end
+     
       eval 'base' + loc + ' = @ids'
       
     end</diff>
      <filename>lib/namespace.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,28 +17,28 @@ module GettextToI18n
     def test_variables
       assert_equal &quot;:a =&gt; 'sdasd', :b =&gt; 'sdasd'&quot;, GettextI18nConvertor.new(&quot;_('a   ' % {:a =&gt; 'sdasd', :b =&gt; 'sdasd'})&quot;).variable_part
       assert_equal [{:name =&gt; &quot;a&quot;, :value =&gt; &quot;'sdasd'&quot;}, {:name =&gt; &quot;b&quot;, :value =&gt; &quot;'sdasd'&quot;}], GettextI18nConvertor.new(&quot;_('a   ' % {:a =&gt; 'sdasd', :b =&gt; 'sdasd'})&quot;).variables
-      assert_equal &quot;t(:message_0, :a =&gt; 'sdasd', :scope =&gt; [:somenamespace])&quot;, GettextI18nConvertor.new(&quot;_('a   ' % {:a =&gt; 'sdasd'})&quot;, Namespace.new(&quot;somenamespace&quot;)).to_i18n
-      assert_equal &quot;t(:message_0, :a =&gt; 'sdasd', :b =&gt; 'sd', :scope =&gt; [:somenamespace])&quot;, GettextI18nConvertor.new(&quot;_('a   ' % {:a =&gt; 'sdasd', :b =&gt; 'sd'})&quot;, Namespace.new(&quot;somenamespace&quot;)).to_i18n
+      assert_equal &quot;I18n.t(:message_0, :a =&gt; 'sdasd', :scope =&gt; [:somenamespace])&quot;, GettextI18nConvertor.new(&quot;_('a   ' % {:a =&gt; 'sdasd'})&quot;, Namespace.new(&quot;somenamespace&quot;)).to_i18n
+      assert_equal &quot;I18n.t(:message_0, :a =&gt; 'sdasd', :b =&gt; 'sd', :scope =&gt; [:somenamespace])&quot;, GettextI18nConvertor.new(&quot;_('a   ' % {:a =&gt; 'sdasd', :b =&gt; 'sd'})&quot;, Namespace.new(&quot;somenamespace&quot;)).to_i18n
       assert_equal &quot;:a =&gt; 'sdf' + _(sdf)&quot;, GettextI18nConvertor.new(&quot;_('aaa' % {:a =&gt; 'sdf' + _(sdf)}) %&gt;&quot;, Namespace.new(&quot;somenamespace&quot;)).variable_part
     end
     
     def test_multiple_variables
-      assert_equal &quot;&lt;%=t(:message_0, :a =&gt; 'sdf', :b =&gt; 'agh', :scope =&gt; [:somenamespace]) %&gt;&quot;, GettextI18nConvertor.string_to_i18n(&quot;&lt;%=_('aaa' % {:a =&gt; 'sdf', :b =&gt; 'agh'}) %&gt;&quot;, Namespace.new(&quot;somenamespace&quot;)) 
+      assert_equal &quot;&lt;%=I18n.t(:message_0, :a =&gt; 'sdf', :b =&gt; 'agh', :scope =&gt; [:somenamespace]) %&gt;&quot;, GettextI18nConvertor.string_to_i18n(&quot;&lt;%=_('aaa' % {:a =&gt; 'sdf', :b =&gt; 'agh'}) %&gt;&quot;, Namespace.new(&quot;somenamespace&quot;)) 
     end
     
     
     def test_recursive_gettext
       t = GettextI18nConvertor.new(&quot;&lt;%=_('aaa' % {:a =&gt; 'sdf' + _(sdfg) + _(sdfg), :b =&gt; '21'}) %&gt;&quot;, Namespace.new(&quot;somenamespace&quot;))
       assert_equal &quot;:a =&gt; 'sdf' + _(sdfg) + _(sdfg), :b =&gt; '21'&quot;, t.variable_part
-      assert_equal [{:value=&gt;&quot;'sdf' + t(:message_0, :scope =&gt; [:somenamespace]) + t(:message_1, :scope =&gt; [:somenamespace])&quot;, :name=&gt;&quot;a&quot;},  {:value=&gt;&quot;'21'&quot;, :name=&gt;&quot;b&quot;}], t.variables
+      assert_equal [{:value=&gt;&quot;'sdf' + I18n.t(:message_0, :scope =&gt; [:somenamespace]) + I18n.t(:message_1, :scope =&gt; [:somenamespace])&quot;, :name=&gt;&quot;a&quot;},  {:value=&gt;&quot;'21'&quot;, :name=&gt;&quot;b&quot;}], t.variables
       
-      assert_equal &quot;&lt;%=t(:message_0, :a =&gt; 'sdf' + t(:message_1, :scope =&gt; [:somenamespace]) + t(:message_2, :scope =&gt; [:somenamespace]), :scope =&gt; [:somenamespace]) %&gt;&quot;, GettextI18nConvertor.string_to_i18n(&quot;&lt;%=_('aaa' % {:a =&gt; 'sdf' + _(sdfg) + _(sdfg)}) %&gt;&quot;, Namespace.new(&quot;somenamespace&quot;)) 
+      assert_equal &quot;&lt;%=I18n.t(:message_0, :a =&gt; 'sdf' + I18n.t(:message_1, :scope =&gt; [:somenamespace]) + I18n.t(:message_2, :scope =&gt; [:somenamespace]), :scope =&gt; [:somenamespace]) %&gt;&quot;, GettextI18nConvertor.string_to_i18n(&quot;&lt;%=_('aaa' % {:a =&gt; 'sdf' + _(sdfg) + _(sdfg)}) %&gt;&quot;, Namespace.new(&quot;somenamespace&quot;)) 
     
     end
     
     
     def test_variable_parts
-      assert_equal &quot;t(:message_0, :a =&gt; 'sdasddd', :b =&gt; 'sdasd' + t(:message_1, :scope =&gt; [:somenamespace]), :scope =&gt; [:somenamespace])&quot; , GettextI18nConvertor.new(&quot;_('a   ' % {:a =&gt; 'sdasddd', :b =&gt; 'sdasd' + _('sfd')})&quot;, Namespace.new(&quot;somenamespace&quot;)).to_i18n
+      assert_equal &quot;I18n.t(:message_0, :a =&gt; 'sdasddd', :b =&gt; 'sdasd' + I18n.t(:message_1, :scope =&gt; [:somenamespace]), :scope =&gt; [:somenamespace])&quot; , GettextI18nConvertor.new(&quot;_('a   ' % {:a =&gt; 'sdasddd', :b =&gt; 'sdasd' + _('sfd')})&quot;, Namespace.new(&quot;somenamespace&quot;)).to_i18n
     end
     
     
@@ -67,14 +67,26 @@ module GettextToI18n
       str = &quot;_('For more information on large volume plans, customized solutions or (media) partnerships.')&quot;
       #str =  &quot;_(\&quot;%{project_name} (copy)\&quot; % {:project_name =&gt; @project.name})&quot;
       t =  GettextI18nConvertor.string_to_i18n(str, Namespace.new('d'))
-      
-      
       str = &quot;o &lt;&lt; content_tag(:div, _(\&quot;Plan your own home with the free floorplanner\&quot;), :class =&gt; \&quot;content\&quot;)&quot;
-      
       t =  GettextI18nConvertor.string_to_i18n(str, Namespace.new('d'))
       puts t
       
     end
     
+    
+    def test_quotes
+      
+      n  =GettextToI18n::Namespace.new(&quot;somenamespace&quot;)
+      str = &quot;_('The easiest way to &lt;span class=\&quot;highlight\&quot;&gt;create&lt;/span&gt; and&lt;br /&gt; &lt;span class=\&quot;highlight\&quot;&gt;share&lt;/span&gt; interactive floorplans')&quot;
+      t = GettextToI18n::GettextI18nConvertor.new(str, n)
+      assert_equal 'The easiest way to &lt;span class=&quot;highlight&quot;&gt;create&lt;/span&gt; and&lt;br /&gt; &lt;span class=&quot;highlight&quot;&gt;share&lt;/span&gt; interactive floorplans', t.contents
+      puts t.text
+      
+      
+      t = GettextToI18n::GettextI18nConvertor.new(&quot;_(\&quot;Save\&quot;)&quot;, n)
+      assert_equal &quot;Save&quot;, t.contents
+      
+    end
+    
   end
 end
\ No newline at end of file</diff>
      <filename>test/gettext_i18n_convertor_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>890a20464bde7b499d2e4a2959ca346b9c54b05f</id>
    </parent>
  </parents>
  <author>
    <name>Jaap van der Meer</name>
    <email>jaapvandermeer@gmail.com</email>
  </author>
  <url>http://github.com/japetheape/gettext_to_i18n/commit/803a02bd3bf7d7017dc299488eff1e6621af991f</url>
  <id>803a02bd3bf7d7017dc299488eff1e6621af991f</id>
  <committed-date>2008-09-16T10:10:29-07:00</committed-date>
  <authored-date>2008-09-16T10:10:29-07:00</authored-date>
  <message>Now completely converts and writes yaml file</message>
  <tree>5746f4c1f24e298d13fd603d8c42e027d76f3668</tree>
  <committer>
    <name>Jaap van der Meer</name>
    <email>jaapvandermeer@gmail.com</email>
  </committer>
</commit>
