mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FEATURE: Allow plugins to add custom emoji translations
FIX: buildTranslationTree was erroring when translations overlapped (ie. ":-)" and ":-))") FIX: emoji translations wasn't working properly when translations overlapped
This commit is contained in:
@ -16,6 +16,15 @@ class Plugin::CustomEmoji
|
||||
@@cache_key = Digest::SHA1.hexdigest(cache_key + name)[0..10]
|
||||
emojis[name] = url
|
||||
end
|
||||
|
||||
def self.translations
|
||||
@@translations ||= {}
|
||||
end
|
||||
|
||||
def self.translate(from, to)
|
||||
@@cache_key = Digest::SHA1.hexdigest(cache_key + from)[0..10]
|
||||
translations[from] = to
|
||||
end
|
||||
end
|
||||
|
||||
class Plugin::Instance
|
||||
@ -429,6 +438,10 @@ class Plugin::Instance
|
||||
Plugin::CustomEmoji.register(name, url)
|
||||
end
|
||||
|
||||
def translate_emoji(from, to)
|
||||
Plugin::CustomEmoji.translate(from, to)
|
||||
end
|
||||
|
||||
def automatic_assets
|
||||
css = styles.join("\n")
|
||||
js = javascripts.join("\n")
|
||||
|
Reference in New Issue
Block a user