Skip to content

Commit 2cc5de9

Browse files
committed
#482 show really used locales in translate modal
1 parent c89cda3 commit 2cc5de9

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/js/service/data/localStorageService.js

-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ let SYNCED_DBS_LIST_KEY = 'SYNCED_DBS_LIST_KEY';
99
let LAST_ACTIVEUSER_KEY = 'LAST_ACTIVEUSER_KEY';
1010
let AUTOLOGIN_USER_KEY = 'AUTOLOGIN_USER_KEY';
1111
let GRID_DIMENSIONS_KEY = 'AG_GRID_DIMENSIONS_KEY';
12-
let USED_LOCALES_KEY = 'AG_USED_LOCALES_KEY';
1312
let CURRENT_VERSION_KEY = 'AG_CURRENT_VERSION_KEY';
1413
let APP_SETTINGS = 'AG_APP_SETTINGS';
1514
let USER_SETTINGS = 'AG_USER_SETTINGS';
@@ -316,18 +315,6 @@ localStorageService.getLastGridDimensions = function () {
316315
return json ? JSON.parse(json) : {};
317316
};
318317

319-
localStorageService.addUsedLocales = function (toAddArray) {
320-
let json = localStorageService.get(USED_LOCALES_KEY);
321-
let array = json ? JSON.parse(json) : [];
322-
array = [...new Set(array.concat(toAddArray))];
323-
localStorageService.save(USED_LOCALES_KEY, JSON.stringify(array));
324-
};
325-
326-
localStorageService.getUsedLocales = function () {
327-
let json = localStorageService.get(USED_LOCALES_KEY);
328-
return json ? JSON.parse(json) : [];
329-
};
330-
331318
localStorageService.getCurrentAppVersion = function () {
332319
return localStorageService.get(CURRENT_VERSION_KEY);
333320
};

src/vue-components/modals/gridTranslateModal.vue

+7-3
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
chosenLocale: i18nService.isCurrentContentLangEN() ? 'de' : 'en',
160160
GridActionSpeakCustom: GridActionSpeakCustom,
161161
allLanguages: i18nService.getAllLanguages(),
162-
usedLocales: localStorageService.getUsedLocales(),
162+
usedLocales: [],
163163
changedGrids: [],
164164
shouldShowMap: {} // element-id or action-id => boolean, tells if element should be shown in translate view
165165
}
@@ -191,8 +191,6 @@
191191
methods: {
192192
save() {
193193
let thiz = this;
194-
let data = thiz.gridData || thiz.allGrids[0];
195-
localStorageService.addUsedLocales(Object.keys(data.label));
196194
dataService.saveGrids(JSON.parse(JSON.stringify(thiz.changedGrids))).then(() => {
197195
thiz.$emit('reload');
198196
thiz.$emit('close');
@@ -288,8 +286,14 @@
288286
let anyLabel = Object.keys(element.label).some(lang => !!element.label[lang]);
289287
let hasImage = element.image && (element.image.url || element.image.data);
290288
this.shouldShowMap[element.id] = anyLabel || hasImage;
289+
for (let lang of Object.keys(element.label)) {
290+
if (!this.usedLocales.includes(lang) && !!element.label[lang]) {
291+
this.usedLocales.push(lang);
292+
}
293+
}
291294
}
292295
}
296+
this.usedLocales.sort((a, b) => this.getLocaleTranslation(a).localeCompare(this.getLocaleTranslation(b)));
293297
});
294298
}
295299
}

0 commit comments

Comments
 (0)