This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix missing nuxt types * Add guidance for how to use useI18n and verify types work * Fix type errors in VLink
- Loading branch information
1 parent
546b612
commit f369f30
Showing
8 changed files
with
50 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { computed, useContext } from '@nuxtjs/composition-api' | ||
|
||
import type { LocaleObject } from '@nuxtjs/i18n' | ||
|
||
const BASE_URL = 'https://translate.wordpress.org/projects/meta/openverse/' | ||
|
||
export function useI18nSync() { | ||
const { app } = useContext() | ||
const currentLocale = computed(() => { | ||
return (app.i18n?.locales as LocaleObject[]).find( | ||
(item) => item.code === app.i18n.locale | ||
) | ||
}) | ||
|
||
const needsTranslationBanner = computed(() => { | ||
if (!currentLocale.value || currentLocale.value.code === 'en') return false | ||
|
||
return (currentLocale.value?.translated ?? 100) <= 90 | ||
}) | ||
|
||
const translationLink = computed( | ||
() => `${BASE_URL}${currentLocale.value?.code || 'en'}/default/` | ||
) | ||
|
||
return { | ||
currentLocale, | ||
needsTranslationBanner, | ||
translationLink, | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
import '@nuxt/types' | ||
import type { IVueI18n } from 'vue-i18n' | ||
import type { Details as UADetails } from 'express-useragent' | ||
|
||
declare module '@nuxt/types' { | ||
export interface NuxtAppOptions { | ||
$ua: UADetails | null | ||
} | ||
export interface Context { | ||
i18n: IVueI18n | ||
} | ||
} |