Sha256: 853fd48b1f162114ea5d06e42320554676ba12ee486979de5f56f9c8bf6ddf84

Contents?: true

Size: 1.48 KB

Versions: 19

Compression:

Stored size: 1.48 KB

Contents

module Merb
  module Global
    module MessageProviders
      grammar GetText
        rule po_file
	      entry* {
	        def to_hash
            hash = {}
	          elements.each {|entry| hash.merge! entry.to_hash}
	          hash
	        end
	      }
	      end

        rule entry
	        whitespaces*
          "msgid" whitespaces msgid:strings
          "msgstr" whitespaces msgstr:strings {
           def to_hash
	           {msgid.to_string => {:plural => nil, nil => msgstr.to_string}}
	         end
	        }
	        /
	        whitespaces*
	        "msgid" whitespaces msgid:strings
	        "msgid_plural" whitespaces msgid_plural:strings
	        msgstrs:("msgstr[" number:[0-9]+ "]" whitespaces strings)+ {
	          def to_hash
	            hash = {:plural => msgid_plural.to_string}
	            msgstrs.elements.each do |msgstr|
		             hash[msgstr.number.text_value.to_i] = msgstr.strings.to_string
	            end
	            {msgid.to_string => hash}
	          end
	        }
	      end

	      rule strings
          (string whitespaces?)+ {
       	    def to_string
	            elements.collect {|element| element.string.to_string}.join
	          end
	        }
	      end

       	rule string
	        '"' content:((!'"' ('\"' / .))*) '"' {
	          def to_string
	            content.text_value.gsub(/\\n/, "\n")
	          end
	        }
	      end

        rule whitespaces
          (" " / "\t" / "\n" / ('#' (!"\n" .)* "\n") )+
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
lastobelus-merb_global-0.0.10 lib/merb_global/message_providers/gettext.treetop
lastobelus-merb_global-0.0.11 lib/merb_global/message_providers/gettext.treetop
lastobelus-merb_global-0.0.12 lib/merb_global/message_providers/gettext.treetop
lastobelus-merb_global-0.0.13 lib/merb_global/message_providers/gettext.treetop
lastobelus-merb_global-0.0.14 lib/merb_global/message_providers/gettext.treetop
lastobelus-merb_global-0.0.8 lib/merb_global/message_providers/gettext.treetop
lastobelus-merb_global-0.0.9 lib/merb_global/message_providers/gettext.treetop
emipair-merb_global-0.0.12 lib/merb_global/message_providers/gettext.treetop
emipair-merb_global-0.0.11 lib/merb_global/message_providers/gettext.treetop
emipair-merb_global-0.0.10 lib/merb_global/message_providers/gettext.treetop
emipair-merb_global-0.0.9 lib/merb_global/message_providers/gettext.treetop
emipair-merb_global-0.0.3 lib/merb_global/message_providers/gettext.treetop
emipair-merb_global-0.0.2 lib/merb_global/message_providers/gettext.treetop
emipair-merb_global-0.0.1 lib/merb_global/message_providers/gettext.treetop
merb_global-0.0.5 lib/merb_global/message_providers/gettext.treetop
merb_global-0.0.6 lib/merb_global/message_providers/gettext.treetop
merb_global-0.0.5.2 lib/merb_global/message_providers/gettext.treetop
merb_global-0.0.5.1 lib/merb_global/message_providers/gettext.treetop
merb_global-0.0.7 lib/merb_global/message_providers/gettext.treetop