YUKI Hiroshi
null+****@clear*****
Thu Feb 6 16:33:42 JST 2014
YUKI Hiroshi 2014-02-06 16:33:42 +0900 (Thu, 06 Feb 2014) New Revision: 9a164f8f1608ee6dcd4f5779c0ee7592c1c93d79 https://github.com/droonga/droonga.org/commit/9a164f8f1608ee6dcd4f5779c0ee7592c1c93d79 Message: Insert "do not edit this file" notice to translated files Modified files: _tasks/i18n.rb Modified: _tasks/i18n.rb (+21 -1) =================================================================== --- _tasks/i18n.rb 2014-02-06 16:22:42 +0900 (9253f17) +++ _tasks/i18n.rb 2014-02-06 16:33:42 +0900 (d41d4b9) @@ -188,8 +188,24 @@ class I18nTask file translated_file.to_s => dependencies do File.open(target_file) do |input| text = YARD::I18n::Text.new(input) + locale_file = locale_file_path(target_file, locale) + notice = "{% comment %}\n" + + "##############################################\n" + + " THIS FILE IS AUTOMATICALLY GENERATED FROM\n" + + " \"#{locale_file}\"\n" + + " DO NOT EDIT THIS FILE MANUALLY!\n" + + "##############################################\n" + + "{% endcomment %}" + translated_text = text.translate(yard_locale(locale)) + if /^---+$/ =~ translated_text + translated_text = translated_text.split(/^---+\n/) + translated_text[2] = "\n#{notice}\n\n#{translated_text[2]}" + translated_text = translated_text.join("---\n") + else + translated_text = "\n#{notice}\n\n#{translated_text}" + end File.open(translated_file, "w") do |output| - output.puts(text.translate(yard_locale(locale))) + output.puts(translated_text) end end end @@ -199,6 +215,10 @@ class I18nTask task :translate => translated_files end + def locale_file_path(target_file_path, locale) + "_po/#{locale}/#{target_file_path.sub(/\.[^\.]+\z/, "\.po")}" + end + def yard_locale(locale) @yard_locales[locale] ||= create_yard_locale(locale) end -------------- next part -------------- HTML����������������������������...Download