Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

i18n: Fill "POT-Creation-Date" header value

It should be the time of the .pot is created. The current
implementation uses the static value. (It was my mistake. Sorry.)
  • Loading branch information...
commit fcc62338efdaf097bc427d6d042fe7f333920c6f 1 parent 77a02c8
@kou kou authored
Showing with 33 additions and 22 deletions.
  1. +19 −11 lib/yard/i18n/pot_generator.rb
  2. +14 −11 spec/i18n/pot_generator_spec.rb
View
30 lib/yard/i18n/pot_generator.rb
@@ -134,7 +134,7 @@ def generate
private
def header
- <<-'EOH'
+ <<-EOH
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
@@ -143,20 +143,28 @@ def header
#, fuzzy
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-11-20 22:17+0900\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"Language: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
+"Project-Id-Version: PACKAGE VERSION\\n"
+"Report-Msgid-Bugs-To: \\n"
+"POT-Creation-Date: #{generate_pot_creation_date_value}\\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
+"Language-Team: LANGUAGE <LL@li.org>\\n"
+"Language: \\n"
+"MIME-Version: 1.0\\n"
+"Content-Type: text/plain; charset=UTF-8\\n"
+"Content-Transfer-Encoding: 8bit\\n"
EOH
end
+ def current_time
+ @current_time ||= Time.now
+ end
+
+ def generate_pot_creation_date_value
+ current_time.strftime("%Y-%m-%d %H:%M%z")
+ end
+
def generate_message(pot, message)
message.comments.sort.each do |comment|
pot << "# #{comment}\n" unless comment.empty?
View
25 spec/i18n/pot_generator_spec.rb
@@ -25,7 +25,10 @@ def add_messages(yard_messages, messages)
describe "Generate" do
it "should generate the default header" do
- @generator.generate.should == <<-'eoh'
+ current_time = Time.parse("2011-11-20 22:17+0900")
+ @generator.stub!(:current_time).and_return(current_time)
+ pot_creation_date = current_time.strftime("%Y-%m-%d %H:%M%z")
+ @generator.generate.should == <<-eoh
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
@@ -34,16 +37,16 @@ def add_messages(yard_messages, messages)
#, fuzzy
msgid ""
msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-11-20 22:17+0900\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"Language: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
+"Project-Id-Version: PACKAGE VERSION\\n"
+"Report-Msgid-Bugs-To: \\n"
+"POT-Creation-Date: #{pot_creation_date}\\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
+"Language-Team: LANGUAGE <LL@li.org>\\n"
+"Language: \\n"
+"MIME-Version: 1.0\\n"
+"Content-Type: text/plain; charset=UTF-8\\n"
+"Content-Transfer-Encoding: 8bit\\n"
eoh
end
Please sign in to comment.
Something went wrong with that request. Please try again.