hanzio 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -3
- package/dist/api-wrapper/connection-auth.d.ts +61 -0
- package/dist/cli/fields.d.ts +30 -0
- package/dist/cli/index.d.ts +122 -0
- package/dist/format/index.d.ts +91 -0
- package/dist/format/phone.d.ts +19 -0
- package/dist/http/index.d.ts +14 -0
- package/dist/i18n/catalog.d.ts +47 -0
- package/dist/i18n/check.d.ts +45 -0
- package/dist/i18n/cli.d.ts +2 -0
- package/dist/i18n/content-rules.d.ts +55 -0
- package/dist/i18n/i18next.d.ts +39 -0
- package/dist/i18n/index.d.ts +16 -1
- package/dist/i18n/locales.d.ts +62 -0
- package/dist/i18n/vite.d.ts +16 -0
- package/dist/i18n/vue.d.ts +93 -0
- package/dist/{index-kj1phgrx.js → index-29mmh343.js} +24 -1
- package/dist/{index-zbj9s3s3.js → index-2kz392vw.js} +1 -1
- package/dist/index-5n2e326q.js +409 -0
- package/dist/{index-hy7kbb99.js → index-5tzqfmnj.js} +1 -1
- package/dist/{index-0zvtcbzy.js → index-6f2w90pp.js} +69 -1
- package/dist/index-6ragggbs.js +473 -0
- package/dist/index-mq2qgc20.js +116 -0
- package/dist/index-najbyzpr.js +99 -0
- package/dist/index-ww09bm49.js +250 -0
- package/dist/iso/countries.d.ts +262 -0
- package/dist/iso/currencies.d.ts +165 -0
- package/dist/iso/index.d.ts +4 -0
- package/dist/iso/languages.d.ts +195 -0
- package/dist/iso/phone-language.d.ts +5 -0
- package/dist/promise/index.d.ts +31 -0
- package/dist/redis/client.d.ts +49 -0
- package/dist/redis/concurrency-limit.d.ts +63 -0
- package/dist/redis/index.d.ts +3 -0
- package/dist/redis/lua-script.d.ts +13 -0
- package/dist/secrets/infisical-identity-file.d.ts +12 -0
- package/dist/src/api-wrapper/connection-auth.js +82 -0
- package/dist/src/api-wrapper/index.js +1 -1
- package/dist/src/cli/index.js +10 -0
- package/dist/src/format/index.js +79 -2
- package/dist/src/format/phone.js +21 -0
- package/dist/src/http/index.js +69 -0
- package/dist/src/i18n/check.js +15 -0
- package/dist/src/i18n/cli.js +71 -0
- package/dist/src/i18n/i18next.js +48 -0
- package/dist/src/i18n/index.js +16 -34
- package/dist/src/i18n/vite.js +25 -0
- package/dist/src/i18n/vue.js +51 -0
- package/dist/src/index.js +14 -4
- package/dist/src/iso/index.js +655 -0
- package/dist/src/redis/index.js +577 -0
- package/dist/src/secrets/index.js +78 -35
- package/dist/src/sitemap/index.js +1 -1
- package/dist/src/storage/index.js +8 -117
- package/dist/src/testing/index.js +348 -0
- package/dist/src/zod/index.js +20 -253
- package/dist/string/index.d.ts +21 -0
- package/dist/testing/connection-auth-contract.d.ts +43 -0
- package/dist/testing/helpers.d.ts +26 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/module-mocker.d.ts +30 -0
- package/dist/testing/prisma.d.ts +30 -0
- package/dist/testing/window.d.ts +18 -0
- package/dist/zod/index.d.ts +10 -0
- package/dist/zod/introspect.d.ts +2 -1
- package/package.json +96 -2
- package/src/api-wrapper/README.md +52 -0
- package/src/api-wrapper/connection-auth.ts +142 -0
- package/src/cli/README.md +220 -0
- package/src/cli/fields.ts +213 -0
- package/src/cli/index.ts +532 -0
- package/src/format/README.md +82 -2
- package/src/format/index.ts +148 -0
- package/src/format/phone.ts +43 -0
- package/src/http/README.md +25 -0
- package/src/http/index.ts +94 -0
- package/src/i18n/README.md +206 -3
- package/src/i18n/catalog.ts +139 -0
- package/src/i18n/check.ts +376 -0
- package/src/i18n/cli.ts +90 -0
- package/src/i18n/content-rules.ts +179 -0
- package/src/i18n/i18next.ts +89 -0
- package/src/i18n/index.ts +34 -0
- package/src/i18n/locales.ts +135 -0
- package/src/i18n/vite.ts +40 -0
- package/src/i18n/vue.ts +82 -0
- package/src/index.ts +1 -1
- package/src/iso/README.md +44 -0
- package/src/iso/countries.ts +272 -0
- package/src/iso/currencies.ts +172 -0
- package/src/iso/index.ts +8 -0
- package/src/iso/languages.ts +208 -0
- package/src/iso/phone-language.ts +46 -0
- package/src/promise/index.ts +100 -0
- package/src/redis/README.md +112 -0
- package/src/redis/client.ts +239 -0
- package/src/redis/concurrency-limit.ts +591 -0
- package/src/redis/index.ts +15 -0
- package/src/redis/lua-script.ts +43 -0
- package/src/secrets/README.md +5 -1
- package/src/secrets/infisical-identity-file.ts +69 -0
- package/src/secrets/infisical.ts +18 -3
- package/src/string/index.ts +59 -0
- package/src/testing/README.md +119 -0
- package/src/testing/connection-auth-contract.ts +303 -0
- package/src/testing/helpers.ts +41 -0
- package/src/testing/index.ts +12 -0
- package/src/testing/module-mocker.ts +50 -0
- package/src/testing/prisma.ts +78 -0
- package/src/testing/window.ts +119 -0
- package/src/zod/index.ts +20 -0
- package/src/zod/introspect.ts +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content rules for translation VALUES, which key and placeholder parity cannot
|
|
3
|
+
* see: source code stored as copy ("row.name", "carTitle(car)") by an automated
|
|
4
|
+
* extraction pass, copy in the wrong language committed to the base catalog,
|
|
5
|
+
* banned product vocabulary, and copy shipped untranslated.
|
|
6
|
+
*/
|
|
7
|
+
export type ContentRulesConfig<Locale extends string = string> = {
|
|
8
|
+
/**
|
|
9
|
+
* Key prefixes the vocabulary and untranslated rules skip, such as internal
|
|
10
|
+
* admin tooling or a marketing site with its own copy owner.
|
|
11
|
+
*/
|
|
12
|
+
exemptKeyPrefixes?: readonly string[];
|
|
13
|
+
/** Values that legitimately look like code, such as `'Solgt.com'`. */
|
|
14
|
+
allowCodeShapes?: readonly string[];
|
|
15
|
+
/**
|
|
16
|
+
* Flags base-catalog values written in another language: two distinct
|
|
17
|
+
* marker words, or one plus a letter from `letters`.
|
|
18
|
+
*/
|
|
19
|
+
wrongLanguage?: {
|
|
20
|
+
/** Function words of the other language that are not English words. */
|
|
21
|
+
markers: readonly string[];
|
|
22
|
+
/** Letters only that language uses, e.g. `'æøåÆØÅ'`. */
|
|
23
|
+
letters?: string;
|
|
24
|
+
allowKeys?: readonly string[];
|
|
25
|
+
};
|
|
26
|
+
bannedWords?: {
|
|
27
|
+
/** Banned in every catalog, the base included. */
|
|
28
|
+
everywhere?: readonly string[];
|
|
29
|
+
/** Banned in translations only (loanwords readers do not use). */
|
|
30
|
+
translations?: readonly string[];
|
|
31
|
+
allowKeys?: readonly string[];
|
|
32
|
+
};
|
|
33
|
+
/** Translations allowed to equal the base value. */
|
|
34
|
+
identical?: {
|
|
35
|
+
/** Leading words (brands, acronyms) that make a value correct as-is. */
|
|
36
|
+
brands?: readonly string[];
|
|
37
|
+
/** Keys correct as-is, in the listed locales or `'all'`. */
|
|
38
|
+
allowKeys?: Readonly<Record<string, readonly Locale[] | 'all'>>;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
/** Compiles the configured rules once; each detector returns why, or null. */
|
|
42
|
+
export declare function createContentRules(config?: ContentRulesConfig): {
|
|
43
|
+
/** The shape name when a value looks like source code. */
|
|
44
|
+
codeShape(value: string): string | null;
|
|
45
|
+
/** The marker words found when a base value is in the wrong language. */
|
|
46
|
+
wrongLanguage(key: string, value: string): string | null;
|
|
47
|
+
/** The offending word when a value uses banned vocabulary. */
|
|
48
|
+
bannedWord(key: string, value: string, isBase: boolean): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* A translation of two or more words identical to its source ("Document
|
|
51
|
+
* name", a whole English sentence). Single words stay out of scope:
|
|
52
|
+
* "Status" and "Email" are correct in many languages.
|
|
53
|
+
*/
|
|
54
|
+
identicalLabel(key: string, locale: string, source: string, translated: string): boolean;
|
|
55
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { i18n as I18next, InitOptions, ResourceLanguage } from 'i18next';
|
|
2
|
+
import { type AsyncStorageLike } from '../storage';
|
|
3
|
+
import type { LocaleRegistry } from '.';
|
|
4
|
+
/**
|
|
5
|
+
* Starts `i18n` in the persisted locale, then the first supported device
|
|
6
|
+
* locale, then `locales.defaultLocale` (also the fallback). Interpolation uses
|
|
7
|
+
* `{name}` (not `{{name}}`) and does not escape, matching the catalog check
|
|
8
|
+
* and `hanzio/i18n`.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* export const appI18n = initI18next(i18n.use(initReactI18next), {
|
|
12
|
+
* locales: uiLocales,
|
|
13
|
+
* resources: { en: { translation: en }, da: { translation: da } },
|
|
14
|
+
* deviceLocales: () => getLocales().flatMap((l) => [l.languageTag, l.languageCode]),
|
|
15
|
+
* storageKey: 'app.ui-locale',
|
|
16
|
+
* storage: AsyncStorage
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function initI18next<L extends string>(i18n: I18next, options: Omit<InitOptions, 'lng' | 'resources'> & {
|
|
21
|
+
locales: LocaleRegistry<L>;
|
|
22
|
+
resources: Record<L, ResourceLanguage>;
|
|
23
|
+
/** Device languages in preference order, e.g. from `expo-localization`. */
|
|
24
|
+
deviceLocales?: () => readonly (string | null | undefined)[];
|
|
25
|
+
/** Remembers the chosen locale (a raw string). Needs `storage`. */
|
|
26
|
+
storageKey?: string;
|
|
27
|
+
storage?: AsyncStorageLike;
|
|
28
|
+
}): {
|
|
29
|
+
/** Resolves once `i18n.init` finishes. Await it before the first render. */
|
|
30
|
+
ready: Promise<void>;
|
|
31
|
+
setLocale: (locale: L) => Promise<void>;
|
|
32
|
+
/** The active locale, or the default before `ready`. */
|
|
33
|
+
locale: () => L;
|
|
34
|
+
/**
|
|
35
|
+
* Follows a server-side preference (the signed-in user's locale). An
|
|
36
|
+
* unsupported or missing tag changes nothing.
|
|
37
|
+
*/
|
|
38
|
+
syncLocale(tag: string | null | undefined): Promise<void>;
|
|
39
|
+
};
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -34,4 +34,19 @@ export declare function flattenMessages<const T extends Messages>(messages: T):
|
|
|
34
34
|
* placeholders. Unknown keys at runtime return the key.
|
|
35
35
|
*/
|
|
36
36
|
export declare function createTranslator<const T extends Messages>(messages: T): <K extends MessageKeys<T>>(key: K, ...args: PlaceholderArgs<Extract<MessageAt<T, K>, string>>) => string;
|
|
37
|
-
|
|
37
|
+
/** Generated key → placeholder-name map: `{ 'greeting': 'name', 'common.save': never }`. */
|
|
38
|
+
export type TranslationParamsMap = Record<string, string>;
|
|
39
|
+
/**
|
|
40
|
+
* Strict `t` over a generated key → placeholder-name map (see `hanzio-i18n
|
|
41
|
+
* generate`). Keys without placeholders take no params; keys with placeholders
|
|
42
|
+
* require every named value.
|
|
43
|
+
*/
|
|
44
|
+
export type TypedTranslate<Params extends TranslationParamsMap> = <Key extends keyof Params & string>(...args: [Params[Key]] extends [never] ? [key: Key] : [key: Key, params: Record<Params[Key], PlaceholderValue>]) => string;
|
|
45
|
+
/** Explicit escape hatch for data-driven keys validated outside TypeScript. */
|
|
46
|
+
export type DynamicTranslate = (key: string, params?: Record<string, PlaceholderValue>) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Narrows a framework's string-wide `t` (vue-i18n, i18next) to the generated
|
|
49
|
+
* map. Types only; returns `t` unchanged.
|
|
50
|
+
*/
|
|
51
|
+
export declare function typedTranslate<Params extends TranslationParamsMap>(t: (...args: never[]) => unknown): TypedTranslate<Params>;
|
|
52
|
+
export * from './locales';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type LocaleRegistry<L extends string> = {
|
|
2
|
+
/** Locale ids in declaration order. They name the catalog files. */
|
|
3
|
+
readonly locales: readonly L[];
|
|
4
|
+
readonly defaultLocale: L;
|
|
5
|
+
tag(locale: L): string;
|
|
6
|
+
name(locale: L): string;
|
|
7
|
+
/**
|
|
8
|
+
* A supported locale for a BCP-47-ish tag (`'da'`, `'da-DK'`, `'en_US'`), or
|
|
9
|
+
* `null`. Matches the id, then the tag, then the language subtag, then the
|
|
10
|
+
* aliases.
|
|
11
|
+
*/
|
|
12
|
+
match(tag: string | null | undefined): L | null;
|
|
13
|
+
/** The first candidate that matches, else `defaultLocale`. */
|
|
14
|
+
resolve(...candidates: readonly (string | null | undefined)[]): L;
|
|
15
|
+
};
|
|
16
|
+
/** The locale union of a registry: `LocaleOf<typeof locales>`. */
|
|
17
|
+
export type LocaleOf<R> = R extends LocaleRegistry<infer L> ? L : never;
|
|
18
|
+
/**
|
|
19
|
+
* The app's shipped UI locales, shared by every runtime and the catalog check.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* export const uiLocales = defineLocales({
|
|
23
|
+
* locales: {
|
|
24
|
+
* en: { tag: 'en-US', name: 'English' },
|
|
25
|
+
* nb: { tag: 'nb-NO', name: 'Norsk bokmål' }
|
|
26
|
+
* },
|
|
27
|
+
* defaultLocale: 'en',
|
|
28
|
+
* aliases: { no: 'nb' }
|
|
29
|
+
* })
|
|
30
|
+
* uiLocales.match('no-NO') // 'nb'
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function defineLocales<const T extends Record<string, {
|
|
34
|
+
/** BCP-47 tag for `Intl` and `<html lang>`, e.g. `'da-DK'`. */
|
|
35
|
+
tag: string;
|
|
36
|
+
/** The language naming itself, for locale pickers: `'Dansk'`. */
|
|
37
|
+
name: string;
|
|
38
|
+
}>>(options: {
|
|
39
|
+
locales: T;
|
|
40
|
+
defaultLocale: keyof T & string;
|
|
41
|
+
/** Extra tags or language subtags that mean a locale: `{ no: 'nb' }`. */
|
|
42
|
+
aliases?: Record<string, keyof T & string>;
|
|
43
|
+
}): LocaleRegistry<keyof T & string>;
|
|
44
|
+
/**
|
|
45
|
+
* A locale picker that switches immediately and rolls back when `persist`
|
|
46
|
+
* (for example saving the user's language on the server) rejects.
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* const selectLocale = createLocaleSelector({
|
|
50
|
+
* getLocale: () => locale.value,
|
|
51
|
+
* setLocale,
|
|
52
|
+
* persist: (locale) => api.user.updateLocale({ locale }),
|
|
53
|
+
* onError: () => toast.error(t('settings.language.error'))
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function createLocaleSelector<L extends string>(options: {
|
|
58
|
+
getLocale: () => L;
|
|
59
|
+
setLocale: (locale: L) => unknown;
|
|
60
|
+
persist?: (locale: L) => Promise<unknown>;
|
|
61
|
+
onError?: (error: unknown) => void;
|
|
62
|
+
}): (next: L) => Promise<void>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Dev-server plugin: reload the page with fresh catalogs when a
|
|
4
|
+
* `locales/*.json` file changes.
|
|
5
|
+
*
|
|
6
|
+
* `@intlify/unplugin-vue-i18n` serves each catalog as a `virtual:intlify-i18n-N`
|
|
7
|
+
* module that the module graph cannot tie back to its JSON file, and its own
|
|
8
|
+
* hot update only invalidates its bundle module, so an edited key kept serving
|
|
9
|
+
* the old catalog until the dev server restarted. This invalidates every
|
|
10
|
+
* catalog module and reloads: `createI18n` reads messages once at startup, so a
|
|
11
|
+
* hot swap would not reach the running instance anyway.
|
|
12
|
+
*/
|
|
13
|
+
export declare function localeCatalogReloadPlugin(options?: {
|
|
14
|
+
/** Which changed files are catalogs. Default: `.json` in a `locales` folder. */
|
|
15
|
+
match?: RegExp;
|
|
16
|
+
}): Plugin;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { WritableComputedRef } from 'vue';
|
|
2
|
+
import { type I18nOptions } from 'vue-i18n';
|
|
3
|
+
import { type SyncStorageLike } from '../storage';
|
|
4
|
+
import { type LocaleRegistry, type Messages, type TranslationParamsMap } from '.';
|
|
5
|
+
/**
|
|
6
|
+
* `createI18n` in composition mode, starting in the persisted locale, then the
|
|
7
|
+
* browser language, then `locales.defaultLocale` (also the fallback locale).
|
|
8
|
+
* `setLocale` is the one write path: it switches vue-i18n, persists the choice
|
|
9
|
+
* and keeps `<html lang>` accurate. `useI18n<Params>()` is vue-i18n's composer
|
|
10
|
+
* with the locale and `t` narrowed to the registry and a generated key map;
|
|
11
|
+
* make it the one place the app calls vue-i18n's `useI18n`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createVueI18n<L extends string>(options: Omit<I18nOptions, 'legacy' | 'locale' | 'messages'> & {
|
|
14
|
+
locales: LocaleRegistry<L>;
|
|
15
|
+
/** One catalog per locale; a missing locale is a type error. */
|
|
16
|
+
messages: Record<L, Messages>;
|
|
17
|
+
/**
|
|
18
|
+
* Remembers the chosen locale (a raw string) so screens before sign-in
|
|
19
|
+
* come up in the right language. Omit to persist nothing.
|
|
20
|
+
*/
|
|
21
|
+
storageKey?: string;
|
|
22
|
+
/** Defaults to `localStorage`, falling back to memory. */
|
|
23
|
+
storage?: SyncStorageLike;
|
|
24
|
+
}): {
|
|
25
|
+
i18n: import("vue-i18n").I18n<Record<L, Messages> extends Record<string, unknown> ? Record<L, Messages> : {}, {}, {}, L extends string ? L : string, false>;
|
|
26
|
+
setLocale(locale: L): void;
|
|
27
|
+
useI18n<Params extends TranslationParamsMap>(): {
|
|
28
|
+
id: number;
|
|
29
|
+
fallbackLocale: WritableComputedRef<import("@intlify/core-base").FallbackLocales<string>, import("@intlify/core-base").FallbackLocales<string>>;
|
|
30
|
+
inheritLocale: boolean;
|
|
31
|
+
availableLocales: string[];
|
|
32
|
+
messages: import("vue").ComputedRef<{
|
|
33
|
+
[x: string]: import("@intlify/core-base").LocaleMessage<import("vue-i18n").VueMessageType>;
|
|
34
|
+
}>;
|
|
35
|
+
datetimeFormats: import("vue").ComputedRef<{
|
|
36
|
+
[x: string]: import("vue-i18n").IntlDateTimeFormat;
|
|
37
|
+
}>;
|
|
38
|
+
numberFormats: import("vue").ComputedRef<{
|
|
39
|
+
[x: string]: import("vue-i18n").IntlNumberFormat;
|
|
40
|
+
}>;
|
|
41
|
+
modifiers: import("vue-i18n").LinkedModifiers<import("vue-i18n").VueMessageType>;
|
|
42
|
+
pluralRules: import("@intlify/core-base").PluralizationRules;
|
|
43
|
+
isGlobal: boolean;
|
|
44
|
+
missingWarn: boolean | RegExp;
|
|
45
|
+
fallbackWarn: boolean | RegExp;
|
|
46
|
+
fallbackRoot: boolean;
|
|
47
|
+
fallbackFormat: boolean;
|
|
48
|
+
warnHtmlMessage: boolean;
|
|
49
|
+
escapeParameter: boolean;
|
|
50
|
+
rt: import("vue-i18n").ComposerResolveLocaleMessageTranslation<string>;
|
|
51
|
+
d: import("vue-i18n").ComposerDateTimeFormatting<{
|
|
52
|
+
[x: string]: import("vue-i18n").IntlDateTimeFormat;
|
|
53
|
+
}, string, import("@intlify/core-base").RemoveIndexSignature<{
|
|
54
|
+
[x: string]: import("@intlify/core-base").DateTimeFormatOptions;
|
|
55
|
+
}>, never, never, never>;
|
|
56
|
+
n: import("vue-i18n").ComposerNumberFormatting<{
|
|
57
|
+
[x: string]: import("vue-i18n").IntlNumberFormat;
|
|
58
|
+
}, string, import("@intlify/core-base").RemoveIndexSignature<{
|
|
59
|
+
[x: string]: import("@intlify/core-base").NumberFormatOptions;
|
|
60
|
+
}>, never, never, never>;
|
|
61
|
+
te<Str extends string, Key extends string = string>(key: Key | Str, locale?: string | undefined): boolean;
|
|
62
|
+
tm<Key extends string, ResourceKeys extends string = string, Locale extends string = string, Target = import("@intlify/core-base").RemoveIndexSignature<{
|
|
63
|
+
[x: string]: import("vue-i18n").LocaleMessageValue<import("vue-i18n").VueMessageType>;
|
|
64
|
+
}>, Return = ResourceKeys extends import("@intlify/core-base").ResourcePath<Target> ? import("@intlify/core-base").ResourceValue<Target, ResourceKeys> : Record<string, any>>(key: Key | ResourceKeys): Return;
|
|
65
|
+
getLocaleMessage<MessageSchema extends import("@intlify/core-base").LocaleMessage<import("vue-i18n").VueMessageType> = never, LocaleSchema extends string = string, Locale extends string = string, Return = import("vue-i18n").IsNever<MessageSchema> extends true ? import("@intlify/core-base").RemoveIndexSignature<{
|
|
66
|
+
[x: string]: import("vue-i18n").LocaleMessageValue<import("vue-i18n").VueMessageType>;
|
|
67
|
+
}> : MessageSchema>(locale: Locale | LocaleSchema): Return;
|
|
68
|
+
setLocaleMessage<MessageSchema extends import("@intlify/core-base").LocaleMessage<import("vue-i18n").VueMessageType> = never, LocaleSchema extends string = string, Locale extends string = string, MessageType = import("vue-i18n").IsNever<MessageSchema> extends true ? import("@intlify/core-base").RemoveIndexSignature<{
|
|
69
|
+
[x: string]: import("vue-i18n").LocaleMessageValue<import("vue-i18n").VueMessageType>;
|
|
70
|
+
}> : MessageSchema, Message extends MessageType = MessageType>(locale: Locale | LocaleSchema, message: Message): void;
|
|
71
|
+
mergeLocaleMessage<MessageSchema extends import("@intlify/core-base").LocaleMessage<import("vue-i18n").VueMessageType> = never, LocaleSchema extends string = string, Locale extends string = string, Message = import("vue-i18n").IsNever<MessageSchema> extends true ? Record<string, any> : MessageSchema>(locale: Locale | LocaleSchema, message: Message): void;
|
|
72
|
+
getDateTimeFormat<DateTimeSchema extends Record<string, any> = never, LocaleSchema extends string = string, Locale extends string = string, Return = import("vue-i18n").IsNever<DateTimeSchema> extends true ? import("@intlify/core-base").RemoveIndexSignature<{
|
|
73
|
+
[x: string]: import("@intlify/core-base").DateTimeFormatOptions;
|
|
74
|
+
}> : DateTimeSchema>(locale: Locale | LocaleSchema): Return;
|
|
75
|
+
setDateTimeFormat<DateTimeSchema extends Record<string, any> = never, LocaleSchema extends string = string, Locale extends string = string, FormatsType = import("vue-i18n").IsNever<DateTimeSchema> extends true ? import("@intlify/core-base").RemoveIndexSignature<{
|
|
76
|
+
[x: string]: import("@intlify/core-base").DateTimeFormatOptions;
|
|
77
|
+
}> : DateTimeSchema, Formats extends FormatsType = FormatsType>(locale: Locale | LocaleSchema, format: Formats): void;
|
|
78
|
+
mergeDateTimeFormat<DateTimeSchema extends Record<string, any> = never, LocaleSchema extends string = string, Locale extends string = string, Formats = import("vue-i18n").IsNever<DateTimeSchema> extends true ? Record<string, any> : DateTimeSchema>(locale: Locale | LocaleSchema, format: Formats): void;
|
|
79
|
+
getNumberFormat<NumberSchema extends Record<string, any> = never, LocaleSchema extends string = string, Locale extends string = string, Return = import("vue-i18n").IsNever<NumberSchema> extends true ? import("@intlify/core-base").RemoveIndexSignature<{
|
|
80
|
+
[x: string]: import("@intlify/core-base").NumberFormatOptions;
|
|
81
|
+
}> : NumberSchema>(locale: Locale | LocaleSchema): Return;
|
|
82
|
+
setNumberFormat<NumberSchema extends Record<string, any> = never, LocaleSchema extends string = string, Locale extends string = string, FormatsType = import("vue-i18n").IsNever<NumberSchema> extends true ? import("@intlify/core-base").RemoveIndexSignature<{
|
|
83
|
+
[x: string]: import("@intlify/core-base").NumberFormatOptions;
|
|
84
|
+
}> : NumberSchema, Formats extends FormatsType = FormatsType>(locale: Locale | LocaleSchema, format: Formats): void;
|
|
85
|
+
mergeNumberFormat<NumberSchema extends Record<string, any> = never, LocaleSchema extends string = string, Locale extends string = string, Formats = import("vue-i18n").IsNever<NumberSchema> extends true ? Record<string, any> : NumberSchema>(locale: Locale | LocaleSchema, format: Formats): void;
|
|
86
|
+
getPostTranslationHandler(): import("vue-i18n").PostTranslationHandler<import("vue-i18n").VueMessageType> | null;
|
|
87
|
+
setPostTranslationHandler(handler: import("vue-i18n").PostTranslationHandler<import("vue-i18n").VueMessageType> | null): void;
|
|
88
|
+
getMissingHandler(): import("vue-i18n").MissingHandler | null;
|
|
89
|
+
setMissingHandler(handler: import("vue-i18n").MissingHandler | null): void;
|
|
90
|
+
locale: WritableComputedRef<L, L>;
|
|
91
|
+
t: import(".").TypedTranslate<Params>;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -165,5 +165,28 @@ function safeDecodeURIComponent(value) {
|
|
|
165
165
|
return value;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
+
function escapeHtml2(text) {
|
|
169
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
170
|
+
}
|
|
171
|
+
var EMOJI_PATTERN = /[\p{Extended_Pictographic}\u{1F1E6}-\u{1F1FF}\u{1F3FB}-\u{1F3FF}\u{20E3}\u{FE0F}\u{200D}]/gu;
|
|
172
|
+
function stripEmoji2(text) {
|
|
173
|
+
const stripped = text.replace(EMOJI_PATTERN, "");
|
|
174
|
+
if (stripped === text)
|
|
175
|
+
return text;
|
|
176
|
+
return stripped.replace(/ {2,}/g, " ").replace(/ +([,.!?;:])/g, "$1").trim();
|
|
177
|
+
}
|
|
178
|
+
function fileExtension2(filename) {
|
|
179
|
+
const name = filename.slice(Math.max(filename.lastIndexOf("/"), filename.lastIndexOf("\\")) + 1);
|
|
180
|
+
const dot = name.lastIndexOf(".");
|
|
181
|
+
if (dot <= 0 || dot === name.length - 1)
|
|
182
|
+
return;
|
|
183
|
+
return name.slice(dot + 1).toLowerCase();
|
|
184
|
+
}
|
|
185
|
+
function toJsonValue2(value) {
|
|
186
|
+
if (value === undefined)
|
|
187
|
+
return null;
|
|
188
|
+
const text = JSON.stringify(value);
|
|
189
|
+
return text === undefined ? null : JSON.parse(text);
|
|
190
|
+
}
|
|
168
191
|
|
|
169
|
-
export { extractNumber2, generateId2, sha256Id2, slugify2, stableStringify2, truncate2, normalizeWhitespace2, escapeRegExp2, foldForSearch2, matchesSearch2, initials2, safeJsonParse2 };
|
|
192
|
+
export { extractNumber2, generateId2, sha256Id2, slugify2, stableStringify2, truncate2, normalizeWhitespace2, escapeRegExp2, foldForSearch2, matchesSearch2, initials2, safeJsonParse2, escapeHtml2, stripEmoji2, fileExtension2, toJsonValue2 };
|