Start localization of the Wikidata extension

This commit is contained in:
Antonin Delpeuch 2018-01-08 20:14:13 +00:00
parent af4df335de
commit 2795a54ea2
4 changed files with 94 additions and 18 deletions

View File

@ -0,0 +1,42 @@
{
"wikidata-schema": {
"dialog-header": "Align to Wikidata",
"dialog-explanation": "The schema alignment skeleton below specifies how your tabular data will be transformed into Wikibase statements. You can drag and drop columns in statements: they will be replaced by their values once you export the statements.",
"schema-tab-header": "Schema",
"warnings-tab-header": "Issues",
"qs-preview-tab-header": "QuickStatements preview",
"draggable-columns-header": "Columns:",
"add-item-button": "add item",
"invalid-schema-warning-issues": "Your schema is incomplete, fix it to see the issues.",
"invalid-schema-warning-qs": "Your schema is incomplete, fix it to see the preview.",
"reset-button": "Reset",
"save-button": "Save",
"close-button": "Close"
},
"warnings-messages": {
"new-item-created": {
"title": "This batch will create new Wikidata items.",
"body": "Please make sure that these items do not exist yet and are suitable for inclusion in Wikidata."
},
"new-item-without-labels-or-aliases": {
"title": "Some new items will be created without any label or alias.",
"body": "You should at least provide one label, so that others can understand what the item is about."
},
"new-item-without-descriptions": {
"title": "Some new items will be created without any description.",
"body": "Adding descriptions will make it easier to disambiguate them from namesakes."
},
"new-item-with-deleted-statements": {
"title": "You are trying to delete statements on new items.",
"body": "There is probably something wrong in your schema or project."
},
"new-item-without-P31-or-P279": {
"title": "Some new items will be created without any type.",
"body": "You should provide an \"instance of\" (P31) or \"subclass of\" (P279) statement for each item that you create."
},
"statement-without-reference": {
"title": "Some statements are not referenced.",
"body": "Please provide references for the statements that you add."
}
}
}

View File

@ -1,51 +1,47 @@
<div class="dialog-frame" style="width: 800px;">
<div class="dialog-header" bind="dialogHeader">Align to Wikibase</div>
<div class="dialog-header" bind="dialogHeader"></div>
<div class="dialog-body" bind="dialogBody">
<p class="body-text">
The schema alignment skeleton below specifies how your tabular data will be
transformed into Wikibase statements. You can drag and drop columns in statements:
they will be replaced by their values once you export the statements.
</p>
<p class="body-text" bind="dialogExplanation"></p>
<div id="schema-alignment-tabs" class="refine-tabs">
<ul>
<li><a href="#schema-alignment-tabs-schema">Schema</a></li>
<li><a href="#schema-alignment-tabs-warnings">Warnings</a></li>
<li><a href="#schema-alignment-tabs-preview-qs">QuickStatements preview</a></li>
<li><a href="#schema-alignment-tabs-schema" bind="schemaTabHeader"></a></li>
<li><a href="#schema-alignment-tabs-warnings" bind="warningsTabHeader"></a></li>
<li><a href="#schema-alignment-tabs-preview-qs" bind="qsPreviewTabHeader"></a></li>
</ul>
<div id="schema-alignment-tabs-schema">
<div class="schema-alignment-dialog-canvas">
<p class="schema-alignment-columns-header">Columns:</p>
<p class="schema-alignment-columns-header" bind="draggableColumnsHeader"></p>
<div class="schema-alignment-dialog-columns-area">
</div>
<div class="schema-alignment-dialog-statements-area">
<div id="schema-alignment-statements-container">
</div>
<div class="wbs-toolbar"><a class="wbs-add-item" bind="addItemButton">add item</a></div>
<div class="wbs-toolbar"><a class="wbs-add-item" bind="addItemButton"></a></div>
</div>
</div>
</div>
<div id="schema-alignment-tabs-warnings" style="display: none;">
<div class="invalid-schema-warning">Your schema is incomplete, fix it to see the warnings.</div>
<div class="invalid-schema-warning" bind="invalidSchemaWarningIssues"></div>
<div class="schema-alignment-dialog-warnings" bind="warningsArea"></div>
</div>
<div id="schema-alignment-tabs-preview-qs" style="display: none;">
<div class="invalid-schema-warning">Your schema is incomplete, fix it to see the preview.</div>
<div class="invalid-schema-warning" bind="invalidSchemaWarningQs"></div>
<div class="schema-alignment-dialog-preview"></div>
</div>
</div>
</div>
<div class="dialog-footer" bind="dialogFooter"><div class="grid-layout layout-normal layout-full"><table><tr>
<td>
<button class="button" bind="resetButton">Reset</button>
<button class="button" bind="resetButton"></button>
</td>
<td style="text-align:right;">
<button class="button button-primary" bind="saveButton">Save</button>
<button class="button button-primary" bind="saveButton"></button>
</td>
<td style="text-align:center;" width="30%">
<span class="schema-alignment-status-indicator" bind="statusIndicator"></span>
</td>
<td style="text-align:right;" width="1%">
<button class="button" bind="closeButton">Close</button>
<button class="button" bind="closeButton"></button>
</td>
</tr></table></div></div>
</div>

