diff --git a/docs/guide/migration/vue2.md b/docs/guide/migration/vue2.md index 001af6423..824da10b7 100644 --- a/docs/guide/migration/vue2.md +++ b/docs/guide/migration/vue2.md @@ -3,7 +3,7 @@ ## `vue-i18n-bridge` :::danger NOTE -vue-i18n-bridge will not be provided in v10 due to Vue 2 EOL. v9.x will be the last version. +vue-i18n-bridge will not be provided in v10 due to Vue 2 EOL. v9.13 will be the last version. ::: ### What is `vue-i18n-bridge`? diff --git a/e2e/bridge/basic.spec.ts b/e2e/bridge/basic.spec.ts deleted file mode 100644 index 9bfab2eb1..000000000 --- a/e2e/bridge/basic.spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { getText } from '../helper' -;['composition', 'legacy'].forEach(pattern => { - describe(`${pattern}`, () => { - beforeAll(async () => { - await page.goto( - `http://localhost:8080/examples/bridge/${pattern}/basic.html` - ) - }) - - test('initial rendering', async () => { - expect(await getText(page, 'label')).toMatch('言語') - expect(await getText(page, 'p')).toMatch('こんにちは、vue-i18n-bridge!') - }) - - test('change locale', async () => { - await page.selectOption('#app select', 'en') - expect(await getText(page, 'label')).toMatch('Language') - expect(await getText(page, 'p')).toMatch('hello, vue-i18n-bridge!') - }) - }) -}) diff --git a/e2e/bridge/component.spec.ts b/e2e/bridge/component.spec.ts deleted file mode 100644 index 58bd5e704..000000000 --- a/e2e/bridge/component.spec.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { getText } from '../helper' -;['composition', 'legacy'].forEach(pattern => { - describe(`${pattern}`, () => { - beforeAll(async () => { - await page.goto( - `http://localhost:8080/examples/bridge/${pattern}/component.html` - ) - }) - - test('rendering', async () => { - expect(await getText(page, '#app p')).toMatch('こんにちは、かずぽん!') - }) - }) -}) diff --git a/e2e/bridge/components/datetime-format.spec.ts b/e2e/bridge/components/datetime-format.spec.ts deleted file mode 100644 index 7a1c125b4..000000000 --- a/e2e/bridge/components/datetime-format.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { getText } from '../../helper' -describe(`bridge: datetime format component`, () => { - beforeAll(async () => { - await page.goto( - `http://localhost:8080/examples/bridge/composition/components/datetime-format.html` - ) - }) - - test('rendering', async () => { - expect(await getText(page, '#app p.p1')).toMatch( - /([1-9]|1[0-2])\/([1-9]|[12]\d|3[01])\/([12]\d{3})/ - ) - expect(await getText(page, '#app p.p2')).toMatch( - /(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/([12]\d{3}), (0[0-9]|1[0-2]):([0-5][0-9]):([0-5][0-9])\u202f(AM|PM)/ - ) - expect(await getText(page, '#app p.p3')).toMatch( - /令和([1-9]|1[0-2])年([1-9]|1[0-2])月([1-9]|[1-3][0-9])日(月|火|水|木|金|土|日)曜日 (午前|午後)([0-9]|1[0-2]):([0-5][0-9]):([0-5][0-9]) 協定世界時/ - ) - expect(await getText(page, '#app span.p4')).toMatch( - /([1-9]|1[0-2])年([1-9]|1[0-2])月([1-9]|[1-3][0-9])日(月|火|水|木|金|土|日)曜日 (午前|午後)([0-9]|1[0-2]):([0-5][0-9]):([0-5][0-9]) 協定世界時/ - ) - }) -}) diff --git a/e2e/bridge/components/number-format.spec.ts b/e2e/bridge/components/number-format.spec.ts deleted file mode 100644 index 1f443dd93..000000000 --- a/e2e/bridge/components/number-format.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { getText } from '../../helper' -describe(`bridge: number format component`, () => { - beforeAll(async () => { - await page.goto( - `http://localhost:8080/examples/bridge/composition/components/number-format.html` - ) - }) - - test('rendering', async () => { - expect(await getText(page, '#app p.p1')).toMatch('100') - expect(await getText(page, '#app p.p2')).toMatch('$100.00') - expect(await getText(page, '#app p.p3')).toMatch('¥100') - expect(await getText(page, '#app div.slot')).toMatch('€1,234.00') - }) -}) diff --git a/e2e/bridge/components/translation.spec.ts b/e2e/bridge/components/translation.spec.ts deleted file mode 100644 index 2e76e9a55..000000000 --- a/e2e/bridge/components/translation.spec.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { getText } from '../../helper' -describe(`bridge: translation component`, () => { - beforeAll(async () => { - await page.goto( - `http://localhost:8080/examples/bridge/composition/components/translation.html` - ) - }) - - test('rendering', async () => { - expect(await getText(page, '#app p.name')).toMatch('こんにちは、kazupon!') - expect(await getText(page, '#app p.list')).toMatch('hello, English!') - expect(await getText(page, '#app p.linked')).toMatch( - 'こんにちは、かずぽん! ごきげんいかが?' - ) - expect(await getText(page, '#app p.plural')).toMatch('no bananas') - }) - - test('change quantity', async () => { - await page.selectOption('#app select', '1') - expect(await getText(page, '#app p.plural')).toMatch('1 banana') - await page.selectOption('#app select', '2') - expect(await getText(page, '#app p.plural')).toMatch('2 bananas') - await page.selectOption('#app select', '0') - expect(await getText(page, '#app p.plural')).toMatch('no bananas') - }) -}) diff --git a/e2e/bridge/plural.spec.ts b/e2e/bridge/plural.spec.ts deleted file mode 100644 index d331e7946..000000000 --- a/e2e/bridge/plural.spec.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { getText } from '../helper' -;['composition', 'legacy'].forEach(pattern => { - describe(`${pattern}`, () => { - beforeAll(async () => { - await page.goto( - `http://localhost:8080/examples/bridge/${pattern}/plural.html` - ) - }) - - test('initial rendering', async () => { - expect(await getText(page, '#app p.p1')).toMatch('car') - expect(await getText(page, '#app p.p2')).toMatch('cars') - expect(await getText(page, '#app p.p3')).toMatch('no apples') - expect(await getText(page, '#app p.p4')).toMatch('one apple') - expect(await getText(page, '#app p.p5')).toMatch('10 apples') - expect(await getText(page, '#app p.p7')).toMatch('1 banana') - expect(await getText(page, '#app p.p9')).toMatch('too many bananas') - }) - }) -}) diff --git a/e2e/bridge/scope/global.spec.ts b/e2e/bridge/scope/global.spec.ts deleted file mode 100644 index 8e72c8936..000000000 --- a/e2e/bridge/scope/global.spec.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { getText } from '../../helper' -;['composition', 'legacy'].forEach(pattern => { - describe(`${pattern}`, () => { - beforeAll(async () => { - await page.goto( - `http://localhost:8080/examples/bridge/${pattern}/scope/global.html` - ) - }) - - test('initial rendering', async () => { - expect(await getText(page, '#app p.parent')).toMatch('こんにちは、世界!') - expect(await getText(page, '#app p.child')).toMatch('こんにちは!') - expect(await getText(page, '#app p.sub-child')).toMatch('こんにちは!') - }) - - test('change locale', async () => { - await page.selectOption('#app select', 'en') - expect(await getText(page, '#app p.parent')).toMatch('hello world!') - expect(await getText(page, '#app p.child')).toMatch('Hi !') - expect(await getText(page, '#app p.sub-child')).toMatch('Hi !') - - await page.selectOption('#app div.sub-child select', 'ja') - expect(await getText(page, '#app p.parent')).toMatch('こんにちは、世界!') - expect(await getText(page, '#app p.child')).toMatch('こんにちは!') - expect(await getText(page, '#app p.sub-child')).toMatch('こんにちは!') - }) - }) -}) diff --git a/e2e/bridge/scope/inherit-locale.spec.ts b/e2e/bridge/scope/inherit-locale.spec.ts deleted file mode 100644 index e165e1988..000000000 --- a/e2e/bridge/scope/inherit-locale.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { getText } from '../../helper' -;['composition', 'legacy'].forEach(pattern => { - describe(`${pattern}`, () => { - beforeAll(async () => { - await page.goto( - `http://localhost:8080/examples/bridge/${pattern}/scope/inherit-locale.html` - ) - }) - - test('initial rendering', async () => { - expect(await getText(page, '#app p.parent')).toMatch('こんにちは、世界!') - expect(await getText(page, '#app p.child')).toMatch('やあ!') - expect(await getText(page, '#app label[for=checkbox]')).toMatch( - 'root から locale を継承する' - ) - }) - - test('change locale', async () => { - // root - await page.selectOption('#app select', 'en') - expect(await getText(page, '#app p.parent')).toMatch('hello world!') - expect(await getText(page, '#app p.child')).toMatch('Hi there!') - expect(await getText(page, '#app label[for=checkbox]')).toMatch( - 'Inherit locale from root' - ) - - // Child - await page.selectOption('#app div.child select', 'ja') - expect(await getText(page, '#app p.parent')).toMatch('hello world!') - expect(await getText(page, '#app p.child')).toMatch('やあ!') - expect(await getText(page, '#app label[for=checkbox]')).toMatch( - 'root から locale を継承する' - ) - - // checkbox off - await page.click('#checkbox') - await page.selectOption('#app select', 'ja') - await page.selectOption('#app select', 'en') - expect(await getText(page, '#app p.parent')).toMatch('hello world!') - - // checkbox on - await page.click('#checkbox') - await page.selectOption('#app select', 'ja') - await page.selectOption('#app select', 'en') - expect(await getText(page, '#app p.parent')).toMatch('hello world!') - expect(await getText(page, '#app p.child')).toMatch('Hi there!') - expect(await getText(page, '#app label[for=checkbox]')).toMatch( - 'Inherit locale from root' - ) - }) - }) -}) diff --git a/e2e/bridge/scope/local.spec.ts b/e2e/bridge/scope/local.spec.ts deleted file mode 100644 index c55ff0996..000000000 --- a/e2e/bridge/scope/local.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { getText } from '../../helper' -;['composition', 'legacy'].forEach(pattern => { - describe(`${pattern}`, () => { - beforeAll(async () => { - await page.goto( - `http://localhost:8080/examples/bridge/${pattern}/scope/local.html` - ) - }) - - test('initial rendering', async () => { - expect(await getText(page, '#app p.parent')).toMatch('こんにちは、世界!') - expect(await getText(page, '#app p.child')).toMatch('やあ!') - }) - - test('change locale', async () => { - // root - await page.selectOption('#app select', 'en') - expect(await getText(page, '#app p.parent')).toMatch('hello world!') - expect(await getText(page, '#app p.child')).toMatch('Hi there!') - - // Child - await page.selectOption('#app div.child select', 'ja') - expect(await getText(page, '#app p.parent')).toMatch('hello world!') - expect(await getText(page, '#app p.child')).toMatch('やあ!') - }) - }) -}) diff --git a/examples/bridge/composition/basic.html b/examples/bridge/composition/basic.html deleted file mode 100644 index 09defde9f..000000000 --- a/examples/bridge/composition/basic.html +++ /dev/null @@ -1,60 +0,0 @@ - - - - - Composition - - - - - - -
-
- - -
-

