From 7dc2b28c44b82fef7dd062118e359d26db169776 Mon Sep 17 00:00:00 2001 From: Franzz Date: Sat, 25 Apr 2026 19:36:03 +0200 Subject: [PATCH] Get the language module out of spot.js --- src/components/admin.vue | 12 ++++---- src/components/project.vue | 44 ++++++++++++++--------------- src/components/projectMapLink.vue | 6 ++-- src/components/projectMediaLink.vue | 6 ++-- src/components/projectPopup.vue | 8 +++--- src/components/projectPost.vue | 26 ++++++++--------- src/components/projectRelTime.vue | 6 ++-- src/components/upload.vue | 30 ++++++++++---------- src/scripts/app.js | 34 +++++++++------------- src/scripts/lang.js | 4 +-- src/scripts/spot.js | 19 ++++--------- 11 files changed, 89 insertions(+), 106 deletions(-) diff --git a/src/components/admin.vue b/src/components/admin.vue index 4e1af91..9b0e082 100644 --- a/src/components/admin.vue +++ b/src/components/admin.vue @@ -9,7 +9,7 @@ export default { SpotButton, AdminInput }, - inject: ['spot'], + inject: ['spot', 'lang'], data() { return { elems: {}, @@ -22,7 +22,7 @@ export default { }, methods: { l(id) { - return this.spot.lang(id); + return this.lang.get(id); }, setEvents() { this.spot.addPage('admin', { @@ -57,7 +57,7 @@ export default { for(const [iKey, oNewElem] of Object.entries(aoNewElems)) { oNewElem.type = sType; this.elems[sType][oNewElem.id] = oNewElem; - this.spot.onFeedback('success', this.spot.lang('admin_create_success'), {'create':sType}); + this.spot.onFeedback('success', this.lang.get('admin_create_success'), {'create':sType}); } } }) @@ -73,7 +73,7 @@ export default { 'admin_delete', (asData) => { delete this.elems[asInputs.type][asInputs.id]; - this.spot.onFeedback('success', this.spot.lang('admin_delete_success'), asInputs); + this.spot.onFeedback('success', this.lang.get('admin_delete_success'), asInputs); }, asInputs, (sError) => { @@ -97,7 +97,7 @@ export default { this.spot.get2('admin_set', asInputs) .then((asData) => { this.elems[oElem.type][oElem.id][oEvent.target.name] = sNewVal; - this.spot.onFeedback('success', this.spot.lang('admin_save_success'), asInputs); + this.spot.onFeedback('success', this.lang.get('admin_save_success'), asInputs); }) .catch((sError) => { oEvent.target.value = sOldVal; @@ -232,4 +232,4 @@ export default {

{{ feedback.msg }}

- \ No newline at end of file + diff --git a/src/components/project.vue b/src/components/project.vue index 0a77a4f..0845de1 100644 --- a/src/components/project.vue +++ b/src/components/project.vue @@ -87,7 +87,7 @@ export default { project: this }; }, - inject: ['spot', 'hash', 'projects', 'user'], + inject: ['spot', 'lang', 'hash', 'projects', 'user'], beforeMount() { if(this.hash.items.length == 0) this.hash.items[0] = this.spot.vars('default_project_codename'); }, @@ -399,7 +399,7 @@ export default { medias: [oMedia], project: this.currProject }); - this.popup.content.provide('spot', this.spot).mount($Popup); + this.popup.content.provide('spot', this.spot).provide('lang', this.lang).mount($Popup); }, openMarkerPopup(oFeature) { this.closeMarkerPopup(); @@ -434,7 +434,7 @@ export default { medias: JSON.parse(oFeature.properties.medias || '[]'), project: this.currProject }); - this.popup.content.provide('spot', this.spot).mount($Popup); + this.popup.content.provide('spot', this.spot).provide('lang', this.lang).mount($Popup); }, closeMarkerPopup() { if(this.popup.content) { @@ -524,14 +524,14 @@ export default { getGoogleMapsLink(asInfo) { return $('', { href:'https://www.google.com/maps/place/'+asInfo.lat_dms+'+'+asInfo.lon_dms+'/@'+asInfo.latitude+','+asInfo.longitude+',10z', - title: this.spot.lang('see_on_google'), + title: this.lang.get('see_on_google'), target: '_blank', rel: 'noreferrer noopener' }).text(asInfo.lat_dms+' '+asInfo.lon_dms); }, async manageSubs() { var regexEmail = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; - if(!regexEmail.test(this.user.email)) this.nlFeedbacks.push({type:'error', 'msg':this.spot.lang('nl_invalid_email')}); + if(!regexEmail.test(this.user.email)) this.nlFeedbacks.push({type:'error', 'msg':this.lang.get('nl_invalid_email')}); else { this.spot.get2(this.nlAction, {'email': this.user.email, 'name': this.user.name}, this.nlLoading) .then((asUser, sDesc) => { @@ -641,19 +641,19 @@ export default {
-

{{ spot.lang('last_update')+' '+lastUpdate.relative_time }}

+

{{ lang.get('last_update')+' '+lastUpdate.relative_time }}

-

+

+ @@ -661,36 +661,36 @@ export default {
-

+

- +
-

- - +

+ +
+ + + {{ lang.get('credits_license') }}
@@ -698,7 +698,7 @@ export default {
- {{ spot.lang('track_'+hikeType) }} + {{ lang.get('track_'+hikeType) }}
@@ -709,7 +709,7 @@ export default {
- +
diff --git a/src/components/projectMapLink.vue b/src/components/projectMapLink.vue index 8bb947c..6619aaf 100644 --- a/src/components/projectMapLink.vue +++ b/src/components/projectMapLink.vue @@ -3,15 +3,15 @@ export default { props: { options: Object }, - inject: ['spot'] + inject: ['lang'] } \ No newline at end of file + diff --git a/src/components/projectMediaLink.vue b/src/components/projectMediaLink.vue index 603e63b..05e4aff 100644 --- a/src/components/projectMediaLink.vue +++ b/src/components/projectMediaLink.vue @@ -16,7 +16,7 @@ export default { title:'' } }, - inject: ['spot'], + inject: ['lang'], mounted() { this.title = (this.$refs.comment?this.$refs.comment.outerHTML:'') + @@ -47,7 +47,7 @@ export default { :src="options.thumb_path" :width="options.width" :height="options.height" - :title="spot.lang((options.subtype == 'video')?'click_watch':'click_zoom')" + :title="lang.get((options.subtype == 'video')?'click_watch':'click_zoom')" class="clickable" /> @@ -64,4 +64,4 @@ export default {
- \ No newline at end of file + diff --git a/src/components/projectPopup.vue b/src/components/projectPopup.vue index 0bbcb88..928f0c2 100644 --- a/src/components/projectPopup.vue +++ b/src/components/projectPopup.vue @@ -18,7 +18,7 @@ export default { medias: Array, project: Object }, - inject: ['spot'], + inject: ['spot', 'lang'], computed: { timeIcon() { return (this.type == 'media')?'image-shot':'time'; @@ -31,7 +31,7 @@ export default {

- + ({{ options.type }})

@@ -47,7 +47,7 @@ export default { ({{ options.relative_time }})

-

+

@@ -57,4 +57,4 @@ export default {
- \ No newline at end of file + diff --git a/src/components/projectPost.vue b/src/components/projectPost.vue index 7c1001b..b60294e 100644 --- a/src/components/projectPost.vue +++ b/src/components/projectPost.vue @@ -29,7 +29,7 @@ absTimeLocal: this.options.formatted_time_local, timeDiff: (this.options.formatted_time && this.options.formatted_time_local != this.options.formatted_time), anchorVisible: ['message', 'media', 'post'].includes(this.options.type), - anchorTitle: this.spot.lang('copy_to_clipboard'), + anchorTitle: this.lang.get('copy_to_clipboard'), anchorIcon: 'link', popupRequested: false, postMessage: '', @@ -49,7 +49,7 @@ return this.options.subtype || this.options.type; }, displayedId() { - return this.options.displayed_id?(this.spot.lang('counter', this.options.displayed_id)):''; + return this.options.displayed_id?(this.lang.get('counter', this.options.displayed_id)):''; }, anchorLink() { return '#'+[this.hash.page, this.hash.items[0], this.options.type, this.options.id].join(this.spot.consts.hash_sep); @@ -69,14 +69,14 @@ } }, - inject: ['spot', 'project', 'user', 'map', 'hash'], + inject: ['spot', 'lang', 'project', 'user', 'map', 'hash'], methods: { copyAnchor() { copyTextToClipboard(this.spot.consts.server+this.anchorLink); - this.anchorTitle = this.spot.lang('link_copied'); + this.anchorTitle = this.lang.get('link_copied'); this.anchorIcon = 'copied'; setTimeout(()=>{ //TODO animation - this.anchorTitle = this.spot.lang('copy_to_clipboard'); + this.anchorTitle = this.lang.get('copy_to_clipboard'); this.anchorIcon = 'link'; }, 5000); }, @@ -146,9 +146,9 @@
-
+
- {{ timeDiff?spot.lang('your_time', absTime):absTime }} + {{ timeDiff?lang.get('your_time', absTime):absTime }} {{ relTime }}
@@ -163,11 +163,11 @@

- + {{ options.weather_temp+'°C' }} - +
@@ -183,13 +183,13 @@

- - - + + +

-

{{ spot.lang('mode_histo') }}

+

{{ lang.get('mode_histo') }}

diff --git a/src/components/projectRelTime.vue b/src/components/projectRelTime.vue index e94cc45..d8deb3d 100644 --- a/src/components/projectRelTime.vue +++ b/src/components/projectRelTime.vue @@ -13,10 +13,10 @@ export default { icon: String, iconClasses: String }, - inject: ['spot'], + inject: ['lang'], computed: { title() { - if(this.localTime != this.siteTime) return this.spot.lang('your_time', this.siteTime.slice(-5)) + ((this.offset != '0')?' ('+this.spot.lang('unit_d')+this.offset+')':''); + if(this.localTime != this.siteTime) return this.lang.get('your_time', this.siteTime.slice(-5)) + ((this.offset != '0')?' ('+this.lang.get('unit_d')+this.offset+')':''); }, spotIconClasses() { return this.iconClasses || 'fa-fw fa-lg'; @@ -28,4 +28,4 @@ export default { \ No newline at end of file + diff --git a/src/components/upload.vue b/src/components/upload.vue index 7339f8d..ea8080f 100644 --- a/src/components/upload.vue +++ b/src/components/upload.vue @@ -10,7 +10,7 @@ import SpotButton from './spotButton.vue'; export default { name: 'upload', components: { SpotButton, SpotIcon }, - inject: ['spot', 'projects', 'consts', 'user'], + inject: ['spot', 'lang', 'projects', 'consts', 'user'], data() { return { project: this.projects[this.spot.vars('default_project_codename')], @@ -24,7 +24,7 @@ export default { this.spot.addPage('upload', {}); if(!this.project.editable) { - this.logs = [this.spot.lang('upload_mode_archived', [this.project.name])]; + this.logs = [this.lang.get('upload_mode_archived', [this.project.name])]; return; } @@ -67,13 +67,13 @@ export default { const uploadedFiles = response?.body?.files || []; uploadedFiles.forEach((uploadedFile) => { const hasError = Object.prototype.hasOwnProperty.call(uploadedFile, 'error'); - this.logs.push(hasError ? uploadedFile.error : this.spot.lang('upload_success', [uploadedFile.name])); + this.logs.push(hasError ? uploadedFile.error : this.lang.get('upload_success', [uploadedFile.name])); if(!hasError) this.files.push({...uploadedFile, content: ''}); }); }); this.uppy.on('upload-error', (file, error, response) => { - const message = response?.body?.error || error?.message || this.spot.lang('error'); + const message = response?.body?.error || error?.message || this.lang.get('error'); this.logs.push(message); }); @@ -88,8 +88,8 @@ export default { }, addComment(oFile) { this.spot.get2('add_comment', {id: oFile.id, content: oFile.content}) - .then((asData) => {this.logs.push(this.spot.lang('media_comment_update', asData.filename));}) - .catch((sMsgId) => {this.logs.push(this.spot.lang(sMsgId));}); + .then((asData) => {this.logs.push(this.lang.get('media_comment_update', asData.filename));}) + .catch((sMsgId) => {this.logs.push(this.lang.get(sMsgId));}); }, addPosition() { if(navigator.geolocation) { @@ -98,8 +98,8 @@ export default { (position) => { this.logs.push('Sending position...'); this.spot.get2('add_position', {'latitude':position.coords.latitude, 'longitude':position.coords.longitude, 'timestamp':Math.round(position.timestamp / 1000)}) - .then((asData) => {this.logs.push(this.spot.lang('success'));}) - .catch((sMsgId) => {this.logs.push(this.spot.lang(sMsgId));}); + .then((asData) => {this.logs.push(this.lang.get('success'));}) + .catch((sMsgId) => {this.logs.push(this.lang.get(sMsgId));}); }, (error) => { this.logs.push(error.message); @@ -113,8 +113,8 @@ export default {