From fcc101c044d63ecdb664b6e6b28b441258f77cdb Mon Sep 17 00:00:00 2001 From: Adrienne Walker Date: Sat, 7 Apr 2018 15:16:13 -0700 Subject: [PATCH] raidboss: pass locale through as data.lang This should help with issue #57. --- ui/raidboss/data/triggers/README.txt | 3 ++- ui/raidboss/data/triggers/test.js | 14 ++++++++++++++ ui/raidboss/popup-text.js | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ui/raidboss/data/triggers/README.txt b/ui/raidboss/data/triggers/README.txt index ff3f4edf69..4fd7ba1576 100644 --- a/ui/raidboss/data/triggers/README.txt +++ b/ui/raidboss/data/triggers/README.txt @@ -46,6 +46,7 @@ // me: The player's character name. // job: The player's job. // role: The role of the player's job (tank/healer/dps-melee/dps-ranged/dps-caster/crafting/gathering). +// lang: The current language, e.g. 'en', 'fr', 'ko', 'de', 'ja'. // function ParseLocaleFloat(float): A function that can parse \y{Float} matches from the regex. // function ShortName(name): A function that simplifies a player's name into something shorter, usually first name. // function StopCombat(): Manually stop timelines and triggers, usually paired with resetWhenOutOfCombat = false. @@ -107,4 +108,4 @@ The full order of evaluation of functions in a trigger is: 7. alertText 8. alarmText 9. tts -10. run \ No newline at end of file +10. run diff --git a/ui/raidboss/data/triggers/test.js b/ui/raidboss/data/triggers/test.js index a579ed9dee..ac3a29e54a 100644 --- a/ui/raidboss/data/triggers/test.js +++ b/ui/raidboss/data/triggers/test.js @@ -110,5 +110,19 @@ fr: 'Bravo, vive la France', }, }, + { + id: 'Test Lang', + regex: /00:0038:cactbot lang/, + infoText: function(data) { + return { + en: 'Language: ' + data.lang, + }; + }, + tts: function(data) { + return { + en: 'Language: ' + data.lang, + }; + }, + }, ], }] diff --git a/ui/raidboss/popup-text.js b/ui/raidboss/popup-text.js index 985a172c6b..8cb93541a1 100644 --- a/ui/raidboss/popup-text.js +++ b/ui/raidboss/popup-text.js @@ -184,10 +184,12 @@ class PopupText { } Reset() { + var locale = this.options.Language || 'en'; this.data = { me: this.me, job: this.job, role: this.role, + lang: locale, ShortName: this.ShortNamify, StopCombat: (function() { this.SetInCombat(false); }).bind(this), ParseLocaleFloat: function(s) { return Regexes.ParseLocaleFloat(s); },