{{ t("message.hello", { name: 'vue-i18n-bridge' }) }}

-
- - - diff --git a/examples/bridge/composition/component.html b/examples/bridge/composition/component.html deleted file mode 100644 index c0663bca2..000000000 --- a/examples/bridge/composition/component.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - Translation component example - - - - - - -
-

Translation component

- - - -
- - - diff --git a/examples/bridge/composition/components/datetime-format.html b/examples/bridge/composition/components/datetime-format.html deleted file mode 100644 index 11df18901..000000000 --- a/examples/bridge/composition/components/datetime-format.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - - DatetimeFormat component examples - - - - - - -

DatetimeFormat component examples

- -
-

basic usages:

- - - - -

slot usages:

- - - -
- - - diff --git a/examples/bridge/composition/components/number-format.html b/examples/bridge/composition/components/number-format.html deleted file mode 100644 index 4d35bcd38..000000000 --- a/examples/bridge/composition/components/number-format.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - - NumberFormat component examples - - - - - - -

NumberFormat component examples

- -
-

basic usages:

- - - - -

slot usages:

- - - - - - -
- - - diff --git a/examples/bridge/composition/components/translation.html b/examples/bridge/composition/components/translation.html deleted file mode 100644 index e0cfed7d2..000000000 --- a/examples/bridge/composition/components/translation.html +++ /dev/null @@ -1,104 +0,0 @@ - - - - - Translation component example - - - - - - -

