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:
Régis Hanol
2019-01-04 15:14:16 +01:00
parent 88e861e895
commit 95e5f8380d
5 changed files with 98 additions and 94 deletions

View File

@ -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")