Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion e2e/fallback/component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

test('initial rendering', async () => {
await expect(page).toMatch('こんにちは、世界')
await expect(page).toMatch('Component1 locale messages: hello component1')
await expect(page).toMatch(
'Component1 locale messages: こんにちは、component1'
)
await expect(page).toMatch(
'Fallback global locale messages: おはよう、世界!'
)
Expand Down
2 changes: 1 addition & 1 deletion e2e/scope/local.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
text: 'こんにちは、世界!'
})
await expect(page).toMatchElement('#app div.child p', {
text: 'Hi there!'
text: 'やあ!'
})
})

Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"jest-watch-typeahead": "^0.6.0",
"lerna-changelog": "^1.0.1",
"minimist": "^1.2.5",
"npm-run-all": "^4.1.5",
"opener": "^1.5.1",
"prettier": "^2.0.0",
"puppeteer": "^2.1.1",
Expand Down Expand Up @@ -98,24 +99,26 @@
"build:sourcemap": "yarn build --sourcemap",
"build:type": "yarn build --types",
"build:watch": "tsc -p . --watch",
"clean": "yarn clean:type && yarn clean:dist && yarn clean:docs && yarn clean:cache && yarn clean:coverage",
"clean:cache": "rm -rf ./node_modules/.rts2_cache",
"clean": "npm-run-all --parallel clean:*",
"clean:cache": "yarn clean:cache:rollup && yarn clean:cache:jest",
"clean:cache:rollup": "rm -rf ./node_modules/.rts2_cache",
"clean:cache:jest": "jest --clearCache",
"clean:coverage": "rm -rf ./coverage",
"clean:dist": "rm -rf ./dist/**",
"clean:docs": "rm -rf ./docs",
"clean:type": "rm -rf ./types/** ./temp ./dist/vue-i18n.d.ts",
"coverage": "opener coverage/lcov-report/index.html",
"dev:docs": "yarn build:type && yarn docs:api",
"dev:docs": "npm-run-all build:type docs:api",
"dev:e2e": "jest --runInBand --config ./jest.e2e.config.js",
"docs:api": "api-documenter markdown -i ./temp -o docs",
"fix": "yarn lint:fix && yarn format:fix",
"fix": "npm-run-all --parallel lint:fix format:fix",
"format": "prettier --config .prettierrc --ignore-path .prettierignore '**/*.{js,json,html}'",
"format:fix": "yarn format --write",
"lint": "eslint ./src ./test ./e2e ./benchmark --ext .js,.ts",
"lint:fix": "yarn lint --fix",
"release:prepare": "shipjs prepare",
"release:trigger": "shipjs trigger",
"test": "yarn lint && yarn test:cover && yarn test:e2e",
"test": "npm-run-all lint clean:cache:jest test:cover test:e2e",
"test:cover": "yarn test:unit --coverage",
"test:e2e": "yarn build && jest --runInBand --config ./jest.e2e.config.js",
"test:type": "tsc -p . --noEmit",
Expand Down
4 changes: 3 additions & 1 deletion src/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ export function createComposer(
const { __root } = options
const _isGlobal = __root === undefined

let _inheritLocale = !!options.inheritLocale
let _inheritLocale = isBoolean(options.inheritLocale)
? options.inheritLocale
: true

const _locale = ref<Locale>(
// prettier-ignore
Expand Down
2 changes: 1 addition & 1 deletion src/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function convertComposerOptions(
const warnHtmlMessage = isString(options.warnHtmlInMessage)
? options.warnHtmlInMessage !== 'off'
: true
const inheritLocale = !!options.sync
const inheritLocale = isBoolean(options.sync) ? options.sync : true

if (__DEV__ && options.formatter) {
warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_FORMATTER))
Expand Down
10 changes: 5 additions & 5 deletions test/composer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ describe('inheritLocale', () => {
locale: 'ja',
__root: root
})
expect(inheritLocale).toEqual(false)
expect(locale.value).toEqual('ja')
expect(inheritLocale).toEqual(true)
expect(locale.value).toEqual('en')
})

test('initialize with composer option', () => {
const root = createComposer({ locale: 'en' })
const { inheritLocale, locale } = createComposer({
locale: 'ja',
inheritLocale: true,
inheritLocale: false,
__root: root
})
expect(inheritLocale).toEqual(true)
expect(locale.value).toEqual('en')
expect(inheritLocale).toEqual(false)
expect(locale.value).toEqual('ja')
})

test('sync root locale, fallbackLocale', async () => {
Expand Down
2 changes: 2 additions & 0 deletions test/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('useI18n', () => {
template: `<p>foo</p>`,
setup() {
composer = useI18n({
inheritLocale: false,
locale: 'en',
messages: {
en: {
Expand Down Expand Up @@ -115,6 +116,7 @@ describe('useI18n', () => {
template: `<div>parent</div><Leaf />`,
setup() {
parent = useI18n({
inheritLocale: false,
locale: 'en',
messages: {
en: {
Expand Down
3 changes: 2 additions & 1 deletion test/mixin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('beforeCreate', () => {
template: `<p>{{ $t('bye') }}</p>`,
i18n: {
locale: 'ja',
sync: false,
messages: {
ja: {
bye: 'さようなら'
Expand All @@ -47,7 +48,7 @@ describe('beforeCreate', () => {
})

const messages = {
'en-US': {
en: {
bye: 'good bye!'
}
}
Expand Down
Loading