Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions docs/app/components/content/SupportedLanguages.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function getEmojiFlag(locale: string): string {
cs: 'cz', // Czech -> Czech Republic (note: modern country code is actually 'cz')
da: 'dk', // Danish -> Denmark
el: 'gr', // Greek -> Greece
en: 'gb', // English -> Great Britain
en: 'us', // English -> United States (default)
et: 'ee', // Estonian -> Estonia
gl: 'es', // Galician -> Spain
he: 'il', // Hebrew -> Israel
Expand All @@ -40,8 +40,20 @@ function getEmojiFlag(locale: string): string {
vi: 'vn' // Vietnamese -> Vietnam
}

// If locale has a country code (e.g., en-GB), extract and use it
if (locale.includes('-')) {
const countryCode = locale.split('-')[1]?.toLowerCase()
if (countryCode) {
return countryCode.toUpperCase()
.split('')
.map(char => String.fromCodePoint(0x1F1A5 + char.charCodeAt(0)))
.join('')
}
}

// Otherwise, use the language-to-country mapping
const baseLanguage = locale.split('-')[0]?.toLowerCase() || locale
const countryCode = languageToCountry[baseLanguage] || locale.replace(/^.*-/, '').slice(0, 2)
const countryCode = languageToCountry[baseLanguage] || locale.slice(0, 2)

return countryCode.toUpperCase()
.split('')
Expand Down
16 changes: 14 additions & 2 deletions src/runtime/components/locale/LocaleSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function getEmojiFlag(locale: string): string {
cs: 'cz', // Czech -> Czech Republic (note: modern country code is actually 'cz')
da: 'dk', // Danish -> Denmark
el: 'gr', // Greek -> Greece
en: 'gb', // English -> Great Britain
en: 'us', // English -> United States (default)
et: 'ee', // Estonian -> Estonia
gl: 'es', // Galician -> Spain
he: 'il', // Hebrew -> Israel
Expand All @@ -56,8 +56,20 @@ function getEmojiFlag(locale: string): string {
vi: 'vn' // Vietnamese -> Vietnam
}

// If locale has a country code (e.g., en-GB), extract and use it
if (locale.includes('-')) {
const countryCode = locale.split('-')[1]?.toLowerCase()
if (countryCode) {
return countryCode.toUpperCase()
.split('')
.map(char => String.fromCodePoint(0x1F1A5 + char.charCodeAt(0)))
.join('')
}
}

// Otherwise, use the language-to-country mapping
const baseLanguage = locale.split('-')[0]?.toLowerCase() || locale
const countryCode = languageToCountry[baseLanguage] || locale.replace(/^.*-/, '').slice(0, 2)
const countryCode = languageToCountry[baseLanguage] || locale.slice(0, 2)

return countryCode.toUpperCase()
.split('')
Expand Down
9 changes: 9 additions & 0 deletions src/runtime/locale/en_gb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Messages } from '../types'
import { defineLocale } from '../composables/defineLocale'
import en from './en'

export default defineLocale<Messages>({
name: 'English (United Kingdom)',
code: 'en-GB',
messages: en.messages
})
1 change: 1 addition & 0 deletions src/runtime/locale/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export { default as de } from './de'
export { default as de_ch } from './de_ch'
export { default as el } from './el'
export { default as en } from './en'
export { default as en_gb } from './en_gb'
export { default as es } from './es'
export { default as et } from './et'
export { default as fa_ir } from './fa_ir'
Expand Down
Loading