mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: auto-load all plugin locales so that they can be used in PrettyText
This commit is contained in:
parent
77dc5f2f58
commit
4a9587fa23
@ -88,8 +88,9 @@ module Discourse
|
|||||||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||||
config.time_zone = 'UTC'
|
config.time_zone = 'UTC'
|
||||||
|
|
||||||
# auto-load server locale in plugins
|
# auto-load locales in plugins
|
||||||
config.i18n.load_path += Dir["#{Rails.root}/plugins/*/config/locales/server.*.yml"]
|
# NOTE: we load both client & server locales since some might be used by PrettyText
|
||||||
|
config.i18n.load_path += Dir["#{Rails.root}/plugins/*/config/locales/*.yml"]
|
||||||
|
|
||||||
# Configure the default encoding used in templates for Ruby 1.9.
|
# Configure the default encoding used in templates for Ruby 1.9.
|
||||||
config.encoding = 'utf-8'
|
config.encoding = 'utf-8'
|
||||||
|
@ -12,11 +12,11 @@ module PrettyText
|
|||||||
def t(key, opts)
|
def t(key, opts)
|
||||||
key = "js." + key
|
key = "js." + key
|
||||||
unless opts
|
unless opts
|
||||||
return I18n.t(key)
|
I18n.t(key)
|
||||||
else
|
else
|
||||||
str = I18n.t(key, Hash[opts.entries].symbolize_keys).dup
|
str = I18n.t(key, Hash[opts.entries].symbolize_keys).dup
|
||||||
opts.each {|k,v| str.gsub!("{{#{k.to_s}}}", v.to_s) }
|
opts.each { |k,v| str.gsub!("{{#{k.to_s}}}", v.to_s) }
|
||||||
return str
|
str
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -26,7 +26,6 @@ module PrettyText
|
|||||||
user = User.find_by(username_lower: username.downcase)
|
user = User.find_by(username_lower: username.downcase)
|
||||||
return "" unless user.present?
|
return "" unless user.present?
|
||||||
|
|
||||||
|
|
||||||
# TODO: Add support for ES6 and call `avatar-template` directly
|
# TODO: Add support for ES6 and call `avatar-template` directly
|
||||||
if !user.uploaded_avatar_id && SiteSetting.default_avatars.present?
|
if !user.uploaded_avatar_id && SiteSetting.default_avatars.present?
|
||||||
split_avatars = SiteSetting.default_avatars.split("\n")
|
split_avatars = SiteSetting.default_avatars.split("\n")
|
||||||
@ -147,7 +146,6 @@ module PrettyText
|
|||||||
context.eval("Discourse.SiteSettings = #{SiteSetting.client_settings_json};")
|
context.eval("Discourse.SiteSettings = #{SiteSetting.client_settings_json};")
|
||||||
context.eval("Discourse.CDN = '#{Rails.configuration.action_controller.asset_host}';")
|
context.eval("Discourse.CDN = '#{Rails.configuration.action_controller.asset_host}';")
|
||||||
context.eval("Discourse.BaseUrl = 'http://#{RailsMultisite::ConnectionManagement.current_hostname}';")
|
context.eval("Discourse.BaseUrl = 'http://#{RailsMultisite::ConnectionManagement.current_hostname}';")
|
||||||
|
|
||||||
context.eval("Discourse.getURL = function(url) { return '#{Discourse::base_uri}' + url };")
|
context.eval("Discourse.getURL = function(url) { return '#{Discourse::base_uri}' + url };")
|
||||||
context.eval("Discourse.getURLWithCDN = function(url) { url = Discourse.getURL(url); if (Discourse.CDN) { url = Discourse.CDN + url; } return url; };")
|
context.eval("Discourse.getURLWithCDN = function(url) { url = Discourse.getURL(url); if (Discourse.CDN) { url = Discourse.CDN + url; } return url; };")
|
||||||
end
|
end
|
||||||
@ -166,7 +164,6 @@ module PrettyText
|
|||||||
context_opts = opts || {}
|
context_opts = opts || {}
|
||||||
context_opts[:sanitize] ||= true
|
context_opts[:sanitize] ||= true
|
||||||
context['opts'] = context_opts
|
context['opts'] = context_opts
|
||||||
|
|
||||||
context['raw'] = text
|
context['raw'] = text
|
||||||
|
|
||||||
if Post.white_listed_image_classes.present?
|
if Post.white_listed_image_classes.present?
|
||||||
|
Loading…
Reference in New Issue
Block a user