User:DR/common.js

From Test Wiki
Revision as of 09:33, 9 April 2024 by DR (talk | contribs) (test)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
function displayUserInfo(user, language = 'en') {
  const translations = {
    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 = {
    registered: `${user.registrationDate} - ${translations[language].registered}`,
    edits: `${user.editCount} ${translations[language].edits}`,
    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>`,
    talkPage: `<a href="https://fr.vikidia.org/wiki/Discussion_utilisateur:${user.name}">${translations[language].talkPage}</a>`,
  };

  console.log(userInfo);
}