Skip to content

Commit 846a3ce

Browse files
authored
fixed: living images Kolding de-en-da (#76)
1 parent b3d03f4 commit 846a3ce

File tree

3 files changed

+98
-45
lines changed

3 files changed

+98
-45
lines changed

src/locales/da.json

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
{
22
"welcomeScreen": {
3-
"title": "LIVING IMAGES",
4-
"description": "You can bring real images to life with the kulturfinder.sh. How does it work?",
5-
"step1": "1. Allow access to your camera",
6-
"step2": "2. Point your camera at the Living Image",
7-
"step3": "3. See what happens with it",
8-
"button": "Let's go!"
3+
"title": "LEVENDE BILLEDER",
4+
"description": "Du kan vække rigtige billeder til live med kulturfinder.sh. Hvordan fungerer det?",
5+
"step1": "1. Giv adgang til dit kamera",
6+
"step2": "2. Peg dit kamera mod det levende billede",
7+
"step3": "3. Se hvad der sker",
8+
"button": "Lad os gå!"
99
},
1010
"loading": {
11-
"spinnerLabel": "Loading",
12-
"text": "Loading Living Images ..."
11+
"spinnerLabel": "Indlæser",
12+
"text": "Indlæser levende billeder..."
1313
},
1414
"camRejected": {
15-
"text": "We need the permission to use your device's camera. The app doesn't work without it.",
16-
"restartButton": "Got it"
15+
"text": "Vi har brug for tilladelse til at bruge dit kamera. App'en virker ikke uden det.",
16+
"restartButton": "Forstået"
1717
},
18-
"videoElementNotSupported": "Your browser doesn't support the video element.",
18+
"videoElementNotSupported": "Din browser understøtter ikke video-elementet.",
1919
"stats": {
20-
"main": "Main",
21-
"worker": "Worker"
20+
"main": "Hoved",
21+
"worker": "Arbejder"
2222
},
2323
"buttons": {
24-
"back": "Back",
24+
"back": "Tilbage",
2525
"info": "Information",
26-
"overview": "Overview",
26+
"overview": "Oversigt",
2727
"pause": "Pause",
28-
"play": "Play",
29-
"muted": "Turn sound on",
30-
"unmuted": "Turn sound off"
28+
"play": "Afspil",
29+
"muted": "Slå lyd til",
30+
"unmuted": "Slå lyd fra"
3131
},
3232
"infoModal": {
33-
"title": "About Living Images",
34-
"p1": "kulturfinder.sh lets you bring real images to life!",
35-
"p2": "How does it work? It's simple: When you see a Living Image in a participating cultural institution, open the Living Image Viewer on the institution's page or scan the corresponding QR code. Now point your device at the image and let its story surprise you! Don't forget to turn on the sound.",
36-
"imageAlt": "Example of a marker",
37-
"imageCaption": "Example: Yvonne Ruprecht from the {link}.",
33+
"title": "Om Levende Billeder",
34+
"p1": "kulturfinder.sh lader dig vække rigtige billeder til live!",
35+
"p2": "Hvordan fungerer det? Det er enkelt: Når du ser et levende billede i en deltagende kulturinstitution, så åbn Living Image Viewer på institutionens side eller scan den tilsvarende QR-kode. Peg din enhed mod billedet, og lad dets historie overraske dig! Husk at tænde for lyden.",
36+
"imageAlt": "Eksempel på en markør",
37+
"imageCaption": "Eksempel: Yvonne Ruprecht fra {link}.",
3838
"imageCaptionLinkValue": "Schauspielhaus Kiel",
39-
"reportErrors": "Have you found an error? Since we are in the midst of testing, errors are likely to occur. Please notify us by email at: {link}.",
39+
"reportErrors": "Har du fundet en fejl? Da vi stadig tester, kan fejl forekomme. Kontakt os venligst via e-mail: {link}.",
4040
"reportErrorsLinkValue": "dev@kultursphaere.sh",
4141
"version": "version"
4242
},
4343
"overviewModal": {
44-
"title": "Living Images",
45-
"imagesFound": "No images found yet | One image found | {count} images found",
46-
"found": "watched"
44+
"title": "Levende Billeder",
45+
"imagesFound": "Ingen billeder fundet endnu | Ét billede fundet | {count} billeder fundet",
46+
"found": "set"
4747
}
48-
}
48+
}

