TagSpaces is an offline, open source, document manager with tagging support
adding internationalization for the getting started guide
uggrockc17b2ca82eff
diff --git a/data/js/core.api.js b/data/js/core.api.jsindex 88a248cc8..14fbab5f5 100644--- a/data/js/core.api.js+++ b/data/js/core.api.js@@ -82,52 +82,63 @@ define(function(require, exports, module) {$(document).ready(function() {reLayout();+ var browserLang = navigator.language || navigator.userLanguage;+var language = tsSettings.getInterfaceLangauge();// "de-DE"- var langURLParam = getParameterByName('locale');- if (langURLParam.length > 1) {+ var langURLParam = tsUtils.getURLParameter('locale');+ if (langURLParam && langURLParam.length > 1) {language = langURLParam;}- switchInterfaceLanguage(language);++ switchInterfaceLanguage(language).then(function() {+ if (isNode || isElectron) {+ tsIOApi.initMainMenu();+ }++ if (tsSettings.isFirstRun()) {+ // Show welcome dialog of first start+ tsCoreUI.showWelcomeDialog();+ } else if (tsSettings.Settings.tagspacesList.length < 1) {+ // Show getting started guide by no locations+ tsCoreUI.startGettingStartedTour();+ }+ }).catch(function() {+ console.warn("Language switching failed.");+ });+initKeyBindings();tsIOApi.checkAccessFileURLAllowed ? tsIOApi.checkAccessFileURLAllowed() : true;- // Show welcome dialog of first start- if (tsSettings.isFirstRun()) {- tsCoreUI.showWelcomeDialog();- }- // Show welcome dialog by no locations- if (tsSettings.Settings.tagspacesList.length < 1) {- tsCoreUI.startGettingStartedTour();- }+if (isNode || isChrome || isElectron || isWeb) {// Handle command line argument in node-webkittsIOApi.handleStartParameters(); // Handle minimizing to the tray in node-webkit}- console.log('Docoument ready finished. Layout initialized');+ console.log('Document ready finished. Layout initialized');checkForNewVersion();});}function switchInterfaceLanguage(language) {- $.i18n.init({- ns: {- namespaces: [- 'ns.common',- 'ns.dialogs',- 'ns.perspectiveList',- 'ns.pro',- ]- },- lng: language,- debug: true,- fallbackLng: 'en_US'- }, function() {- $('[data-i18n]').i18n();- if (isNode || isElectron) {- tsIOApi.initMainMenu();- }- });exports.currentLanguage = language;+ return new Promise(function(resolve, reject) {+ $.i18n.init({+ ns: {+ namespaces: [+ 'ns.common',+ 'ns.dialogs',+ 'ns.perspectiveList',+ 'ns.pro',+ ]+ },+ lng: language,+ debug: true,+ fallbackLng: 'en_US'+ }, function() {+ $('[data-i18n]').i18n();+ resolve();+ });+ });}function initKeyBindings() {@@ -174,13 +185,6 @@ define(function(require, exports, module) {}}- function getParameterByName(name) {- name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');- var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'),- results = regex.exec(location.search);- return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));- }-function updateNewVersionData(data) {console.log('Version Information: ' + data);var versioningData = JSON.parse(data);@@ -479,7 +483,6 @@ define(function(require, exports, module) {exports.removeFileModel = removeFileModel;exports.updateFileModel = updateFileModel;exports.switchInterfaceLanguage = switchInterfaceLanguage;- exports.getParameterByName = getParameterByName;// Proxying functions from tsCoreUI// TODO use TSCORE.UI insteaddiff --git a/data/js/gettingstarted.js b/data/js/gettingstarted.jsindex 2113458e6..0977f9977 100644--- a/data/js/gettingstarted.js+++ b/data/js/gettingstarted.js@@ -12,15 +12,30 @@ define(function(require, exports, module) {"css!libs/hopscotch/dist/css/hopscotch.min.css",], function() {});- var nextI18N = $.i18n.t('ns.dialogs:titleWaiting'); // not working- //console.log("nextI18N "+ nextI18N);+ function closeTour() {+ $('#openLeftPanel').click();+ $("#locationsList").css("display", "");+ $("#createNewLocation").removeClass("uiEmphasizer");+ $('#tagGroupsContent').removeClass("uiEmphasizer");+ $('#contactUsContent').removeClass("uiEmphasizer");+ $('#closeLeftPanel').removeClass("uiEmphasizer");+ $('.col1 .row2').removeClass("uiEmphasizer");+ $('#viewContainers').removeClass("uiEmphasizer");+ $('#showSearchButton').removeClass("uiEmphasizer");+ $('#perspectiveSwitcherButton').removeClass("uiEmphasizer");+ $('#openLeftPanel').removeClass("uiEmphasizer");+ $('#openOptions').removeClass("uiEmphasizer");+ }- var tour = {+ exports.closeTour = closeTour();++ exports.startTour = function() {+ var tour = {id: "gettingstarted",steps: [{- title: "Welcome to TagSpaces!",- content: "Start using TagSpaces by choosing a location from your locale storage.",+ title: $.i18n.t('ns.common:welcomeTitle'),+ content: $.i18n.t('ns.common:welcomeContent'),target: "locationName",placement: "bottom",onNext: function() {@@ -182,28 +197,10 @@ define(function(require, exports, module) {showNextButton: true,showPrevButton: true, // disable in productioni18n: {- nextBtn: nextI18N,+ //nextBtn: nextI18N,}};- function closeTour() {- $('#openLeftPanel').click();- $("#locationsList").css("display", "");- $("#createNewLocation").removeClass("uiEmphasizer");- $('#tagGroupsContent').removeClass("uiEmphasizer");- $('#contactUsContent').removeClass("uiEmphasizer");- $('#closeLeftPanel').removeClass("uiEmphasizer");- $('.col1 .row2').removeClass("uiEmphasizer");- $('#viewContainers').removeClass("uiEmphasizer");- $('#showSearchButton').removeClass("uiEmphasizer");- $('#perspectiveSwitcherButton').removeClass("uiEmphasizer");- $('#openLeftPanel').removeClass("uiEmphasizer");- $('#openOptions').removeClass("uiEmphasizer");- }-- exports.closeTour = closeTour();-- exports.startTour = function() {// Start the tour!TSCORE.openLeftPanel();hopscotch.startTour(tour);diff --git a/data/js/utils.js b/data/js/utils.jsindex 25cd98649..93482a91f 100644--- a/data/js/utils.js+++ b/data/js/utils.js@@ -90,6 +90,13 @@ define(function(require, exports, module) {return false;}+ /*function getParameterByName(name) {+ name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');+ var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'),+ results = regex.exec(location.search);+ return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));+ }*/+exports.arrayBufferToDataURL = arrayBufferToDataURL;exports.base64ToArrayBuffer = base64ToArrayBuffer;exports.dataURLtoBlob = dataURLtoBlob;diff --git a/data/locales/en_US/ns.common.json b/data/locales/en_US/ns.common.jsonindex 78a905da6..1b3331481 100644--- a/data/locales/en_US/ns.common.json+++ b/data/locales/en_US/ns.common.json@@ -181,5 +181,7 @@"directoryRenameFailed": "Directory renaming failed!","functionalityNotImplemented" : "This functionality is not implemented yet.","invalidImportFile": "The imported file has invalid format",+ "welcomeTitle": "Welcome to TagSpaces!",+ "welcomeContent": "Start using TagSpaces by choosing a location from your locale storage.","-": "-"}\ No newline at end of file