refactor(core): ♻️ do not use 'skin-theme-' message keys

It causes issues with translatewiki because of a conflict with Vector.
And those messages are not stable (T359983, T361157)
This commit is contained in:
alistair3149 2024-04-25 14:21:56 -04:00
parent 469d6d1d5e
commit 07aedfea91
No known key found for this signature in database
4 changed files with 38 additions and 21 deletions

View file

@ -48,10 +48,10 @@
"prefs-citizen-lineheight-label": "Line height",
"prefs-citizen-resetbutton-label": "Reset to default",
"skin-theme-name": "Color",
"skin-theme-description": "Reduces the light emitted by device screens.",
"skin-theme-day-label": "Day",
"skin-theme-night-label": "Night",
"skin-theme-os-label": "Automatic",
"skin-theme-exclusion-notice": "This page is always in day mode."
"citizen-theme-name": "Theme",
"citizen-theme-description": "Change the theme of the wiki",
"citizen-theme-day-label": "Light",
"citizen-theme-night-label": "Dark",
"citizen-theme-os-label": "Auto",
"citizen-theme-exclusion-notice": "This page is always in light mode."
}

View file

@ -50,8 +50,10 @@
"prefs-citizen-pagewidth-label": "Label for the page width settings",
"prefs-citizen-lineheight-label": "Label for the line height settings",
"prefs-citizen-resetbutton-label": "Label for the reset button that restore default settings",
"skin-theme-name": "Label for setting that allows you to change theme.",
"skin-theme-description": "Description for theme.",
"skin-theme-day-label": "Label for light theme (standard mode).",
"skin-theme-night-label": "Label for night theme (dark mode)."
"citizen-theme-name": "Label for setting that allows you to change theme.",
"citizen-theme-description": "Description for theme.",
"citizen-theme-day-label": "Label for light/day theme.",
"citizen-theme-night-label": "Label for dark/night theme.",
"citizen-theme-os-label": "Label for automatic theme (which respects any operating system setting).",
"citizen-theme-exclusion-notice": "Text that informs you that the page is always in light/day mode."
}

View file

@ -15,6 +15,22 @@
const addPortlet = require( './addPortlet.polyfill.js' )();
const clientPrefs = require( './clientPrefs.polyfill.js' )();
/**
* Wrapper for mw.message to replace some message keys with citizen-specific messages
* * Some message keys are not merged into core upstream
* * Translatewiki does not allow for duplicated message keys
* * @see https://github.com/StarCitizenTools/mediawiki-skins-Citizen/commit/a741639085d70c22a9f49890542a142a223bf981#r141359264
*
* @param {string} messageKey
* @return {string}
*/
function getMessage( messageKey ) {
if ( messageKey.startsWith( 'skin-theme-' ) ) {
messageKey = messageKey.replace( 'skin-theme-', 'citizen-theme-' );
}
return mw.message( messageKey );
}
/**
* Get the list of client preferences that are active on the page, including hidden.
*
@ -97,7 +113,7 @@ function makeInputElement( type, featureName, value ) {
function makeLabelElement( featureName, value ) {
const label = document.createElement( 'label' );
// eslint-disable-next-line mediawiki/msg-doc
label.textContent = mw.msg( `${ featureName }-${ value }-label` );
label.textContent = getMessage( `${ featureName }-${ value }-label` );
label.setAttribute( 'for', getInputId( featureName, value ) );
return label;
}
@ -113,7 +129,7 @@ function makeLabelElement( featureName, value ) {
function makeExclusionNotice( featureName ) {
const p = document.createElement( 'p' );
// eslint-disable-next-line mediawiki/msg-doc
const noticeMessage = mw.message( `${ featureName }-exclusion-notice` );
const noticeMessage = getMessage( `${ featureName }-exclusion-notice` );
p.classList.add( 'exclusion-notice', `${ featureName }-exclusion-notice` );
p.textContent = noticeMessage.text();
return p;
@ -206,8 +222,7 @@ function createRow( className ) {
* @return {MwMessage}
*/
const getFeatureLabelMsg = ( featureName ) =>
// eslint-disable-next-line mediawiki/msg-doc
mw.message( `${ featureName }-name` );
getMessage( `${ featureName }-name` );
/**
* adds a toggle button
@ -269,7 +284,7 @@ function makeClientPreference( parent, featureName, config ) {
const portlet = addPortlet( id, labelMsg.text() );
const labelElement = portlet.querySelector( 'label' );
// eslint-disable-next-line mediawiki/msg-doc
const descriptionMsg = mw.message( `${ featureName }-description` );
const descriptionMsg = getMessage( `${ featureName }-description` );
if ( descriptionMsg.exists() ) {
const desc = document.createElement( 'span' );
desc.classList.add( 'skin-client-pref-description' );

View file

@ -241,12 +241,12 @@
"prefs-citizen-pagewidth-label",
"prefs-citizen-lineheight-label",
"prefs-citizen-resetbutton-label",
"skin-theme-name",
"skin-theme-description",
"skin-theme-day-label",
"skin-theme-night-label",
"skin-theme-os-label",
"skin-theme-exclusion-notice"
"citizen-theme-name",
"citizen-theme-description",
"citizen-theme-day-label",
"citizen-theme-night-label",
"citizen-theme-os-label",
"citizen-theme-exclusion-notice"
],
"dependencies": [
"mediawiki.storage",