* Look up a localized version of a standard message. While using `_` for the * method name is not exactly idiomatic javascript, it was inspired by Python's * https://docs.python.org/3/library/gettext.html|gettext module, with * the intention of reducing clutter in places where
(k, context)
| 88 | * @returns {string} - a localized string appropriate to the message key |
| 89 | */ |
| 90 | _(k, context) { |
| 91 | let msg = this.messages[k] || Language.fallback.messages[k] || k; |
| 92 | if (msg.match(MESSAGE_VARIABLE_PATTERN)) { |
| 93 | if (!context) throw new TLError("template_message_without_context") |
| 94 | for (let match of msg.matchAll(MESSAGE_VARIABLE_PATTERN)) { |
| 95 | if (!(match[1] in context)) throw new TLError("template_message_without_context") |
| 96 | msg = msg.replace(match[0], context[match[1]]) |
| 97 | } |
| 98 | } |
| 99 | return msg |
| 100 | } |
| 101 | |
| 102 | formatDate(date, format_name) { |
| 103 |
no outgoing calls
no test coverage detected