Translation component example

- -
-

localize with slot contents:

- - - - -

localize with DOM contents:

- - {{ t('message.language', {}, { locale: 'en' }) }} - - -

localize with using linked:

- - - - -

localize with using plural:

-
- - -
- - - -
- - - diff --git a/examples/bridge/composition/plural.html b/examples/bridge/composition/plural.html deleted file mode 100644 index ad1477793..000000000 --- a/examples/bridge/composition/plural.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - plural basic usage examples - - - - - - -
-

Car:

-

{{ t('car', 1) }}

-

{{ t('car', 2) }}

-

Apple:

-

{{ t('apple', 0) }}

-

{{ t('apple', 1) }}

-

{{ t('apple', { count: 10 }, 10) }}

-

{{ t('apple', 10) }}

-

Banana:

-

{{ t('banana', { n: 1 }, 1) }}

-

{{ t('banana', 1) }}

-

{{ t('banana', { n: 'too many' }, 100) }}

-
- - - diff --git a/examples/bridge/composition/scope/global.html b/examples/bridge/composition/scope/global.html deleted file mode 100644 index fa20d31f4..000000000 --- a/examples/bridge/composition/scope/global.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - - Global scope example - - - - - - -
-

Root

-
- - -
-

{{ $t('message.hello') }}

