Skip to content

Commit

Permalink
fix: allow $ta method to work without text (#170)
Browse files Browse the repository at this point in the history
* docs: fix loader readme

* docs: update README

* fix: allow $ta method to work without text
  • Loading branch information
Demivan authored Oct 17, 2020
1 parent 2df30a5 commit 5597392
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![GitHub license](https://img.shields.io/github/license/demivan/fluent-vue)](https://github.com/Demivan/fluent-vue/blob/develop/LICENSE)

`fluent-vue` is Vue.js integration for [Project Fluent](https://projectfluent.org).
`fluent-vue` is [Vue.js](https://vuejs.org) integration for [Fluent.js](https://github.com/projectfluent/fluent.js) - JavaScript implementation of [Project Fluent](https://projectfluent.org)
`fluent-vue` is compatible both with Vue 2 and Vue 3

## Packages
Expand Down
1 change: 0 additions & 1 deletion packages/fluent-vue-loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ module.exports = {
resourceQuery: /blockType=i18n/,
loader: 'fluent-vue-loader',
},
},
// ...
]
}
Expand Down
20 changes: 20 additions & 0 deletions packages/fluent-vue/__tests__/vue/customComponents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ describe('method', () => {
expect(mounted.html()).toEqual(`<div attr="Attr value">Inner data</div>`)
})

it('works without message text', () => {
// Arrange
bundle.addResource(
new FluentResource(ftl`
key =
.attr = Attr value
`)
)

const component = {
template: `<div v-bind="$ta('key')"></div>`,
}

// Act
const mounted = mount(component, options)

// Assert
expect(mounted.html()).toEqual(`<div attr="Attr value"></div>`)
})

it('warns about missing translation', () => {
// Arange
bundle.addResource(
Expand Down
2 changes: 1 addition & 1 deletion packages/fluent-vue/src/TranslationContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class TranslationContext {
const context = this.getBundle(key)
const message = this.getMessage(context, key)

if (context === null || message === null || message.value === null) {
if (context === null || message === null) {
return {}
}

Expand Down

0 comments on commit 5597392

Please sign in to comment.