Guide
Inflection & Transliteration
Wordsmith provides multi-language methods for dealing with noun inflection.
Inflection is available for these locales:
en
(English) (default)es
(Spanish)fr
(French)nb
(Norwegian Bokmal)pt
(Portuguese)tr
(Turkish)
Wordsmith’s inflection and transliteration methods include:
Singulars/Plurals
pluralize
When used without an explicit quantity, pluralize
returns the plural form of the given word.
When used with a quantity, pluralize
returns the correct singular or plural form of the given word, for the provided quantity and language.
quantity
(2
) — The quantity of objectslocale
(en
) — The language to use for inflection
{{ 'plugin' | pluralize }} |
3 {{ 'plugin' | pluralize( qty=3 ) }} |
{{ pluralize('child', qty=1) }} |
{{ pluralize('child', qty=100) }} |
{{ pluralize('el', locale='es') }} {{ pluralize('hijo', locale='es') }} |
singularize
Returns the singular form of the given word.
{{ 'matrices' | singularize }} |
{{ singularize('mamás', locale='es') }} |
Ordinals
ordinal
Returns the ordinal suffix that corresponds to the given number.
(Uses English ordinalization rules).
{{ 1 | ordinal }} |
{{ 2 | ordinal }} |
{{ 3 | ordinal }} |
{{ 4 | ordinal }} |
ordinalize
Returns the ordinalized variant of the given number.
(Uses English ordinalization rules).
{{ 1 | ordinalize }} |
{{ 42 | ordinalize }} |
{{ 103 | ordinalize }} |
{{ 4 | ordinalize }} |
Transliteration
transliterate
// TODO
Case Modification
Wordsmith also provides several methods for case modification, including:
camelize
dasherize
humanize
hyphenate
pascalize
slugify
titleize
underscore
underscored
upperCamelize
Caught a mistake or want to contribute to the documentation?
Submit a PR via Github
or
email Support.