- -
- - - diff --git a/examples/bridge/composition/scope/inherit-locale.html b/examples/bridge/composition/scope/inherit-locale.html deleted file mode 100644 index 207bce217..000000000 --- a/examples/bridge/composition/scope/inherit-locale.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - Inherit locale example - - - - - - -
-

Root

-
- - -
-

{{ t("message.hello") }}

- -
- - - diff --git a/examples/bridge/composition/scope/local.html b/examples/bridge/composition/scope/local.html deleted file mode 100644 index 09c716660..000000000 --- a/examples/bridge/composition/scope/local.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Local scope example - - - - - - - -
-

Root

-
- - -
-

{{ t("message.hello") }}

- -
- - - diff --git a/examples/bridge/legacy/basic.html b/examples/bridge/legacy/basic.html deleted file mode 100644 index 356f5fdff..000000000 --- a/examples/bridge/legacy/basic.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - Legacy - - - - - - - -
-
- - -
-

{{ $t("message.hello", { name: 'vue-i18n-bridge' }) }}

-
- - - diff --git a/examples/bridge/legacy/component.html b/examples/bridge/legacy/component.html deleted file mode 100644 index 8ecaea78c..000000000 --- a/examples/bridge/legacy/component.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - Translation component example - - - - - - - -
-

Translation component

- - - -
- - - diff --git a/examples/bridge/legacy/plural.html b/examples/bridge/legacy/plural.html deleted file mode 100644 index 21e3ea0bf..000000000 --- a/examples/bridge/legacy/plural.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - plural basic usage examples - - - - - - - -
-

Car:

-

{{ $tc('car', 1) }}

-

{{ $tc('car', 2) }}

-

Apple:

-

{{ $tc('apple', 0) }}

-

{{ $tc('apple', 1) }}

-

{{ $tc('apple', 10, { count: 10 }) }}

-

{{ $tc('apple', 10) }}

-

Banana:

-

{{ $tc('banana', 1, { n: 1 }) }}

-

{{ $tc('banana', 1) }}

-

{{ $tc('banana', 100, { n: 'too many' }) }}

-
- - - diff --git a/examples/bridge/legacy/scope/global.html b/examples/bridge/legacy/scope/global.html deleted file mode 100644 index 90509ee8b..000000000 --- a/examples/bridge/legacy/scope/global.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - Global scope example - - - - - - - -
-

Root

-
- - -
-

{{ $t('message.hello') }}

