Skip to content

Commit

Permalink
feat(ipfs): localize image/file loading errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bludnic committed Jan 9, 2025
1 parent 3991e33 commit 4ac40d8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/components/AChat/AChatAttachment/AChatFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<v-icon v-bind="props" :class="classes.errorIcon" icon="mdi-image-off" />
</template>

<span>Failed to load the image</span>
<span>{{ t('chats.file_loading_error') }}</span>
</v-tooltip>
</div>
</div>
Expand Down Expand Up @@ -60,6 +60,7 @@

<script lang="ts">
import { computed, defineComponent, PropType } from 'vue'
import { useI18n } from 'vue-i18n'
import { NormalizedChatMessageTransaction } from '@/lib/chat/helpers'
import { LocalFile, isLocalFile, formatBytes } from '@/lib/files'
import { FileAsset } from '@/lib/adamant-api/asset'
Expand Down Expand Up @@ -100,6 +101,8 @@ export default defineComponent({
emits: ['click'],
components: { AChatFileLoader, IconFile },
setup(props) {
const { t } = useI18n()
const isImage = computed(() => {
if (isLocalFile(props.file)) {
return props.file.file.isImage
Expand All @@ -118,6 +121,7 @@ export default defineComponent({
})
return {
t,
classes,
isImage,
fileName,
Expand Down
6 changes: 5 additions & 1 deletion src/components/AChat/AChatAttachment/AChatImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<v-icon v-bind="props" :class="classes.errorIcon" icon="mdi-image-off" />
</template>

<span>Failed to load the image</span>
<span>{{ t('chats.image_loading_error') }}</span>
</v-tooltip>
</div>
</v-img>
Expand Down Expand Up @@ -41,6 +41,7 @@

<script lang="ts">
import { defineComponent, PropType } from 'vue'
import { useI18n } from 'vue-i18n'
import { AChatFileLoader } from './AChatFileLoader.tsx'
import { NormalizedChatMessageTransaction } from '@/lib/chat/helpers'
Expand Down Expand Up @@ -75,7 +76,10 @@ export default defineComponent({
emits: ['click'],
components: { AChatFileLoader },
setup() {
const { t } = useI18n()
return {
t,
classes
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"max_file_size": "Max file size allowed: 10MB",
"file": "0 files | 1 file | {n} files | {n} files",
"files": "file(s)",
"file_loading_error": "Failed to load the file",
"image_loading_error": "Failed to load the image",
"me": "Me",
"message": "Type a message",
"message_rejected": "Message rejected",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"max_file_size": "Максимальный размер файла: 10MB",
"file": "0 файлов | 1 файл | {n} файла | {n} файлов",
"files": "файл(ов)",
"file_loading_error": "Не удалось загрузить файл",
"image_loading_error": "Не удалось загрузить изображение",
"me": "Я",
"message": "Введите сообщение",
"message_rejected": "Сообщение отклонено",
Expand Down

0 comments on commit 4ac40d8

Please sign in to comment.