Skip to content

Commit 5e882ce

Browse files
authored
breaking: drop modulo interpolation syntax (#1814)
1 parent ac5c33e commit 5e882ce

File tree

28 files changed

+548
-1443
lines changed

28 files changed

+548
-1443
lines changed

e2e/formatting/ruby.spec.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

examples/composition/formatting/ruby.html

Lines changed: 0 additions & 57 deletions
This file was deleted.

examples/legacy/formatting/ruby.html

Lines changed: 0 additions & 47 deletions
This file was deleted.

examples/petite/formatting/ruby.html

Lines changed: 0 additions & 52 deletions
This file was deleted.

packages/core-base/src/compilation.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { warn, format, isObject, isBoolean, isString } from '@intlify/shared'
22
import {
33
baseCompile as baseCompileCore,
4-
CompileWarnCodes,
54
defaultOnError,
65
detectHtmlTag
76
} from '@intlify/message-compiler'
@@ -12,8 +11,7 @@ import type {
1211
CompileOptions,
1312
CompileError,
1413
CompilerResult,
15-
ResourceNode,
16-
CompileWarn
14+
ResourceNode
1715
} from '@intlify/message-compiler'
1816
import type { MessageFunction, MessageFunctions } from './runtime'
1917
import type { MessageCompilerContext } from './context'
@@ -29,17 +27,6 @@ function checkHtmlMessage(source: string, warnHtmlMessage?: boolean): void {
2927
const defaultOnCacheKey = (message: string): string => message
3028
let compileCache: unknown = Object.create(null)
3129

32-
function onCompileWarn(_warn: CompileWarn): void {
33-
if (_warn.code === CompileWarnCodes.USE_MODULO_SYNTAX) {
34-
warn(
35-
`The use of named interpolation with modulo syntax is deprecated. ` +
36-
`It will be removed in v10.\n` +
37-
`reference: https://vue-i18n.intlify.dev/guide/essentials/syntax#rails-i18n-format \n` +
38-
`(message compiler warning message: ${_warn.message})`
39-
)
40-
}
41-
}
42-
4330
export function clearCompileCache(): void {
4431
compileCache = Object.create(null)
4532
}
@@ -77,11 +64,6 @@ export const compileToFunction = <
7764
throw createCoreError(CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE)
7865
}
7966

80-
// set onWarn
81-
if (__DEV__) {
82-
context.onWarn = onCompileWarn
83-
}
84-
8567
if (__RUNTIME__) {
8668
__DEV__ &&
8769
warn(
@@ -125,11 +107,6 @@ export function compile<
125107
message: MessageSource,
126108
context: MessageCompilerContext
127109
): MessageFunction<Message> {
128-
// set onWarn
129-
if (__DEV__) {
130-
context.onWarn = onCompileWarn
131-
}
132-
133110
if (
134111
(__ESM_BROWSER__ ||
135112
__NODE_JS__ ||

packages/core-base/src/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export type PostTranslationHandler<Message = string> = (
145145
*/
146146
export type MessageCompilerContext = Pick<
147147
CompileOptions,
148-
'onError' | 'onCacheKey' | 'onWarn'
148+
'onError' | 'onCacheKey'
149149
> & {
150150
/**
151151
* Whether to allow the use locale messages of HTML formatting.

packages/core-base/src/warnings.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import { format, incrementer } from '@intlify/shared'
2-
import { CompileWarnCodes } from '@intlify/message-compiler'
32

4-
const code = CompileWarnCodes.__EXTEND_POINT__
3+
const code = 1
54
const inc = incrementer(code)
65

76
export const CoreWarnCodes = {
8-
NOT_FOUND_KEY: code, // 2
9-
FALLBACK_TO_TRANSLATE: inc(), // 3
10-
CANNOT_FORMAT_NUMBER: inc(), // 4
11-
FALLBACK_TO_NUMBER_FORMAT: inc(), // 5
12-
CANNOT_FORMAT_DATE: inc(), // 6
13-
FALLBACK_TO_DATE_FORMAT: inc(), // 7
14-
EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc(), // 8
15-
__EXTEND_POINT__: inc() // 9
7+
NOT_FOUND_KEY: code, // 1
8+
FALLBACK_TO_TRANSLATE: inc(), // 2
9+
CANNOT_FORMAT_NUMBER: inc(), // 3
10+
FALLBACK_TO_NUMBER_FORMAT: inc(), // 4
11+
CANNOT_FORMAT_DATE: inc(), // 5
12+
FALLBACK_TO_DATE_FORMAT: inc(), // 6
13+
EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc(), // 7
14+
__EXTEND_POINT__: inc() // 8
1615
} as const
1716

1817
export type CoreWarnCodes = (typeof CoreWarnCodes)[keyof typeof CoreWarnCodes]

packages/core-base/test/compilation.test.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,6 @@ describe('compileToFunction', () => {
6060
})
6161
expect(occured).toBe(true)
6262
})
63-
64-
test('modulo syntax warning', () => {
65-
const mockWarn = vi.spyOn(shared, 'warn')
66-
mockWarn.mockImplementation(() => {})
67-
68-
compileToFunction('hello %{name}!', {
69-
...DEFAULT_CONTEXT
70-
})
71-
expect(mockWarn).toHaveBeenCalledTimes(1)
72-
expect(mockWarn.mock.calls[0][0]).includes(
73-
`The use of named interpolation with modulo syntax is deprecated. It will be removed in v10.`
74-
)
75-
})
7663
})
7764

7865
describe('compile', () => {
@@ -132,15 +119,4 @@ describe('compile', () => {
132119
})
133120
expect(occured).toBe(true)
134121
})
135-
136-
test('modulo syntax warning', () => {
137-
const mockWarn = vi.spyOn(shared, 'warn')
138-
mockWarn.mockImplementation(() => {})
139-
140-
compile('%{msg} world!', DEFAULT_CONTEXT)
141-
expect(mockWarn).toHaveBeenCalledTimes(1)
142-
expect(mockWarn.mock.calls[0][0]).includes(
143-
`The use of named interpolation with modulo syntax is deprecated. It will be removed in v10.`
144-
)
145-
})
146122
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CoreWarnCodes } from '../src/warnings'
22

33
test('CoreWarnCodes', () => {
4-
expect(CoreWarnCodes.NOT_FOUND_KEY).toBe(2)
4+
expect(CoreWarnCodes.NOT_FOUND_KEY).toBe(1)
55
})

packages/message-compiler/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export * from './location'
22
export * from './nodes'
33
export * from './options'
4-
export * from './warnings'
54
export * from './errors'
65
export * from './helpers'
76
export * from './parser'

0 commit comments

Comments
 (0)