View File

@ -153,6 +153,19 @@ SchemaAlignmentDialog._createDialog = function() {
var frame = $(DOM.loadHTML("wikidata", "scripts/dialogs/schema-alignment-dialog.html"));
var elmts = this._elmts = DOM.bind(frame);
this._elmts.dialogHeader.text($.i18n._('wikidata-schema')["dialog-header"]);
this._elmts.dialogExplanation.text($.i18n._('wikidata-schema')["dialog-explanation"]);
this._elmts.schemaTabHeader.text($.i18n._('wikidata-schema')["schema-tab-header"]);
this._elmts.warningsTabHeader.text($.i18n._('wikidata-schema')["warnings-tab-header"]);
this._elmts.qsPreviewTabHeader.text($.i18n._('wikidata-schema')["qs-preview-tab-header"]);
this._elmts.draggableColumnsHeader.text($.i18n._('wikidata-schema')["draggable-columns-header"]);
this._elmts.addItemButton.text($.i18n._('wikidata-schema')["add-item-button"]);
this._elmts.invalidSchemaWarningIssues.text($.i18n._('wikidata-schema')["invalid-schema-warning-issues"]);
this._elmts.invalidSchemaWarningQs.text($.i18n._('wikidata-schema')["invalid-schema-warning-qs"]);
this._elmts.resetButton.text($.i18n._('wikidata-schema')["reset-button"]);
this._elmts.saveButton.text($.i18n._('wikidata-schema')["save-button"]);
this._elmts.closeButton.text($.i18n._('wikidata-schema')["close-button"]);
this._level = DialogSystem.showDialog(frame);
this._wikibasePrefix = "http://www.wikidata.org/entity/"; // hardcoded for now
@ -850,6 +863,13 @@ SchemaAlignmentDialog.preview = function(initial) {
*************************/
SchemaAlignmentDialog._renderWarning = function(warning) {
var localized = $.i18n._('warnings-messages')[warning.type];
var title = warning.type;
var body = "";
if (localized) {
title = localized.title;
body = localized.body;
}
var tr = $('<tr></tr>').addClass('wb-warning');
var severityTd = $('<td></td>')
.addClass('wb-warning-severity')
@ -859,10 +879,10 @@ SchemaAlignmentDialog._renderWarning = function(warning) {
.addClass('wb-warning-body')
.appendTo(tr);
var h1 = $('<h1></h1>')
.text(warning.type)
.text(title)
.appendTo(bodyTd);
var p = $('<p></p>')
.text('Lorem ipsum')
.text(body)
.appendTo(bodyTd);
var countTd = $('<td></td>')
.addClass('wb-warning-count')

View File

@ -1,3 +1,21 @@
// Load the localization file
var dictionary = {};
$.ajax({
url : "command/core/load-language?",
type : "POST",
async : false,
data : {
module : "wikidata",
// lang : lang
},
success : function(data) {
dictionary = data;
}
});
$.i18n.setDictionary(dictionary);
ExporterManager.MenuItems.push({});
ExporterManager.MenuItems.push(
{