mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
automatically updating times for posts on topic
moved moment.js into localization file (we need to localize it) added helpers for date formatting use, moment().shortDate() moment().longDate() moment().shortDateNoYear()
This commit is contained in:
@ -18,11 +18,26 @@ module JsLocaleHelper
|
||||
result = generate_message_format(message_formats, locale_str)
|
||||
|
||||
result << "I18n.translations = #{translations.to_json};\n"
|
||||
result << "I18n.locale = '#{locale_str}'\n"
|
||||
result << "I18n.locale = '#{locale_str}';\n"
|
||||
# loading moment here cause we must customize it
|
||||
result << File.read("#{Rails.root}/lib/javascripts/moment.js")
|
||||
result << moment_locale(locale_str)
|
||||
result << moment_formats
|
||||
result
|
||||
end
|
||||
|
||||
def self.moment_formats
|
||||
result = ""
|
||||
result << moment_format_function('short_date_no_year')
|
||||
result << moment_format_function('short_date')
|
||||
result << moment_format_function('long_date')
|
||||
end
|
||||
|
||||
def self.moment_format_function(name)
|
||||
format = I18n.t("dates." << name)
|
||||
result = "moment.fn.#{name.camelize(:lower)} = function(){ return this.format('#{format}'); };\n"
|
||||
end
|
||||
|
||||
def self.moment_locale(locale_str)
|
||||
filename = Rails.root + "lib/javascript/moment_locale/#{locale_str}.js"
|
||||
if File.exists?(filename)
|
||||
|
Reference in New Issue
Block a user