Skip to content

Commit 43ebd52

Browse files
committed
Fix actually passing config to the TranslationContext
1 parent 2d12488 commit 43ebd52

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

__tests__/vue/plugin.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,28 @@ describe('vue integration', () => {
101101
'<div>Hello, \u{2068}John\u{2069}!<div>Hello from child component, \u{2068}Alice\u{2069}</div>\n</div>',
102102
)
103103
})
104+
105+
it('allows specifying custom variable mapping function', () => {
106+
// Arrange
107+
const fluent = createFluentVue({
108+
bundles: [bundle],
109+
mapVariable: (variable) => {
110+
if (typeof variable === 'string')
111+
return variable.toUpperCase()
112+
},
113+
})
114+
115+
const component = {
116+
data: () => ({
117+
name: 'John',
118+
}),
119+
template: '<div>{{ $t("message", { name }) }}</div>',
120+
}
121+
122+
// Act
123+
const mounted = mountWithFluent(fluent, component)
124+
125+
// Assert
126+
expect(mounted.html()).toEqual('<div>Hello, \u{2068}JOHN\u{2069}!</div>')
127+
})
104128
})

src/util/options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function resolveOptions(options: FluentVueOptions): ResolvedOptions {
2929
return {
3030
warnMissing: getWarnMissing(options),
3131
parseMarkup: options.parseMarkup ?? defaultMarkupParser,
32+
mapVariable: options.mapVariable,
3233
globalFormatName: options.globals?.functions?.format ?? '$t',
3334
globalFormatAttrsName: options.globals?.functions?.formatAttrs ?? '$ta',
3435
directiveName: options.globals?.directive ?? 't',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy