MediaWiki:Gadget-I18n-js.js: Difference between revisions
From Tardis Wiki, the free Doctor Who reference
fix issues with not-existing messages when using "qqx" language
(optimise i18n cache by only keeping messages for the user and content languages) |
(fix issues with not-existing messages when using "qqx" language) |
||
Line 6: | Line 6: | ||
* @author OneTwoThreeFall <https://dev.fandom.com/User:OneTwoThreeFall> | * @author OneTwoThreeFall <https://dev.fandom.com/User:OneTwoThreeFall> | ||
* | * | ||
* @version 0.6. | * @version 0.6.1 | ||
* | * | ||
* @notes Also used by VSTF wiki for their reporting forms (with a non-dev i18n.json page) | * @notes Also used by VSTF wiki for their reporting forms (with a non-dev i18n.json page) | ||
Line 456: | Line 456: | ||
var msgName = args.shift(), | var msgName = args.shift(), | ||
noMsg = '<' + msgName + '>', | noMsg = '<' + msgName + '>', | ||
msg; | msg = getMsg(messages, msgName, lang), | ||
msgExists = msg !== noMsg; | |||
if (conf.wgUserLanguage === 'qqx') { | if (conf.wgUserLanguage === 'qqx' && msgExists) { | ||
// https://www.mediawiki.org/wiki/Help:System_message#Finding_messages_and_documentation | // https://www.mediawiki.org/wiki/Help:System_message#Finding_messages_and_documentation | ||
msg = '(i18njs-' + name + '-' + msgName + ')'; | msg = '(i18njs-' + name + '-' + msgName + ')'; | ||
Line 464: | Line 465: | ||
// if the message has been overridden, use that without checking the language | // if the message has been overridden, use that without checking the language | ||
msg = overrides[name][msgName]; | msg = overrides[name][msgName]; | ||
} | } | ||
Line 476: | Line 475: | ||
* Boolean representing whether the message exists. | * Boolean representing whether the message exists. | ||
*/ | */ | ||
exists: | exists: msgExists, | ||
/* | /* | ||
Line 844: | Line 843: | ||
options.language = options.language || conf.wgUserLanguage; | options.language = options.language || conf.wgUserLanguage; | ||
options.useCache = (options.noCache || conf.debug) !== true; | options.useCache = (options.noCache || conf.debug) !== true; | ||
if (options.useCache) { | if (options.useCache) { |