From f51012e8668b7911aabbb8b17ef7b8e47acccc1f Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 17 Oct 2025 16:02:20 +0100 Subject: [PATCH] Fixes for translations --- script.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/script.js b/script.js index 3dd7081..3e49ef3 100644 --- a/script.js +++ b/script.js @@ -17,7 +17,7 @@ let property_list = []; mw.hook( 'wikibase.entityPage.entityLoaded' ).add( function ( data ) { - let valid_values = ['item', 'lexeme', 'property'] + let valid_values = ['item', 'lexeme', 'property']; if (!valid_values.includes(data["type"])) { return; } mw.util.addSubtitle(entityschema_getHTML()); @@ -189,7 +189,7 @@ let shape_html = ""; let response1 = properties[key].response.combined; let response_class = ""; - let response_string = properties[key].response.combined;; + let response_string = properties[key].response.combined; switch (response1) { case "present": response_class = "present"; @@ -223,18 +223,19 @@ response_string = entityschema_translate("Not in schema"); response_class = "notinschema"; } + let schema_link = `${properties[key].name} (${key})`; if (response1 == null) { response1 = ""; - shape_html += `${key} - ${properties[key].name}
`; + shape_html += `${schema_link}
`; } else if (response1 == "Not in schema") { other_array.push(key); - other_array_names.push(properties[key].name); + other_array_names.push(schema_link); } else { shape_html += `
  • ${response_string} - ${key} - ${properties[key].name}
  • ` + ${schema_link}`; } switch (properties[key].necessity.combined) { case "required": @@ -253,7 +254,7 @@ for (let item in other_array) { other_html += `
  • ${entityschema_translate("Not in schema")} ${other_array[item]} - ${other_array_names[item]}
  • `; + class="is_entityschema-notinschema">${other_array_names[item]}`; } other_html += ""; absent_html += "" + other_html; @@ -440,11 +441,12 @@ "not allowed": "ní cheadaítear", "Not in schema": "ní sa scéim" } + }; + let language = "en"; + if (translations.hasOwnProperty(lang)) { + language = lang; } - if (!translations.hasOwnProperty(lang)) { - language = "en"; - } - return translations[lang][phrase]; + return translations[language][phrase]; } function entityschema_getStylesheet() { @@ -491,7 +493,7 @@ .entityshape-spinner div:nth-child(10) { transform: rotate(270deg); animation-delay: -0.2s;} .entityshape-spinner div:nth-child(11) { transform: rotate(300deg); animation-delay: -0.1s;} .entityshape-spinner div:nth-child(12) { transform: rotate(330deg); animation-delay: 0s;} - @keyframes entityshape-spinner { 0% { opacity: 1; } 100% { opacity: 0; }}` + @keyframes entityshape-spinner { 0% { opacity: 1; } 100% { opacity: 0; }}`; return entityschema_stylesheet; } @@ -533,7 +535,7 @@ - ` + `; return entityschema_results_html; } -}()); \ No newline at end of file +}());