Skip to content
Open
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
5 changes: 3 additions & 2 deletions i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ const i18n = function I18n(_OPTS = false) {
let targetLocale = defaultLocale
const argv = parseArgv(arguments)
const namedValues = argv[0]
const args = argv[1]
if (argv[1].length > 0)
logWarn('i18n.__mf must be called with named values only')

// called like __({phrase: "Hello", locale: "en"})
if (typeof phrase === 'object') {
Expand Down Expand Up @@ -345,7 +346,7 @@ const i18n = function I18n(_OPTS = false) {
mf.compiledFunctions[msg] = f
}

return postProcess(f(namedValues), namedValues, args)
return f(namedValues)
}

i18n.__l = function i18nTranslationList(phrase) {
Expand Down
15 changes: 3 additions & 12 deletions test/i18n.mf.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ describe('parsing Messageformat phrases', () => {
mfTest.setLocale('de')
should.equal('Hallo', mfTest.__mf('Hello'))
should.equal('Hallo', mfTest.__mf('Hello'))
should.equal(
'Hallo Marcus, wie geht es dir heute?',
mfTest.__mf('Hello %s, how are you today?', 'Marcus')
)
should.equal('Hello', i18n.__mf({ phrase: 'Hello', locale: 'en' }))
should.equal('Hello', mfTest.__mf({ phrase: 'Hello', locale: 'en' }))
})
Expand All @@ -37,14 +33,9 @@ describe('parsing Messageformat phrases', () => {
)

mfTest.setLocale('de')
should.equal(
'Hallo Marcus',
mfTest.__mf('Hello {name}', { name: 'Marcus' })
)
should.equal(
'Hallo Marcus, wie war dein test?',
mfTest.__mf('Hello {name}, how was your %s?', 'test', { name: 'Marcus' })
)
for (const name of ['Marcus', '[0]|[1]|s', '{{}}', '{{{}}', '%%']) {
should.equal(`Hallo ${name}`, mfTest.__mf('Hello {name}', { name }))
}
})

it('should work with plurals', () => {
Expand Down
Loading