Vue Pluralize

0.0.2 · abandoned · verified Sun Apr 19

vue-pluralize is a lightweight utility that integrates the popular `pluralize` library as filters for Vue.js 2 projects. It enables developers to easily convert words between singular and plural forms directly within Vue templates using a custom filter, or programmatically via `this.$pluralize` within components. The package is currently at version `0.0.2` and has not received updates since its initial releases in 2018, indicating an abandoned status. It is specifically designed for Vue 2 and is not compatible with Vue 3, which significantly limits its applicability in modern Vue development. Its primary differentiator was its straightforward integration as a Vue 2 plugin and filter, making pluralization functionality readily available within the Vue 2 ecosystem without manual setup of the underlying `pluralize` library.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install `vue-pluralize` as a Vue 2 plugin and use its `pluralize` filter in templates, along with accessing `$pluralize` directly from the component instance.

<div id="app"></div>

<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script>
<script src="https://unpkg.com/vue-pluralize@0.0.2/dist/vue-pluralize.umd.js"></script>
<script>
  Vue.use(VuePluralize);

  new Vue({
    el: '#app',
    data: {
      itemsCount: 1,
      anotherCount: 5,
    },
    template: `
      <div>
        <h1>Vue Pluralize Demo</h1>
        <p>You have {{ itemsCount }} {{ 'item' | pluralize(itemsCount) }}.</p>
        <p>We found {{ anotherCount }} {{ 'photo' | pluralize(anotherCount) }}.</p>
        <button @click="itemsCount++">Add Item</button>
        <button @click="anotherCount++">Add Photo</button>
        <p>Using $pluralize directly: {{ $pluralize('sheep', 1) }} vs {{ $pluralize('sheep', 2) }}</p>
      </div>
    `
  });
</script>

view raw JSON →