User:DR/common.js: Difference between revisions

From Test Wiki
Jump to navigation Jump to search
Content deleted Content added
DR (talk | contribs)
test
 
DR (talk | contribs)
test
Line 1: Line 1:
function displayUserInfo(user, language = 'en') {
function displayUserInfo(user, language = 'en') {
const translations = {
const translations = userInfoTranslations[language];
en: {
registered: "registered",
edits: "edits",
contributions: "contributions",
userPage: "user page",
talkPage: "talk page",
},
fr: {
registered: "enregistré",
edits: "modifications",
contributions: "contributions",
userPage: "page utilisateur",
talkPage: "page de discussion",
},
};


const userInfo = {
const userInfo = {
autopatrol: translations.autopatrol || 'autopatrol',
registered: `${user.registrationDate} - ${translations[language].registered}`,
edits: `${user.editCount} ${translations[language].edits}`,
translateadmin: translations.translateadmin || 'translateadmin',
autoconfirmed: translations.autoconfirmed || 'autoconfirmed',
contributions: `<a href="https://fr.vikidia.org/wiki/Spécial:Contributions/${user.name}">${translations[language].contributions}</a>`,
userPage: `<a href="https://fr.vikidia.org/wiki/${user.name}">${translations[language].userPage}</a>`,
registered: `${user.registrationDate} - ${translations.registered}`,
talkPage: `<a href="https://fr.vikidia.org/wiki/Discussion_utilisateur:${user.name}">${translations[language].talkPage}</a>`,
edits: `${user.editCount} ${translations.edits}`,
contributions: `<a href="https://fr.vikidia.org/wiki/Spécial:Contributions/${user.name}">${translations.contributions}</a>`,
userPage: `<a href="https://fr.vikidia.org/wiki/${user.name}">${translations.userPage}</a>`,
talkPage: `<a href="https://fr.vikidia.org/wiki/Discussion_utilisateur:${user.name}">${translations.talkPage}</a>`,
};
};



Revision as of 09:35, 9 April 2024

function displayUserInfo(user, language = 'en') {
  const translations = userInfoTranslations[language];

  const userInfo = {
    autopatrol: translations.autopatrol || 'autopatrol',
    translateadmin: translations.translateadmin || 'translateadmin',
    autoconfirmed: translations.autoconfirmed || 'autoconfirmed',
    registered: `${user.registrationDate} - ${translations.registered}`,
    edits: `${user.editCount} ${translations.edits}`,
    contributions: `<a href="https://fr.vikidia.org/wiki/Spécial:Contributions/${user.name}">${translations.contributions}</a>`,
    userPage: `<a href="https://fr.vikidia.org/wiki/${user.name}">${translations.userPage}</a>`,
    talkPage: `<a href="https://fr.vikidia.org/wiki/Discussion_utilisateur:${user.name}">${translations.talkPage}</a>`,
  };

  console.log(userInfo);
}