Skip to content

Commit

Permalink
fix: update language switcher types
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon committed Sep 12, 2024
1 parent d992621 commit 304c41d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
12 changes: 6 additions & 6 deletions components/LanguageSwitcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<script setup lang="ts">
import vSelect from 'vue-select'
import { languageLocales } from '@/constants'
import { localeCodes, type Locale } from '@/types'
import { LocaleCodes, type Locale } from '@/types'
import esESIcon from '@/assets/svg/sp-flags.svg?component'
import enUSIcon from '@/assets/svg/flag-eeuu.svg?component'
import 'vue-select/dist/vue-select.css'
Expand All @@ -46,7 +46,7 @@ defineProps({
})
type Option = {
label: localeCodes
label: LocaleCodes
}
interface Dictionary {
[key: string]: any
Expand All @@ -59,14 +59,14 @@ const language = computed({
},
})
const languageCodes: ComputedRef<Array<Locale>> = computed(() => {
return Object.values(languageLocales).map((locale) => locale.code)
const languageCodes: ComputedRef<Array<string>> = computed(() => {
return Object.values(languageLocales).map((locale: Locale) => locale.code)
})
const iconMap: Dictionary = computed(() => {
return {
[localeCodes.es]: esESIcon,
[localeCodes.en]: enUSIcon,
[LocaleCodes.es]: esESIcon,
[LocaleCodes.en]: enUSIcon,
}
})
</script>
Expand Down
18 changes: 9 additions & 9 deletions constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { localeCodes, type LanguageDictionary } from './types'
import { LocaleCodes, type Locale } from './types'

export const URLS: Record<string, string> = {
ado: 'https://github.com/adoracles/',
Expand Down Expand Up @@ -73,17 +73,17 @@ export const URLS: Record<string, string> = {
solidity_sdk: 'https://www.npmjs.com/package/witnet-solidity',
}

export const languageLocales: LanguageDictionary = {
[localeCodes.en]: {
export const languageLocales: Record<LocaleCodes, Locale> = {
[LocaleCodes.en]: {
code: 'en-US',
iso: 'en-US',
name: 'ENGLISH',
file: 'en-US.json',
},
// [localeCodes.es]: {
// code: 'es-ES',
// iso: 'es-ES',
// name: 'ESPAÑOL',
// file: 'es-ES.json',
// },
[LocaleCodes.es]: {
code: 'es-ES',
iso: 'es-ES',
name: 'ESPAÑOL',
file: 'es-ES.json',
},
}
7 changes: 1 addition & 6 deletions types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum localeCodes {
export enum LocaleCodes {
en = 'en-US',
es = 'es-ES',
}
Expand All @@ -18,11 +18,6 @@ export enum ButtonType {
disabled = 'disabled',
}

export interface LanguageDictionary {
[localeCodes.en]: Locale
// [localeCodes.es]: Locale
}

export type TutorialLink = {
name: string
url: string
Expand Down

0 comments on commit 304c41d

Please sign in to comment.