src/store/modules/api.js

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ import Vue from 'vue'
33
// Living Image Marker Object for testing purposes
44
// should be put in a database in the future
55
class LIMarker {
6-
constructor(id, title, markerImageUrl, markerSetUrl, videoUrl, width, height, scale = 0.112, offsetX = 0, offsetY = 0, offsetZ = 0) {
6+
constructor(id, title, markerImageUrl, markerSetUrl, video, width, height, scale = 0.112, offsetX = 0, offsetY = 0, offsetZ = 0) {
77
this.id = id // used for identification, must be unique
88
this.title = title // seen in overview
99
this.imageUrl = markerImageUrl
1010
this.setUrl = markerSetUrl // feature set name without extensions
11-
this.videoUrl = videoUrl
11+
// If a string is passed, wrap it in an object under 'de'
12+
if (typeof video === 'string') {
13+
this.videoUrls = { de: video }
14+
} else {
15+
this.videoUrls = video
16+
}
17+
// this.videoUrl = videoUrl
1218
this.width = width // video width
1319
this.height = height // video height
1420
this.scale = scale // need to adjust this to make the video fit the marker image
@@ -18,6 +24,19 @@ class LIMarker {
1824
z: offsetZ
1925
}
2026
}
27+
28+
// Returns the video URL based on the current Vue I18n locale.
29+
getVideoUrl(currentLocale) {
30+
// If only a German video exists, return that
31+
if (this.videoUrls.de && Object.keys(this.videoUrls).length === 1) {
32+
return this.videoUrls.de
33+
}
34+
// Use the first two characters of the locale (e.g. "en", "de", "da")
35+
const lang = currentLocale ? currentLocale.slice(0, 2) : 'en'
36+
console.log('Current locale:', currentLocale, 'Using lang:', lang)
37+
// Fallback to English if the language is not available
38+
return this.videoUrls[lang] || this.videoUrls.en
39+
}
2140
}
2241

2342
export default {
@@ -247,21 +266,29 @@ export default {
247266
new LIMarker(
248267
'jenny',
249268
'Jenny ENG',
250-
baseUrl + 'jenny.jpeg', // LivingImagesJennyENGCoverphoto400.jpg
251-
baseUrl + 'jenny', // LivingImagesJennyENGCoverphoto400_thresh
252-
baseUrl + 'jenny.mov',
253-
1080, // 1920
254-
1080, // 1080 // 0.454
255-
0.180,
269+
baseUrl + 'jenny-marker.jpg', // marker image
270+
baseUrl + 'jenny-marker', // marker set
271+
{
272+
en: baseUrl + 'jenny_eng.mp4',
273+
de: baseUrl + 'jenny_de.mp4',
274+
da: baseUrl + 'jenny_da.mp4'
275+
},
276+
1080,
277+
1080,
278+
0.122,
256279
8,
257280
8
258281
),
259282
new LIMarker(
260283
'walther',
261284
'Walther ENG',
262-
baseUrl + 'walther.jpeg', // LivingImagesWaltherENGCoverphoto2_400
263-
baseUrl + 'walther', // LivingImagesWaltherENGCoverphoto2_400thresh
264-
baseUrl + 'walther.mov', // LivingImagesWaltherENG.mp4
285+
baseUrl + 'walther-marker.jpg', // LivingImagesWaltherENGCoverphoto2_400
286+
baseUrl + 'walther-marker', // LivingImagesWaltherENGCoverphoto2_400thresh
287+
{
288+
en: baseUrl + 'walther_eng.mp4',
289+
de: baseUrl + 'walther_de.mp4',
290+
da: baseUrl + 'walther_da.mp4'
291+
},
265292
1080,
266293
1080,
267294
0.122,

src/views/ARViewer.vue

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
crossOrigin="anonymous"
8888
style="opacity:0"
8989
>
90-
<source :src="livingImage.videoUrl" type="video/mp4">
90+
<source :src="livingImage.getVideoUrl(currentLocale)" type="video/mp4">
9191
</video>
9292
</div>
9393

@@ -232,6 +232,10 @@ export default {
232232
}
233233
},
234234
computed: {
235+
currentLocale() {
236+
// Use Vue I18n locale if available, otherwise fall back to the browser's language.
237+
return this.$i18n && this.$i18n.locale ? this.$i18n.locale : navigator.language.slice(0, 2)
238+
},
235239
unfoundLivingImages() {
236240
return this.livingImages.filter(li => !li.found).length
237241
},
@@ -268,9 +272,8 @@ export default {
268272
ids = ids.split(',')
269273
}
270274
}
271-
272275
return {
273-
locale: urlParams.get('locale') || 'de',
276+
locale: urlParams.get('locale') || navigator.language.slice(0, 2),
274277
ids: ids || []
275278
}
276279
},
@@ -293,19 +296,42 @@ export default {
293296
// get ids and locale
294297
this.params = this.getUrlParams(window.location.search)
295298
// if no id, set fallback
296-
if (this.params.ids.length === 0) this.params.ids = ['act001610']
299+
if (this.params.ids.length === 0) this.params.ids = ['act0002644']
297300
// set locale
298301
this.$i18n.locale = this.params.locale
299302
},
300303
async mounted() {
301304
if (this.params.ids[0].startsWith('act')) this.oldWayUsed = true
305+
const actionName = this.oldWayUsed
306+
? 'api/fetchLivingImagesOldWay'
307+
: 'api/fetchLivingImages'
308+
console.log(this.params.ids)
309+
310+
// fetch living images
311+
const livingImages = await this.$store.dispatch(actionName, {
312+
ids: this.params.ids,
313+
locale: this.$i18n.locale
314+
})
315+
// Assign the original instances to preserve their prototype methods
316+
this.livingImages = livingImages
317+
// Add extra properties directly
318+
this.livingImages.forEach(livingImage => {
319+
livingImage.video = null
320+
livingImage.active = false
321+
livingImage.found = false
322+
livingImage.playing = false
323+
livingImage.userPaused = false
324+
livingImage.fadingOut = false
325+
livingImage.ended = false
326+
})
302327
328+
/* async mounted() {
303329
// fetch living images
304330
const actionName = this.oldWayUsed
305331
? 'api/fetchLivingImagesOldWay'
306332
: 'api/fetchLivingImages'
307333
const livingImages = await this.$store.dispatch(actionName, { ids: this.params.ids })
308-
334+
309335
if (!livingImages) {
310336
// TODO: Handle error, e.g. show error message
311337
return
@@ -322,7 +348,7 @@ export default {
322348
fadingOut: false,
323349
ended: false
324350
}
325-
})
351+
}) */
326352
327353
document.getElementById('accept-button').addEventListener('click', () => {
328354
for (let livingImage of this.livingImages) {

0 commit comments

Comments
 (0)