We've identified the necessity of installing an on-screen keyboard for language description on Wikidata.
Description
Event Timeline
Here are the steps to create an onscreen keyboard for incorporating special characters into editing Wikidata descriptions. If you wish to utilize this code in your preferred language, you'll need to adjust the special characters to match those in your language.
- You need to login to your wikidata account
- The second Step is to is to create a .js Script on wikidata
- The next step is to write the code in the wikidata .js script
To enable this script, put the following line on your common.js User subpage: importScript('User:AgnesAbah/copy-IglChar.js');
To fork this tool for your language, simply change the characters in the chars array.
//Code inspired by [[User:Masssly/copy-DagChar.js]]
const chars = [
{ text: 'á', capitalizedText: 'Ɛ' }, { text: 'ā', capitalizedText: 'Ɣ' }, { text: 'à', capitalizedText: 'Ŋ' }, { text: 'é', capitalizedText: 'Ɔ' }, { text: 'ē', capitalizedText: 'Ʒ' }, { text: 'ẹ́', capitalizedText: 'Ẹ́' }, { text: 'ē', capitalizedText: 'Gb' }, { text: 'ẹ', capitalizedText: 'Kp' }, { text: 'è', capitalizedText: 'Ŋm' }, { text: 'ẹ̄', capitalizedText: 'Sh' }, { text: 'ẹ̀', capitalizedText: 'Ny' }, { text: 'ị̄̀', capitalizedText: 'Ny' }, { text: 'ẹ', capitalizedText: 'Kp' }, { text: 'ṑ', capitalizedText: 'Ŋm' }, { text: 'ọ̣́̄', capitalizedText: 'Sh' }, { text: 'ọ̣', capitalizedText: 'Ny' }, { text: 'ọ̄̀', capitalizedText: 'Ny' },
];
let isCapitalized = false;
mw.loader.using('oojs-ui-core').done(() => {
const container = $('<div>').attr('id', 'dag-char-buttons').css({ position: 'fixed', right: '10px', bottom: '10px', zIndex: '1000' }).appendTo('.mw-indicators'); const capsButton = $('<button>').addClass('oo-ui-buttonElement oo-ui-widget oo-ui-widget-enabled oo-ui-buttonWidget oo-ui-buttonWidget-framed').appendTo(container); updateCapsButtonText(); capsButton.click(() => { isCapitalized = !isCapitalized; updateCapsButtonText(); chars.forEach((char, index) => $(`#dag-char-button-${index}`).text(isCapitalized ? char.capitalizedText : char.text)); }); chars.forEach((char, index) => { $('<button>').attr('id', `dag-char-button-${index}`).addClass('oo-ui-buttonElement oo-ui-widget oo-ui-widget-enabled oo-ui-buttonWidget oo-ui-buttonWidget-framed').text(char.text).click(() => { navigator.clipboard.writeText(isCapitalized ? char.capitalizedText : char.text).then( () => $('<div>').addClass('copy-popup').text('Copied!').css({ width: 80, position: 'fixed', bottom: '10px', right: '10px', textAlign: 'center', backgroundColor: 'rgba(0, 0, 0, 0.7)', color: '#fff', padding: '10px', borderRadius: '5px', zIndex: '1001' }).appendTo('body').fadeIn(1000).fadeOut(1000, () => $(this).remove()), () => $('<div>').addClass('copy-popup').text('Copy failed').css({ width: 80 }).appendTo('.mw-indicators').fadeIn(1000).fadeOut(1000, () => $(this).remove()) ); }).appendTo(container); }); function updateCapsButtonText() { capsButton.text(`Caps: ${isCapitalized ? 'On' : 'Off'}`); }
});
- the next step is to create common.js script on wikidata
- import script to common.js and publish
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.
@AgnesAbah: Thanks for participating in the Hackathon! We hope you had a great time.
- If this task was being worked on and resolved at the Hackathon: Please change the task status to resolved via the Add Action... → Change Status dropdown, and make sure that this task has a link to the public codebase.
- If this task is still valid and should stay open: Please add another active project tag to this task, so others can find this task (as likely nobody in the future will look back at the Hackathon workboard when trying to find something they are interested in).
- In case there is nothing else to do for this task, or nobody plans to work on this task anymore: Please set the task status to declined.
Thank you,
Phabricator housekeeping service