Skip to content

Commit

Permalink
fix: modifiers with pascalCase wouldn't translate (#1512)
Browse files Browse the repository at this point in the history
Co-authored-by: Mikhail Ermakov <m.ermakov@youps.io>
  • Loading branch information
nofacez and Mikhail Ermakov committed Jun 20, 2022
1 parent 22f73b3 commit eebc076
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import I18nPath from './path'
import type { PathValue } from './path'

const htmlTagMatcher = /<\/?[\w\s="/.':;#-\/]+>/
const linkKeyMatcher = /(?:@(?:\.[a-z]+)?:(?:[\w\-_|./]+|\([\w\-_:|./]+\)))/g
const linkKeyPrefixMatcher = /^@(?:\.([a-z]+))?:/
const linkKeyMatcher = /(?:@(?:\.[a-zA-Z]+)?:(?:[\w\-_|./]+|\([\w\-_:|./]+\)))/g
const linkKeyPrefixMatcher = /^@(?:\.([a-zA-Z]+))?:/
const bracketsMatcher = /[()]/g
const defaultModifiers = {
'upper': str => str.toLocaleUpperCase(),
Expand Down
20 changes: 20 additions & 0 deletions test/unit/issues.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,4 +820,24 @@ describe('issues', () => {
assert.strictEqual(vm.$i18n.t('message.linkPipe'), messages.en['pipe|hello'])
})
})

describe('#1308', () => {
it('should be translated', () => {
const i18n = new VueI18n({
locale: 'en',
messages: {
en: {
'address': 'home Address',
'snakeAddress': '@.snakeCase:(address)'
}
},
name: 'test',
modifiers: {
snakeCase: str => str.split(' ').join('-')
},
})

assert.strictEqual(i18n.t('snakeAddress'), 'home-Address')
})
})
})

0 comments on commit eebc076

Please sign in to comment.