Pluralize common variant unit names

This adds the most popular unit names as singular and plural to our
locale for translation. The added Javascript performs a reverse lookup
to find the right singular/plural form of a unit name in that language.
This commit is contained in:
Maikel Linke
2020-01-23 11:27:01 +11:00
parent f797745848
commit 98b55287f1
3 changed files with 137 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
describe "OptionValueNamer", ->
subject = null
beforeEach ->
module('admin.products')
inject (_OptionValueNamer_) ->
subject = new _OptionValueNamer_
describe "pluralize a variant unit name", ->
it "returns the same word if no plural is known", ->
expect(subject.pluralize("foo", 2)).toEqual "foo"
it "returns the same word if we omit the quantity", ->
expect(subject.pluralize("loaf")).toEqual "loaf"
it "finds the plural of a word", ->
expect(subject.pluralize("loaf", 2)).toEqual "loaves"
it "finds the singular of a word", ->
expect(subject.pluralize("loaves", 1)).toEqual "loaf"
it "finds the zero form of a word", ->
expect(subject.pluralize("loaf", 0)).toEqual "loaves"
it "ignores upper case", ->
expect(subject.pluralize("Loaf", 2)).toEqual "loaves"