Skip to content

Commit ef67f94

Browse files
authored
Change to use @intlify/message-resolver for key path splitting. (#160)
1 parent 021c6f8 commit ef67f94

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

lib/rules/no-unused-keys.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type {
2020
Range,
2121
CustomBlockVisitorFactory
2222
} from '../types'
23-
import { joinPath } from '../utils/key-path'
23+
import { joinPath, parsePath } from '../utils/key-path'
2424
const debug = debugBuilder('eslint-plugin-vue-i18n:no-unused-keys')
2525

2626
type UsedKeys = {
@@ -54,7 +54,7 @@ function getUsedKeysMap(
5454
const usedKeysMap: UsedKeys = {}
5555

5656
for (const key of [...usedkeys, ...collectLinkedKeys(values, context)]) {
57-
const paths = key.split('.')
57+
const paths = parsePath(key)
5858
let map = usedKeysMap
5959
while (paths.length) {
6060
const path = paths.shift()!

lib/utils/key-path.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { parse } from '@intlify/message-resolver'
2+
13
/**
24
* @fileoverview Utility for localization keys
35
* @author Yosuke Ota
@@ -17,3 +19,7 @@ export function joinPath(...paths: (string | number)[]): string {
1719
}
1820
return result
1921
}
22+
23+
export function parsePath(path: string): string[] {
24+
return parse(path) || []
25+
}

lib/utils/locale-messages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import { ResourceLoader } from './resource-loader'
1919
import JSON5 from 'json5'
2020
import yaml from 'js-yaml'
21-
import { joinPath } from './key-path'
21+
import { joinPath, parsePath } from './key-path'
2222

2323
/**
2424
* The localization message class
@@ -253,7 +253,7 @@ export class LocaleMessages {
253253
findMissingPath(key: string): string | null {
254254
let missingPath: string[] = []
255255
for (const locale of this.locales) {
256-
const paths = key.split('.')
256+
const paths = parsePath(key)
257257
const length = paths.length
258258
let lasts: I18nLocaleMessageValue[] = this.localeMessages.map(lm =>
259259
lm.getMessagesFromLocale(locale)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
}
2525
},
2626
"dependencies": {
27-
"@intlify/message-compiler": "^9.0.0-beta.16",
27+
"@intlify/message-compiler": "^9.0.0-rc.5",
28+
"@intlify/message-resolver": "^9.0.0-rc.5",
2829
"glob": "^7.1.3",
2930
"ignore": "^5.0.5",
3031
"js-yaml": "^4.0.0",

yarn.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -977,24 +977,24 @@
977977
minimatch "^3.0.4"
978978
strip-json-comments "^3.1.1"
979979

980-
"@intlify/message-compiler@^9.0.0-beta.16":
981-
version "9.0.0-beta.16"
982-
resolved "https://registry.yarnpkg.com/@intlify/message-compiler/-/message-compiler-9.0.0-beta.16.tgz#359993251a303f148b3a325eca055cdbaf0cd95f"
983-
integrity sha512-dE4UZsbVl5TKogYdfrJ6nQKdin1R4XMKVBVa9dE1A8HVvVHBSLy6iQiYpcw8TwcEHIa+rFjuuHuh+IdN3eCw+g==
980+
"@intlify/message-compiler@^9.0.0-rc.5":
981+
version "9.0.0-rc.5"
982+
resolved "https://registry.yarnpkg.com/@intlify/message-compiler/-/message-compiler-9.0.0-rc.5.tgz#823d59dda2a48d32015ac5f4c5cf20fb4b3ed897"
983+
integrity sha512-TnWea88H3pTqYXNNXV7eZk62IVGXzS7dtoTpTdRj4mfJclyU+3neIqkcoeJC7WM8yeT9VWFkIdx882dWpoghPw==
984984
dependencies:
985-
"@intlify/message-resolver" "9.0.0-beta.16"
986-
"@intlify/shared" "9.0.0-beta.16"
985+
"@intlify/message-resolver" "9.0.0-rc.5"
986+
"@intlify/shared" "9.0.0-rc.5"
987987
source-map "0.6.1"
988988

989-
"@intlify/[email protected]beta.16":
990-
version "9.0.0-beta.16"
991-
resolved "https://registry.yarnpkg.com/@intlify/message-resolver/-/message-resolver-9.0.0-beta.16.tgz#f8960344201050d17560f8d01f63e3cd0b9bf59c"
992-
integrity sha512-xwjsFuDDYEv7g1KE5QZRbrPgfsrNsDhYLtNYR7Tn4inzbmB6ipak2UlDzDcQGLieSFbe1WwAoNL0IXy4sUKboQ==
989+
"@intlify/[email protected]rc.5", "@intlify/message-resolver@^9.0.0-rc.5":
990+
version "9.0.0-rc.5"
991+
resolved "https://registry.yarnpkg.com/@intlify/message-resolver/-/message-resolver-9.0.0-rc.5.tgz#144f61a09ff32a9451c37b8e92e806ed3efaf947"
992+
integrity sha512-cZT9kWy6TBB71zb17e5juCTuSNz2/RUf8PeqGYnGP+f/mrPG0X6D3KFqpY3tkWgYwSGcwswd8oBMEvmb0eTMTw==
993993

994-
"@intlify/[email protected]beta.16":
995-
version "9.0.0-beta.16"
996-
resolved "https://registry.yarnpkg.com/@intlify/shared/-/shared-9.0.0-beta.16.tgz#51a80ca4705c93cb14c8f06398dfc550df09d67d"
997-
integrity sha512-A7GSOovcZn/NMoAmDc8FG9uRcFv6iygriK8+C6HFeOnMQ9X+T9f5A9bPtXhCOCiRpQm9SUtGqXedxO5Y8rz9/A==
994+
"@intlify/[email protected]rc.5":
995+
version "9.0.0-rc.5"
996+
resolved "https://registry.yarnpkg.com/@intlify/shared/-/shared-9.0.0-rc.5.tgz#8ed9ea92e73b3856031724dc4a11fcbf7f1f7a7c"
997+
integrity sha512-LGurIHW/TYo07WrbCWXBuZQ3Hg2CHAv5rXLFpxBfHjZawCTrrORQfD4NA+RPVbaWFgzMgw5VJybpJRd9iB1x6g==
998998

999999
"@istanbuljs/load-nyc-config@^1.0.0":
10001000
version "1.0.0"

0 commit comments

Comments
 (0)