* Helper function to inject the translated text and tooltip. * * @param {string} id ID of the HTML element * @param {string} attribute Name of the attribute used for localization * @param {string} tooltip
(id, attribute, tooltip = "")
| 231 | * @param {string} tooltip |
| 232 | */ |
| 233 | function injectText(id, attribute, tooltip = "") |
| 234 | { |
| 235 | const object = document.getElementById(id); |
| 236 | object.textContent = translate(attribute); |
| 237 | |
| 238 | /* |
| 239 | This function will throw an error if no translation |
| 240 | is found for the tooltip. This is a planned error. |
| 241 | */ |
| 242 | tooltip = translate(attribute+"_title"); |
| 243 | |
| 244 | if(tooltip !== "") |
| 245 | { |
| 246 | object.setAttribute('title', tooltip); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Loads data from storage and saves into local variable. |