- -
- - - diff --git a/examples/bridge/legacy/scope/inherit-locale.html b/examples/bridge/legacy/scope/inherit-locale.html deleted file mode 100644 index ed33796aa..000000000 --- a/examples/bridge/legacy/scope/inherit-locale.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - - Inherit locale example - - - - - - - -
-

Root

-
- - -
-

{{ $t("message.hello") }}

- -
- - - diff --git a/examples/bridge/legacy/scope/local.html b/examples/bridge/legacy/scope/local.html deleted file mode 100644 index 679b04777..000000000 --- a/examples/bridge/legacy/scope/local.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - Local scope example - - - - - - - -
-

Root

-
- - -
-

{{ $t("message.hello") }}

- -
- - - diff --git a/packages/core-base/src/context.ts b/packages/core-base/src/context.ts index df939c3a8..24e97a976 100644 --- a/packages/core-base/src/context.ts +++ b/packages/core-base/src/context.ts @@ -616,7 +616,7 @@ export function createCoreContext(options: any = {}): any { } // for vue-devtools timeline event - if (!__BRIDGE__ && __DEV__) { + if (__DEV__) { ;(context as unknown as CoreInternalContext).__v_emitter = internalOptions.__v_emitter != null ? internalOptions.__v_emitter @@ -658,7 +658,7 @@ export function handleMissing( const { missing, onWarn } = context // for vue-devtools timeline event - if (!__BRIDGE__ && __DEV__) { + if (__DEV__) { const emitter = (context as unknown as CoreInternalContext).__v_emitter if (emitter) { emitter.emit(VueDevToolsTimelineEvents.MISSING, { diff --git a/packages/core-base/src/datetime.ts b/packages/core-base/src/datetime.ts index 46d563e44..0b9dbb771 100644 --- a/packages/core-base/src/datetime.ts +++ b/packages/core-base/src/datetime.ts @@ -251,7 +251,7 @@ export function datetime< } // for vue-devtools timeline event - if (!__BRIDGE__ && __DEV__ && locale !== targetLocale) { + if (__DEV__ && locale !== targetLocale) { const emitter = (context as unknown as CoreInternalContext).__v_emitter if (emitter) { emitter.emit(VueDevToolsTimelineEvents.FALBACK, { diff --git a/packages/core-base/src/number.ts b/packages/core-base/src/number.ts index a6bd09f1a..ab1aa07ba 100644 --- a/packages/core-base/src/number.ts +++ b/packages/core-base/src/number.ts @@ -246,7 +246,7 @@ export function number< } // for vue-devtools timeline event - if (!__BRIDGE__ && __DEV__ && locale !== targetLocale) { + if (__DEV__ && locale !== targetLocale) { const emitter = (context as unknown as CoreInternalContext).__v_emitter if (emitter) { emitter.emit(VueDevToolsTimelineEvents.FALBACK, { diff --git a/packages/core-base/src/translate.ts b/packages/core-base/src/translate.ts index 70a54e44e..496664c0f 100644 --- a/packages/core-base/src/translate.ts +++ b/packages/core-base/src/translate.ts @@ -777,14 +777,14 @@ export function translate< ? (format as MessageFunctionInternal).key! : '', locale: targetLocale || (isMessageFunction(format) - ? (format as MessageFunctionInternal).locale! - : ''), + ? (format as MessageFunctionInternal).locale! + : ''), format: isString(format) - ? format - : isMessageFunction(format) - ? (format as MessageFunctionInternal).source! - : '', + ? format + : isMessageFunction(format) + ? (format as MessageFunctionInternal).source! + : '', message: ret as string } ;(payloads as AdditionalPayloads).meta = assign( @@ -853,7 +853,7 @@ function resolveMessageFormat( } // for vue-devtools timeline event - if (!__BRIDGE__ && __DEV__ && locale !== targetLocale) { + if (__DEV__ && locale !== targetLocale) { const emitter = (context as unknown as CoreInternalContext).__v_emitter if (emitter) { emitter.emit(VueDevToolsTimelineEvents.FALBACK, { @@ -886,7 +886,7 @@ function resolveMessageFormat( } // for vue-devtools timeline event - if (!__BRIDGE__ && __DEV__ && inBrowser) { + if (__DEV__ && inBrowser) { const end = window.performance.now() const emitter = (context as unknown as CoreInternalContext).__v_emitter if (emitter && start && format) { @@ -974,7 +974,7 @@ function compileMessageFormat( ) as MessageFunctionInternal // for vue-devtools timeline event - if (!__BRIDGE__ && __DEV__ && inBrowser) { + if (__DEV__ && inBrowser) { const end = window.performance.now() const emitter = (context as unknown as CoreInternalContext).__v_emitter if (emitter && start) { @@ -1017,7 +1017,7 @@ function evaluateMessage( const messaged = msg(msgCtx) // for vue-devtools timeline event - if (!__BRIDGE__ && __DEV__ && inBrowser) { + if (__DEV__ && inBrowser) { const end = window.performance.now() const emitter = (context as unknown as CoreInternalContext).__v_emitter if (emitter && start) { @@ -1095,7 +1095,7 @@ function getCompileContext( warnHtmlMessage, onError: (err: CompileError): void => { onError && onError(err) - if (!__BRIDGE__ && __DEV__) { + if (__DEV__) { const _source = getSourceForCodeFrame(source) const message = `Message compilation error: ${err.message}` const codeFrame = diff --git a/packages/global.d.ts b/packages/global.d.ts index 3c474c2a8..d68cdb4eb 100644 --- a/packages/global.d.ts +++ b/packages/global.d.ts @@ -8,7 +8,6 @@ declare let __ESM_BUNDLER__: boolean declare let __ESM_BROWSER__: boolean declare let __NODE_JS__: boolean declare let __LITE__: boolean -declare let __BRIDGE__: boolean declare let __VERSION__: string declare let __BUNDLE_FILENAME__: string declare let __COMMIT__: string diff --git a/packages/petite-vue-i18n/src/index.ts b/packages/petite-vue-i18n/src/index.ts index ca0bfecee..2d66a1786 100644 --- a/packages/petite-vue-i18n/src/index.ts +++ b/packages/petite-vue-i18n/src/index.ts @@ -94,7 +94,6 @@ export { export { createI18n, useI18n, - castToVueI18n, I18nOptions, I18nAdditionalOptions, I18n, diff --git a/packages/petite-vue-i18n/src/runtime.ts b/packages/petite-vue-i18n/src/runtime.ts index 6f2c213f0..bb14a391b 100644 --- a/packages/petite-vue-i18n/src/runtime.ts +++ b/packages/petite-vue-i18n/src/runtime.ts @@ -86,7 +86,6 @@ export { export { createI18n, useI18n, - castToVueI18n, I18nOptions, I18nAdditionalOptions, I18n, diff --git a/packages/vue-i18n-bridge/LICENSE b/packages/vue-i18n-bridge/LICENSE deleted file mode 100644 index d50c49b4d..000000000 --- a/packages/vue-i18n-bridge/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2021 kazuya kawaguchi - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packages/vue-i18n-bridge/README.md b/packages/vue-i18n-bridge/README.md deleted file mode 100644 index deee4114e..000000000 --- a/packages/vue-i18n-bridge/README.md +++ /dev/null @@ -1,228 +0,0 @@ -# 🌉 vue-i18n-bridge - -A bridge for Vue I18n Legacy - -## ❓ What is `vue-i18n-bridge`? - -`vue-i18n-bridge` is a bridge to make the upgrade as easy as possible between vue-i18n@v8.26.1 or later and vue-i18n@v9.x. - -It can be used in Vue 2 applications that you have already built with vue-i18n@v8.26.1 or later. - -And, also some features are backported from vue-i18n@v9.x: - -- Vue I18n Compostion API, that is powered by `@vue/composition-api` -- Message format syntax, that is powered by `@intlify/message-compiler` - -## 💿 Installation - -### Package manager - -```sh -# npm -npm install vue-i18n-bridge -# yarn -yarn add vue-i18n-bridge -# pnpm -pnpm add vue-i18n-bridge -``` - -You must install the below packages before using this library: - -- vue-i18n: >= v8.26.1 < v9 -- @vue/composition-api: >= v1.2.0 - -### CDN - -Include `vue-i18n-bridge` after `vue`, `@vue/composition-api` and it will install. - -```html - - - - -``` - -## 🚀 Usage - -### Composition API - -```js -import Vue from 'vue' -import VueI18n from 'vue-i18n' -import VueCompositionAPI, { createApp } from '@vue/composition-api' -import { createI18n, useI18n } from 'vue-i18n-bridge' - -Vue.use(VueCompositionAPI) -Vue.use(VueI18n, { bridge: true }) // you must specify '{ bridge: true }' plugin option when install vue-i18n - -// `createI18n` options is almost same vue-i18n-next (vue-i18n@v9.x) API -const i18n = createI18n({ - legacy: false, - locale: 'ja', - messages: { - en: { - message: { - hello: 'hello, {name}!' - } - }, - ja: { - message: { - hello: 'こんにちは、{name}!' - } - } - } -}, VueI18n) // `createI18n` which is provide `vue-i18n-bridge` has second argument, you **must** pass `VueI18n` constructor which is provide `vue-i18n` - -const app = createApp({ - setup() { - // `useI18n` options is almost same vue-i18n-next (vue-i18n@v9.x) API - const { t, locale } = useI18n() - // ... todo something - - return { t, locale } - } -}) - -app.use(i18n) // you must install `i18n` instance which is created by `createI18n` -app.mount('#app') -``` - -### Legacy API - -```js -import Vue from 'vue' -import VueI18n from 'vue-i18n' -import VueCompositionAPI from '@vue/composition-api' -import { createI18n, useI18n } from 'vue-i18n-bridge' - -Vue.use(VueCompositionAPI) -Vue.use(VueI18n, { bridge: true }) // you must specify '{ bridge: true }' plugin option when install vue-i18n - -// `createI18n` options is almost same vue-i18n-next (vue-i18n@v9.x) API -const i18n = createI18n({ - locale: 'ja', - messages: { - en: { - message: { - hello: 'hello, {name}!' - } - }, - ja: { - message: { - hello: 'こんにちは、{name}!' - } - } - } -}, VueI18n) // `createI18n` which is provide `vue-i18n-bridge` has second argument, you **must** pass `VueI18n` constructor which is provide `vue-i18n` - -Vue.use(i18n) // you must install `i18n` instance which is created by `createI18n` - -const app = new Vue({ i18n }) -app.$mount('#app') -``` - -For TypeScript: -```ts -import Vue from 'vue' -import VueI18n from 'vue-i18n' -import VueCompositionAPI from '@vue/composition-api' -import { createI18n, useI18n, castToVueI18n } from 'vue-i18n-bridge' - -Vue.use(VueCompositionAPI) -Vue.use(VueI18n, { bridge: true }) - -const i18n = castToVueI18n( - createI18n( - { - locale: 'ja', - messages: { - en: { - message: { - hello: 'hello, {name}!', - }, - }, - ja: { - message: { - hello: 'こんにちは、{name}!', - }, - }, - }, - }, - VueI18n - ) -) - -Vue.use(i18n) - -const app = new Vue({ i18n }) // you need to cast `i18n` instance -app.$mount('#app') -``` - -### Usage UMD module in browser - -```js -const { createApp } = VueCompositionAPI // exported UMD which is named by `VueCompositionAPI -const { createI18n, useI18n } = VueI18nBridge // exported UMD which is named by `VueI18nBridge` - -Vue.use(VueCompositionAPI) -Vue.use(VueI18n, { bridge: true }) -``` - -## ⚠️ Limitations -- In Legacy API mode, You **cannot use [new message format syntax](https://vue-i18n.intlify.dev/guide/essentials/syntax.html)** by porting from `vue-i18n-next` - - it use possible only Composition API mode -- In Composition API mode, If you can use the following components, these can be referenced i18n resources, **only globally** - - i18n functional component `` - - i18n-n functional component `` - -## Explanation of Different Builds -In the [dist/ directory of the npm package](https://unpkg.com/browse/vue-i18n-bridge@9.2.0-beta.6/dist/) you will find many different builds of `vue-i18n-bridge`. Here is an overview of which dist file should be used depending on the use-case. - -### From CDN or without a Bundler - -- **`vue-i18n-bridge(.runtime).global(.prod).js`**: - - For direct use via `