Skip to content

Commit

Permalink
+currentLocale
Browse files Browse the repository at this point in the history
  • Loading branch information
eddow committed Jun 5, 2024
1 parent 3d0fe81 commit 7f93bd0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ error(key: string, error: string, spec: object): string
- [SvelteKit](https://github.com/eddow/omni18n-svelte4) - Svelte4
- [Translator](https://github.com/eddow/omni18n-edit/releases) - To edit `FileDB` dictionaries


## TODO

- tests:
Expand Down
19 changes: 19 additions & 0 deletions src/umd/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,25 @@ export function translatePage() {

localesListElm.innerHTML = selectionList.join('')
}

const currentLocaleElm = document.getElementById('current-locale')
if (currentLocaleElm) {
const flags = localeFlags(locale),
flagsStr =
flags.length === 1
? flags[0]
: `
<span class="flag-main">${flags[0]}</span>
<span class="flag-loc">${flags[1]}</span>
`,
localeName = new Intl.DisplayNames(locale, { type: 'language' }).of(locale)
currentLocaleElm.innerHTML = `
<button class="locale" title="${localeName}">
<span class="flag">${flagsStr}</span>
<span class="name">${localeName}</span>
</button>
`
}
}

async function loadLanguage() {
Expand Down

0 comments on commit 7f93bd0

Please sign in to comment.