Commit 665aeee0 authored by Eirik Alvær's avatar Eirik Alvær

Added translation using i18next.js.

parent 29cb8f9b
......@@ -34,13 +34,15 @@
"http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js",
"http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.min.js",
"http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/js/bootstrap.min.js",
"libraries/i18next-1.6.3.js",
// Our own scripts
"js/init.js",
"js/common.js",
"js/model.js",
"js/templates-loader.js",
"js/metadata-maker.js",
"js/controller.js"
);
);
</script>
</body>
......
......@@ -3,10 +3,6 @@ function loadFromRestServer(urlEnding, successFunction) {
robustAjax(url, "json", true, successFunction);
}
function loadSyncFromRestServer(urlEnding) {
return syncAjax(Model.restServerURL + "/" + urlEnding, "json");
}
function getJSON(urlString, successFunction) {
robustAjax(urlString, "json", true, successFunction);
}
......@@ -42,5 +38,10 @@ function robustAjax(urlString, dataType, isAsync, successFunction) {
}
function getTranslation(text) {
return text;
if (text == null) {
return null;
}
else {
return i18n.t(text);
}
}
\ No newline at end of file
i18n.init({
fallbackLng: 'en',
debug: true,
getAsync: false,
resGetPath: 'locales/__ns__.__lng__.json'
});
Handlebars.registerHelper('t', function(i18n_key) {
var result = i18n.t(i18n_key);
return new Handlebars.SafeString(result);
});
\ No newline at end of file
......@@ -31,7 +31,7 @@ function getMetadataHtml(metadataSelection, metadata) {
function getHeadingHtml(metadataSelection, metadata) {
var templateObject = {}
templateObject.heading = metadataSelection.heading;
templateObject.heading = getTranslation(metadataSelection.heading);
return metadataHeadingTemplate(templateObject);
}
......@@ -52,7 +52,7 @@ function getLabel(label, field) {
if (label == "--default--") {
var fields = field.split('.');
var lastField = fields[fields.length-1];
return Model.metadataTranslation[lastField];
return getTranslation("metadataTranslation." + lastField);
}
else {
return getTranslation(label);
......
......@@ -8,7 +8,7 @@ var Model = {
"correlation" : null,
"backRoutes" : [],
"currentAnalysisType" : "", // tabulation / regression / correlation
"currentVariableStore" : "" // rowVariableIds / columnVariableIds /measureVariableId / dependentVariableId / independentVariableIds
"currentVariableStore" : "" // rowVariableIds / columnVariableIds / measureVariableId / dependentVariableId / independentVariableIds
},
"urlObjectSaved" : false,
......@@ -62,8 +62,6 @@ Model.studyMetadataSelection = getSyncJSON("/metadata-selection/study-metadata-s
Model.variableMetadataSelection = getSyncJSON("/metadata-selection/variable-metadata-selection.json");
Model.metadataTranslation = loadSyncFromRestServer("metadata-translation/en").metadataTranslation;
function initNewTabulation() {
Model.urlObject.tabulation = new Tabulation();
Model.urlObject.currentAnalysisType = "tabulation";
......
This diff is collapsed.
This diff is collapsed.
{
"headings" : {
"studies" : "Studies",
"variables" : "Variables",
"study_description" : "Study Description",
"variable_description" : "Variable Description",
"label" : "Label"
},
"buttons" : {
"back" : "back",
"use_variable" : "use variable"
},
"metadataTranslation" : {
"docDscr" : "Document Description",
"citation" : "Citation",
"titlStmt" : "Title Statement",
"titl" : "Title",
"subTitl" : "Subtitle",
"altTitl" : "Alternative Title",
"parTitl" : "Parallel Title",
"IDNo" : "ID Number",
"rspStmt" : "Responsibility Statement",
"AuthEnty" : "Authoring Entities / Primary Investigators",
"affiliation" : "Affiliation",
"othId" : "Other Identifications / Acknowledgement",
"role" : "Role",
"p" : "Name",
"prodStmt" : "Production Statement",
"producer" : "Producers",
"abbr" : "Abbrevation",
"copyright" : "Copyright",
"prodDate" : "Date of Production",
"date" : "Date",
"prodPlace" : "Place of Production",
"software" : "Software",
"fundAg" : "Funding Agents",
"grantNo" : "Grant Numbers",
"distStmt" : "Distribution Statement",
"distrbtr" : "Distributors",
"URI" : "URI",
"depDate" : "Date of Deposit",
"distDate" : "Date of Distribution",
"serStmt" : "Series Statement",
"serName" : "Series Name",
"serInfo" : "Series Information",
"ExtLink" : "External Link",
"verStmt" : "Version Statement",
"version" : "Version",
"type" : "Type",
"verResp" : "Version Responsibility",
"notes" : "Notes",
"biblCit" : "Bibliographic Citation",
"holdings" : "Holdings",
"location" : "Location",
"callno" : "Call Number",
"guide" : "Guide to the Documentation",
"docStatus" : "Documentation Status",
"docSrc" : "Documentation Source",
"contact" : "Contact Persons",
"email" : "Email",
"depositr" : "Depositors",
"stdyDscr" : "Study Description",
"stdyInfo" : "Study Information",
"subject" : "Subject / Study Scope",
"keyword" : "Keywords",
"vocab" : "Vocabulary",
"vocabURI" : "Vocabulary URI",
"topcClas" : "Topic Classifications",
"abstract" : "Abstract",
"sumDscr" : "Summary Data Description",
"timePrd" : "Time Periods",
"event" : "Event",
"cycle" : "Cycle",
"collDate" : "Dates of Collection",
"nation" : "Nations",
"geogCover" : "Geographic Coverage",
"geogUnit" : "Geographic Unit",
"anlyUnit" : "Unit of Analysis",
"universe" : "Universe",
"dataKind" : "Kind of Data",
"method" : "Method",
"dataColl" : "Data Collection Methodology",
"timeMeth" : "Time Method",
"dataCollector" : "Data Collectors",
"frequenc" : "Frequency of Data Collection",
"sampProc" : "Sampling Procedure",
"deviat" : "Major Deviations From the Sample Design",
"collMode" : "Mode of Data Collection",
"resInstru" : "Type of Research Instrument",
"sources" : "Sources",
"dataSrc" : "Data Sources",
"collSitu" : "Characteristics of the Data Collection Situation",
"actMin" : "Actions to Minimize Losses",
"ConOps" : "Control Operations",
"weight" : "Weighting",
"cleanOps" : "Cleaning Operations",
"anlyInfo" : "Data Appraisal Information",
"respRate" : "Response Rates",
"EstSmpErr" : "Estimates of Sampling Error",
"dataAppr" : "Other Forms of Data Appraisal",
"stdyClas" : "Class or Status of the Study",
"dataAccs" : "Data Access",
"setAvail" : "Dataset Availability",
"media" : "Media",
"accsPlac" : "Locations of Data Collection",
"origArch" : "Original Archive Where Collection Stored",
"avlStatus" : "Availability Status",
"collSize" : "Extent of Collection",
"complete" : "Completeness of Collection Stored",
"fileQnty" : "Number of Files",
"useStmt" : "Data Use Statement",
"confDec" : "Confidentiality Declaration",
"required" : "Required",
"formNo" : "Form Number",
"specPerm" : "Special Permissions",
"restrctn" : "Restrictions",
"citReq" : "Citation Requirement",
"deposReq" : "Deposit Requirement",
"conditions" : "Access Conditions",
"disclaimer" : "Disclaimer",
"othrStdyMat" : "Other Study Materials",
"relMat" : "Related Materials",
"relStdy" : "Related Studies",
"relPubl" : "Related Publications",
"othRefs" : "Other References",
"fileDscr" : "File Description",
"fileTxt" : "File Description",
"fileName" : "File Name",
"fileCont" : "File Contents",
"dimensns" : "Dimensions",
"caseQnty" : "Case Quantity",
"varQnty" : "Variable Quantity",
"fileType" : "File Type",
"filePlac" : "Place of File Production",
"dataChck" : "Extent of Processing Checks",
"ProcStat" : "Processing Status",
"dataMsng" : "Missing Data",
"dataDscr" : "Data Description",
"varGrp" : "Variable Groups",
"labl" : "Label",
"txt" : "Text",
"defntn" : "Definition",
"var" : "Variables",
"dcml" : "Decimals",
"files" : "Files",
"intrvl" : "Measure Type",
"RecSegNo" : "Record",
"imputation" : "Imputation",
"security" : "Security",
"embargo" : "Embargo",
"respUnit" : "Response Unit",
"anlysUnit" : "Analysis Unit",
"qstn" : "Questions",
"preQTxt" : "Pre-Quetion Text",
"qstnLit" : "Literal Question",
"postQTxt" : "Post-Question Text",
"ivuInstr" : "Interviewer Instructions",
"undocCod" : "Undocumented Codes",
"TotlResp" : "Total Responses",
"sumStat" : "Summary Statistics",
"stdCatgry" : "Standard Categories",
"catgry" : "Categories",
"catValu" : "Category Value",
"codInstr" : "Coding instructions",
"concept" : "Concepts",
"varFormat" : "Variable Format",
"schema" : "Schema",
"otherMat" : "Other Materials",
"valrng" : "Value Range",
"range" : "Range",
"UNITS" : "Units",
"min" : "Minimum",
"max" : "Maximum"
}
}
\ No newline at end of file
[
{
"type" : "heading",
"heading" : "Study Description"
"heading" : "headings.study_description"
},
{
"type" : "table",
......@@ -11,13 +11,13 @@
},
{
"type" : "text",
"heading" : "Abstract",
"heading" : "--default--",
"field" : "studyMetadata.stdyDscr.stdyInfo.abstract",
"innerFields" : [{"content" : null}]
},
{
"type" : "text",
"heading" : "Version",
"heading" : "--default--",
"field" : "studyMetadata.stdyDscr.citation.verStmt.version",
"innerFields" : [{"content" : null}, {"date" : "--default--"}, {"type" : "--default--"}]
},
......
[
{
"type" : "heading",
"heading" : "Variable Description"
"heading" : "headings.variable_description"
},
{
"type" : "text",
"heading" : "Label",
"heading" : "headings.label",
"field" : "variable",
"innerFields" : [{"labl" : null}]
},
......
<script id="studiesTemplate" type="text/x-handlebars-template">
<h1>Studies</h1>
<h1>{{t "headings.studies"}}</h1>
<ul class="nav nav-tabs nav-stacked">
{{#each studies}}
<li><a href="/#goto/studyMetadata/{{id}}">{{name}}</a></li>
......
<script id="studyMetadataTemplate" type="text/x-handlebars-template">
<p><a href="/#goBack">back</a></p>
<h2>variables</h2>
<p><a href="/#goBack">{{t "buttons.back"}}</a></p>
<h2>{{t "headings.variables"}}</h2>
{{#each variables}}
<p><a href="#goto/variableMetadata/{{id}}">{{label}}</a></p>
{{/each}}
......
<script id="variableMetadataTemplate" type="text/x-handlebars-template">
<p><a href="/#goBack">back</a></p>
<p><a href="/#useVariableAndGoBack/{{variableId}}">use variable</a></p>
<p><a href="/#goBack">{{t "buttons.back"}}</a></p>
<p><a href="/#useVariableAndGoBack/{{variableId}}">{{t "buttons.use_variable"}}</a></p>
<div id="variableMetadata">
</div>
</script>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment