Skip to content
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

improve: component injection properties typing hints on VSCode #197

Merged
merged 5 commits into from Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -39,3 +39,5 @@ jobs:
run: yarn install
- name: Test
run: yarn test
# https://github.com/actions/runner/issues/795
- run: echo "NODE_ICU_DATA=" >> $GITHUB_ENV
4 changes: 3 additions & 1 deletion .textlintrc.js
Expand Up @@ -27,7 +27,9 @@ module.exports = {
'JSON5',
'HTTP',
'CLI',
'SFC'
'SFC',
'PHP',
'SSR'
]
},
'abbr-within-parentheses': true,
Expand Down
8 changes: 4 additions & 4 deletions docs/.vitepress/config.js
Expand Up @@ -114,19 +114,19 @@ const config = {
link: '/essentials/pluralization'
},
{
text: 'DateTime Localization',
text: 'Datetime Formatting',
link: '/essentials/datetime'
},
{
text: 'Number Localization',
text: 'Number Formatting',
link: '/essentials/number'
},
{
text: 'Scope and Locale Changing',
link: '/essentials/scope'
},
{
text: 'Fallback Localization',
text: 'Fallbacking',
link: '/essentials/fallback'
},
{
Expand All @@ -140,7 +140,7 @@ const config = {
collapsable: false,
children: [
{
text: 'Custom Directive Localization',
text: 'Custom Directive',
link: '/advanced/directive'
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/advanced/composition.md
Expand Up @@ -177,7 +177,7 @@ export default {
In the Composition API mode, plural translations have been integrated into `t`.
:::

## Datetime Localization
## Datetime Formatting

In the Legacy API mode, Datetime value was localized using `$d` or the VueI18n instance of `d`.

Expand Down Expand Up @@ -225,7 +225,7 @@ export default {

For more detals of `d`, see the [API Reference](../api/composition#d).

## Number Localization
## Number Formatting

In the Legacy API mode, Number value is localized using `$n` or the `n` of the VueI18n instance.

Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/directive.md
@@ -1,4 +1,4 @@
# Custom Directive Localization
# Custom Directive

You can translate not only with `$t`, but also with the `v-t` custom directive.

Expand Down
2 changes: 1 addition & 1 deletion docs/essentials/datetime.md
@@ -1,4 +1,4 @@
# DateTime Localization
# Datetime Formatting

## Basic Usage
You can localize the datetime with your definition formats.
Expand Down
2 changes: 1 addition & 1 deletion docs/essentials/fallback.md
@@ -1,4 +1,4 @@
# Fallback localization
# Fallbacking

`fallbackLocale: '<lang>'` to choose which language to use when your preferred language lacks a translation.

Expand Down
2 changes: 1 addition & 1 deletion docs/essentials/number.md
@@ -1,4 +1,4 @@
# Number Localization
# Number Formatting

## Basic Usage

Expand Down
8 changes: 4 additions & 4 deletions docs/tooling.md
Expand Up @@ -37,7 +37,7 @@ It easily integrates some localization lint features to your Vue.js Application.
You can use this extension to enable SSR and improve i18n performance.


## 3rd party tooling
## Third-party tooling

### BabelEdit

Expand All @@ -51,13 +51,13 @@ Read more about BabelEdit in [tutorial page](https://www.codeandweb.com/babeledi

[i18n Ally](https://marketplace.visualstudio.com/items?itemName=antfu.i18n-ally) is i18n extension for VSCode.

i18n Ally give awesome DX for your i18n development.
The i18n Ally give awesome developer experience for your i18n development.

Read more about i18n Ally in [README](https://github.com/antfu/i18n-ally/blob/master/README.md).

### i18nPlugin (intellij platform)

[i18nPlugin](https://github.com/nyavro/i18nPlugin) Intellij idea i18next support plugin ( [Jetbrains plugin page ](https://plugins.jetbrains.com/plugin/12981-i18n-support)).
[i18nPlugin](https://github.com/nyavro/i18nPlugin) Intellij idea i18next support plugin ( [JetBrains plugin page ](https://plugins.jetbrains.com/plugin/12981-i18n-support)).

Plugin for i18n typescript/javascript/PHP. Supports vue-i18n. To enable vue-i18n support go to settings -> Tools -> i18n Plugin configuration and check "Vue-i18n". You need set vue locales directory (locales by default).

Expand All @@ -68,6 +68,6 @@ Plugin for i18n typescript/javascript/PHP. Supports vue-i18n. To enable vue-i18n
- list of all the **unused vue-i18n keys** (entries found in the language files but not used in the project)
- list of all the **missing keys** (entries fond in the project but not in the language files)

It's possible to show the output in the console or to write it in a json file.
Its possible to show the output in the console or to write it in a json file.

The missing keys can be also automatically added to the given language files.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -139,7 +139,7 @@
"benchmark": "yarn build && node ./benchmark/index.js",
"build": "yarn clean:cache:rollup && node ./scripts/build.js",
"build:sourcemap": "yarn build --sourcemap",
"build:type": "yarn build --types && tail -n +14 src/vue.d.ts >> ./dist/vue-i18n.d.ts",
"build:type": "yarn build --types && tail -n +14 ./src/vue.d.ts >> ./dist/vue-i18n.d.ts",
"build:watch": "tsc -p . --watch",
"clean": "npm-run-all --parallel clean:*",
"clean:cache": "yarn clean:cache:rollup && yarn clean:cache:jest",
Expand Down
5 changes: 5 additions & 0 deletions src/core/context.ts
Expand Up @@ -27,19 +27,24 @@ import {
NumberFormats as NumberFormatsType
} from './types'

/** @VueI18nGeneral */
export type Locale = string

/** @VueI18nGeneral */
export type FallbackLocale =
| Locale
| Locale[]
| { [locale in string]: Locale[] }
| false

/** @VueI18nGeneral */
export type LocaleMessageValue<Message = string> =
| string
| MessageFunction<Message>
| LocaleMessageDictionary<Message>
| LocaleMessageArray<Message>

/** @VueI18nGeneral */
export type LocaleMessageDictionary<Message = string> = {
[property: string]: LocaleMessageValue<Message>
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/datetime.ts
Expand Up @@ -66,7 +66,7 @@ import { DevToolsTimelineEvents } from '../debugger/constants'
* datetime(context, value, { key: 'short', part: true }, { currency: 'EUR'})
*/

/** @internal */
/** @VueI18nGeneral */
export type DateTimeOptions = {
key?: string
locale?: Locale
Expand Down
2 changes: 1 addition & 1 deletion src/core/number.ts
Expand Up @@ -64,7 +64,7 @@ import { DevToolsTimelineEvents } from '../debugger/constants'
* number(context, value, { key: 'currenty', part: true }, { year: '2-digit'})
*/

/** @internal */
/** @VueI18nGeneral */
export type NumberOptions = {
key?: string
locale?: Locale
Expand Down
2 changes: 1 addition & 1 deletion src/core/translate.ts
Expand Up @@ -90,7 +90,7 @@ const isMessageFunction = <T>(val: unknown): val is MessageFunction<T> =>
* translate(context, 'foo.bar', { name: 'kazupon' }, { escapeParameter: true })
*/

/** @internal */
/** @VueI18nGeneral */
export type TranslateOptions = {
list?: unknown[]
named?: NamedValue
Expand Down
9 changes: 4 additions & 5 deletions src/legacy.ts
Expand Up @@ -50,19 +50,18 @@ import {
} from './utils'
import { DevToolsEmitter } from './debugger/constants'

/**
* Translate Result
*
* @VueI18nLegacy
*/
/** @VueI18nLegacy */
export type TranslateResult = string
export type Choice = number
/** @VueI18nLegacy */
export type LocaleMessageObject<Message = string> = LocaleMessageDictionary<
Message
>
export type PluralizationRulesMap = { [locale: string]: PluralizationRule }
export type WarnHtmlInMessageLevel = 'off' | 'warn' | 'error'
/** @VueI18nLegacy */
export type DateTimeFormatResult = string
/** @VueI18nLegacy */
export type NumberFormatResult = string
export interface Formatter {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
1 change: 1 addition & 0 deletions src/message/runtime.ts
Expand Up @@ -62,6 +62,7 @@ export type PluralizationProps = {
export type LinkedModify<T = string> = (value: T) => MessageType<T>
export type LinkedModifiers<T = string> = { [key: string]: LinkedModify<T> }

/** @VueI18nGeneral */
export type NamedValue<T = {}> = T & Record<string, unknown>

// TODO: list and named type definition more improvements
Expand Down