New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create error.ts #1620
Open
Youngemmy5956
wants to merge
1
commit into
intlify:master
Choose a base branch
from
Youngemmy5956:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Create error.ts #1620
Conversation
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
Typescript error when using pluralization and formatting intlify#1574
kazupon
requested changes
Nov 2, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should fix the below type definition
vue-i18n-next/packages/vue-i18n-core/src/composer.ts
Lines 641 to 976 in c37f6f0
export interface ComposerTranslation< | |
Messages extends Record<string, any> = {}, | |
Locales = 'en-US', | |
DefinedLocaleMessage extends | |
RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>, | |
C = IsEmptyObject<DefinedLocaleMessage> extends false | |
? PickupPaths<{ | |
[K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] | |
}> | |
: never, | |
M = IsEmptyObject<Messages> extends false ? PickupKeys<Messages> : never, | |
ResourceKeys extends C | M = IsNever<C> extends false | |
? IsNever<M> extends false | |
? C | M | |
: C | |
: IsNever<M> extends false | |
? M | |
: never | |
> { | |
/** | |
* Locale message translation | |
* | |
* @remarks | |
* If this is used in a reactive context, it will re-evaluate once the locale changes. | |
* | |
* If [UseI18nScope](general#usei18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope locale messages than global scope locale messages. | |
* | |
* If not, then it’s translated with global scope locale messages. | |
* | |
* @param key - A target locale message key | |
* | |
* @returns Translated message | |
* | |
* @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope) | |
*/ | |
<Key extends string>(key: Key | ResourceKeys | number): string | |
/** | |
* Locale message translation for plurals | |
* | |
* @remarks | |
* Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. | |
* | |
* In this overloaded `t`, return a pluralized translation message. | |
* | |
* You can also suppress the warning, when the translation missing according to the options. | |
* | |
* About details of options, see the {@link TranslateOptions}. | |
* | |
* @param key - A target locale message key | |
* @param plural - Which plural string to get. 1 returns the first one. | |
* @param options - Additional {@link TranslateOptions | options} for translation | |
* | |
* @returns Translated message | |
* | |
* @VueI18nSee [Pluralization](../guide/essentials/pluralization) | |
*/ | |
<Key extends string>( | |
key: Key | ResourceKeys | number, | |
plural: number, | |
options?: TranslateOptions<Locales> | |
): string | |
/** | |
* Locale message translation for missing default message | |
* | |
* @remarks | |
* Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. | |
* | |
* In this overloaded `t`, if no translation was found, return a default message. | |
* | |
* You can also suppress the warning, when the translation missing according to the options. | |
* | |
* About details of options, see the {@link TranslateOptions}. | |
* | |
* @param key - A target locale message key | |
* @param defaultMsg - A default message to return if no translation was found | |
* @param options - Additional {@link TranslateOptions | options} for translation | |
* | |
* @returns Translated message | |
*/ | |
<Key extends string>( | |
key: Key | ResourceKeys | number, | |
defaultMsg: string, | |
options?: TranslateOptions<Locales> | |
): string | |
/** | |
* Locale message translation for list interpolations | |
* | |
* @remarks | |
* Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. | |
* | |
* In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list. | |
* | |
* You can also suppress the warning, when the translation missing according to the options. | |
* | |
* About details of options, see the {@link TranslateOptions}. | |
* | |
* @param key - A target locale message key | |
* @param list - A values of list interpolation | |
* @param options - Additional {@link TranslateOptions | options} for translation | |
* | |
* @returns Translated message | |
* | |
* @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) | |
*/ | |
<Key extends string>( | |
key: Key | ResourceKeys | number, | |
list: unknown[], | |
options?: TranslateOptions<Locales> | |
): string | |
/** | |
* Locale message translation for list interpolations and plurals | |
* | |
* @remarks | |
* Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. | |
* | |
* In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list, and return a pluralized translation message. | |
* | |
* @param key - A target locale message key | |
* @param list - A values of list interpolation | |
* @param plural - Which plural string to get. 1 returns the first one. | |
* | |
* @returns Translated message | |
* | |
* @VueI18nSee [Pluralization](../guide/essentials/pluralization) | |
* @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) | |
*/ | |
<Key extends string>( | |
key: Key | ResourceKeys | number, | |
list: unknown[], | |
plural: number | |
): string | |
/** | |
* Locale message translation for list interpolations and missing default message | |
* | |
* @remarks | |
* Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. | |
* | |
* In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list, and if no translation was found, return a default message. | |
* | |
* @param key - A target locale message key | |
* @param list - A values of list interpolation | |
* @param defaultMsg - A default message to return if no translation was found | |
* | |
* @returns Translated message | |
* | |
* @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) | |
*/ | |
<Key extends string>( | |
key: Key | ResourceKeys | number, | |
list: unknown[], | |
defaultMsg: string | |
): string | |
/** | |
* Locale message translation for named interpolations | |
* | |
* @remarks | |
* Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. | |
* | |
* In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token. | |
* | |
* You can also suppress the warning, when the translation missing according to the options. | |
* | |
* About details of options, see the {@link TranslateOptions}. | |
* | |
* @param key - A target locale message key | |
* @param named - A values of named interpolation | |
* @param options - Additional {@link TranslateOptions | options} for translation | |
* | |
* @returns Translated message | |
* | |
* @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) | |
*/ | |
<Key extends string>( | |
key: Key | ResourceKeys | number, | |
named: NamedValue, | |
options?: TranslateOptions<Locales> | |
): string | |
/** | |
* Locale message translation for named interpolations and plurals | |
* | |
* @remarks | |
* Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. | |
* | |
* In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token, and return a pluralized translation message. | |
* | |
* @param key - A target locale message key | |
* @param named - A values of named interpolation | |
* @param plural - Which plural string to get. 1 returns the first one. | |
* | |
* @returns Translated message | |
* | |
* @VueI18nSee [Pluralization](../guide/essentials/pluralization) | |
* @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) | |
*/ | |
<Key extends string>( | |
key: Key | ResourceKeys | number, | |
named: NamedValue, | |
plural: number | |
): string | |
/** | |
* Locale message translation for named interpolations and plurals | |
* | |
* @remarks | |
* Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details. | |
* | |
* In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token, and if no translation was found, return a default message. | |
* | |
* @param key - A target locale message key | |
* @param named - A values of named interpolation | |
* @param defaultMsg - A default message to return if no translation was found | |
* | |
* @returns Translated message | |
* | |
* @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) | |
*/ | |
<Key extends string>( | |
key: Key | ResourceKeys | number, | |
named: NamedValue, | |
defaultMsg: string | |
): string | |
} | |
/** | |
* Resolve locale message translation functions | |
* | |
* @remarks | |
* This is the interface for {@link Composer} | |
* | |
* @VueI18nComposition | |
*/ | |
export interface ComposerResolveLocaleMessageTranslation<Locales = 'en-US'> { | |
/** | |
* Resolve locale message translation | |
* | |
* @remarks | |
* If this is used in a reactive context, it will re-evaluate once the locale changes. | |
* | |
* If [UseI18nScope](general#usei18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope locale messages than global scope locale messages. | |
* | |
* If not, then it’s translated with global scope locale messages. | |
* | |
* @VueI18nTip | |
* The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement. | |
* | |
* @VueI18nWarning | |
* `rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`. | |
* | |
* @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`. | |
* | |
* @returns Translated message | |
* | |
* @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope) | |
*/ | |
(message: MessageFunction<VueMessageType> | VueMessageType): string | |
/** | |
* Resolve locale message translation for plurals | |
* | |
* @remarks | |
* Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-message-message-string) details. | |
* | |
* In this overloaded `rt`, return a pluralized translation message. | |
* | |
* @VueI18nTip | |
* The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement. | |
* | |
* @VueI18nWarning | |
* `rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`. | |
* | |
* @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`. | |
* @param plural - Which plural string to get. 1 returns the first one. | |
* @param options - Additional {@link TranslateOptions | options} for translation | |
* | |
* @returns Translated message | |
* | |
* @VueI18nSee [Pluralization](../guide/essentials/pluralization) | |
*/ | |
( | |
message: MessageFunction<VueMessageType> | VueMessageType, | |
plural: number, | |
options?: TranslateOptions<Locales> | |
): string | |
/** | |
* Resolve locale message translation for list interpolations | |
* | |
* @remarks | |
* Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-message-message-string) details. | |
* | |
* In this overloaded `rt`, return a pluralized translation message. | |
* | |
* @VueI18nTip | |
* The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement. | |
* | |
* @VueI18nWarning | |
* `rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`. | |
* | |
* @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`. | |
* @param list - A values of list interpolation. | |
* @param options - Additional {@link TranslateOptions | options} for translation | |
* | |
* @returns Translated message | |
* | |
* @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation) | |
*/ | |
( | |
message: MessageFunction<VueMessageType> | VueMessageType, | |
list: unknown[], | |
options?: TranslateOptions<Locales> | |
): string | |
/** | |
* Resolve locale message translation for named interpolations | |
* | |
* @remarks | |
* Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-message-message-string) details. | |
* | |
* In this overloaded `rt`, for each placeholder x, the locale messages should contain a `{x}` token. | |
* | |
* @VueI18nTip | |
* The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement. | |
* | |
* @VueI18nWarning | |
* `rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`. | |
* | |
* @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`. | |
* @param named - A values of named interpolation. | |
* @param options - Additional {@link TranslateOptions | options} for translation | |
* | |
* @returns Translated message | |
* | |
* @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation) | |
*/ | |
( | |
message: MessageFunction<VueMessageType> | VueMessageType, | |
named: NamedValue, | |
options?: TranslateOptions<Locales> | |
): string | |
} |
will check it out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Typescript error when using pluralization and formatting #1574