Fix tests
This commit is contained in:
@@ -28,6 +28,7 @@ describe('Auto Imports', () => {
|
||||
const defineContentScript: typeof import('wxt/sandbox')['defineContentScript']
|
||||
const defineUnlistedScript: typeof import('wxt/sandbox')['defineUnlistedScript']
|
||||
const fakeBrowser: typeof import('wxt/testing')['fakeBrowser']
|
||||
const i18n: typeof import('wxt/i18n')['i18n']
|
||||
const storage: typeof import('wxt/storage')['storage']
|
||||
}
|
||||
"
|
||||
|
||||
@@ -61,7 +61,7 @@ describe('TypeScript Project', () => {
|
||||
const project = new TestProject();
|
||||
project.addFile('entrypoints/unlisted.html');
|
||||
project.addFile(
|
||||
'public/_locales/en/messages.json',
|
||||
'locales/en.json',
|
||||
JSON.stringify({
|
||||
prompt_for_name: {
|
||||
message: "What's your name?",
|
||||
@@ -119,6 +119,36 @@ describe('TypeScript Project', () => {
|
||||
}
|
||||
|
||||
export interface WxtI18n extends I18n.Static {
|
||||
/**
|
||||
* Ask for the user's name
|
||||
*
|
||||
* "What's your name?"
|
||||
*/
|
||||
getMessage(
|
||||
messageName: "prompt_for_name",
|
||||
substitutions?: string | string[],
|
||||
options?: GetMessageOptions,
|
||||
): string;
|
||||
/**
|
||||
* Greet the user
|
||||
*
|
||||
* "Hello, $USER$"
|
||||
*/
|
||||
getMessage(
|
||||
messageName: "hello",
|
||||
substitutions?: string | string[],
|
||||
options?: GetMessageOptions,
|
||||
): string;
|
||||
/**
|
||||
* Say goodbye to the user
|
||||
*
|
||||
* "Goodbye, $USER$. Come back to $OUR_SITE$ soon!"
|
||||
*/
|
||||
getMessage(
|
||||
messageName: "bye",
|
||||
substitutions?: string | string[],
|
||||
options?: GetMessageOptions,
|
||||
): string;
|
||||
/**
|
||||
* The extension or app ID; you might use this string to construct URLs for resources inside the extension. Even unlocalized extensions can use this message.
|
||||
Note: You can't use this message in a manifest file.
|
||||
@@ -131,7 +161,7 @@ describe('TypeScript Project', () => {
|
||||
options?: GetMessageOptions,
|
||||
): string;
|
||||
/**
|
||||
*
|
||||
* No message description.
|
||||
*
|
||||
* "<browser.i18n.getUiLocale()>"
|
||||
*/
|
||||
@@ -180,36 +210,25 @@ describe('TypeScript Project', () => {
|
||||
substitutions?: string | string[],
|
||||
options?: GetMessageOptions,
|
||||
): string;
|
||||
/**
|
||||
* Ask for the user's name
|
||||
*
|
||||
* "What's your name?"
|
||||
*/
|
||||
getMessage(
|
||||
messageName: "prompt_for_name",
|
||||
substitutions?: string | string[],
|
||||
options?: GetMessageOptions,
|
||||
): string;
|
||||
/**
|
||||
* Greet the user
|
||||
*
|
||||
* "Hello, $USER$"
|
||||
*/
|
||||
getMessage(
|
||||
messageName: "hello",
|
||||
substitutions?: string | string[],
|
||||
options?: GetMessageOptions,
|
||||
): string;
|
||||
/**
|
||||
* Say goodbye to the user
|
||||
*
|
||||
* "Goodbye, $USER$. Come back to $OUR_SITE$ soon!"
|
||||
*/
|
||||
getMessage(
|
||||
messageName: "bye",
|
||||
substitutions?: string | string[],
|
||||
options?: GetMessageOptions,
|
||||
): string;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "wxt/i18n" {
|
||||
export interface WxtMessageSchema {
|
||||
t: {
|
||||
"prompt_for_name": any;
|
||||
"hello": any;
|
||||
"bye": any;
|
||||
"@@extension_id": any;
|
||||
"@@ui_locale": any;
|
||||
"@@bidi_dir": any;
|
||||
"@@bidi_reversed_dir": any;
|
||||
"@@bidi_start_edge": any;
|
||||
"@@bidi_end_edge": any;
|
||||
};
|
||||
tp: {
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
"
|
||||
|
||||
@@ -12,13 +12,13 @@ export function getUnimportOptions(
|
||||
imports: [
|
||||
{ name: 'defineConfig', from: 'wxt' },
|
||||
{ name: 'fakeBrowser', from: 'wxt/testing' },
|
||||
{ name: 'i18n', from: 'wxt/i18n' },
|
||||
],
|
||||
presets: [
|
||||
{ package: 'wxt/client' },
|
||||
{ package: 'wxt/browser' },
|
||||
{ package: 'wxt/sandbox' },
|
||||
{ package: 'wxt/storage' },
|
||||
{ package: 'wxt/i18n' },
|
||||
],
|
||||
warn: config.logger.warn,
|
||||
dirs: ['components', 'composables', 'hooks', 'utils'],
|
||||
|
||||
@@ -3,39 +3,39 @@
|
||||
"entry": {
|
||||
"message": "Hello world!"
|
||||
},
|
||||
"name": ["simple"]
|
||||
"name": "simple"
|
||||
},
|
||||
{
|
||||
"entry": {
|
||||
"description": "This is a description to give translators more context (it's never translated)",
|
||||
"message": "This is the translated text"
|
||||
},
|
||||
"name": ["manifestStyle"]
|
||||
"name": "manifestStyle"
|
||||
},
|
||||
{
|
||||
"entry": {
|
||||
"message": "Hello $1, my name is $2"
|
||||
},
|
||||
"name": ["interpolation"]
|
||||
"name": "interpolation"
|
||||
},
|
||||
{
|
||||
"entry": {
|
||||
"message": "You can nest translations inside deep objects"
|
||||
},
|
||||
"name": ["some", "nested", "translation"]
|
||||
"name": "some_nested_translation"
|
||||
},
|
||||
{
|
||||
"entry": {
|
||||
"message": "You owe me $$100"
|
||||
},
|
||||
"name": ["escapeTheDollarSign"]
|
||||
"name": "escapeTheDollarSign"
|
||||
},
|
||||
{
|
||||
"entry": {
|
||||
"message": "Zero items | 1 item | $1 items"
|
||||
},
|
||||
"isPlural": true,
|
||||
"name": ["pluralForm"]
|
||||
"name": "pluralForm"
|
||||
},
|
||||
{
|
||||
"entry": {
|
||||
@@ -43,14 +43,14 @@
|
||||
"message": "<browser.runtime.id>"
|
||||
},
|
||||
"isBuiltin": true,
|
||||
"name": ["@@extension_id"]
|
||||
"name": "@@extension_id"
|
||||
},
|
||||
{
|
||||
"entry": {
|
||||
"message": "<browser.i18n.getUiLocale()>"
|
||||
},
|
||||
"isBuiltin": true,
|
||||
"name": ["@@ui_locale"]
|
||||
"name": "@@ui_locale"
|
||||
},
|
||||
{
|
||||
"entry": {
|
||||
@@ -58,7 +58,7 @@
|
||||
"message": "<ltr|rtl>"
|
||||
},
|
||||
"isBuiltin": true,
|
||||
"name": ["@@bidi_dir"]
|
||||
"name": "@@bidi_dir"
|
||||
},
|
||||
{
|
||||
"entry": {
|
||||
@@ -66,7 +66,7 @@
|
||||
"message": "<rtl|ltr>"
|
||||
},
|
||||
"isBuiltin": true,
|
||||
"name": ["@@bidi_reversed_dir"]
|
||||
"name": "@@bidi_reversed_dir"
|
||||
},
|
||||
{
|
||||
"entry": {
|
||||
@@ -74,7 +74,7 @@
|
||||
"message": "<left|right>"
|
||||
},
|
||||
"isBuiltin": true,
|
||||
"name": ["@@bidi_start_edge"]
|
||||
"name": "@@bidi_start_edge"
|
||||
},
|
||||
{
|
||||
"entry": {
|
||||
@@ -82,6 +82,6 @@
|
||||
"message": "<right|left>"
|
||||
},
|
||||
"isBuiltin": true,
|
||||
"name": ["@@bidi_end_edge"]
|
||||
"name": "@@bidi_end_edge"
|
||||
}
|
||||
]
|
||||
|
||||
+6
-1
@@ -13,4 +13,9 @@ export interface WxtMessageSchema extends DefaultMessageSchema {
|
||||
}
|
||||
|
||||
export const i18n = createExtensionI18n<WxtMessageSchema>();
|
||||
export * from './client';
|
||||
export {
|
||||
DefaultMessageSchema,
|
||||
ExtensionI18n,
|
||||
TypedExtensionI18n,
|
||||
UntypedExtensionI18n,
|
||||
} from './client';
|
||||
|
||||
Reference in New Issue
Block a user