<img src="image_url.jpg" alt="This is a descriptive text.">
<img src="gift_image.jpg" alt="A colorful gift box with a happy ribbon on top.">
<template>
<div>
<img :src="imageUrl" :alt="imageAltText">
</div>
</template>
<script>
export default {
data() {
return {
imageUrl: "image_url.jpg",
imageAltText: "This is a descriptive text."
};
},
mounted() {
// A variable determining the user's preferred language or the site's language.
const language = "en"; // You can dynamically set this value.
// Code dynamically updating the alt tag.
this.imageUrl = (language === "tr") ? "image-aciklamasi.jpg" : "image-description.jpg";
}
};
</script>
// nuxt.config.js
export default {
// Other configuration settings...
// Multi-language configuration.
i18n: {
locales: ["en", "tr"],
defaultLocale: "en",
vueI18n: {
fallbackLocale: "en",
messages: {
en: {
homePage: {
title: "Welcome to our website!",
content: "Explore the amazing content of our website."
}
},
tr: {
homePage: {
title: "Websitemize hoş geldiniz!",
content: "Websitemizin harika içeriğini keşfedin."
}
}
}
}
}
};
<template>
<div>
<h1>{{ $t("homePage.title") }}</h1>
<p>{{ $t("homePage.content") }}</p>
</div>
</template>
<script>
export default {
// Texts defining the content of the page.
async asyncData({ app }) {
return {
title: app.i18n.t("homePage.title"),
content: app.i18n.t("homePage.content")
};
}
};
</script>