NAME

Valiant::Translation - Localized, human readable names for models and attributes

DESCRIPTION

A role providing the translation glue between your model and Valiant::I18N: it turns attribute names into localized, human readable strings for error messages and form labels. You won't usually consume this role directly; it is composed into your class via Valiant::Validates. Documented here is the public API it adds to your class.

ATTRIBUTES

i18n

An instance of the class named by "i18n_class", lazily built. You can pass your own at construction if you need custom translation behavior.

METHODS

i18n_class

The class used for translation. Defaults to Valiant::I18N. Override this method in your class to use a different translation backend.

i18n_scope

The top level namespace under which translation keys are looked up. Defaults to valiant. Override to relocate your translations.

human_attribute_name ($attribute, \%options)

Returns a human readable, localized version of an attribute name, used when building full error messages. Looks for translations under {i18n_scope}.attributes.{model}.{attribute} across the class hierarchy, falling back to any default tags passed in \%options and finally to a title cased version of the attribute name itself (with any trailing _id removed and underscores turned into spaces).

human_label_name ($attribute, \%options)

The same lookup as "human_attribute_name" but under the labels scope rather than attributes; used by the form generation code to build field labels so labels can be localized separately from error messages.

SEE ALSO

Valiant, Valiant::I18N, Valiant::Validates.

AUTHOR

See Valiant

COPYRIGHT & LICENSE

See Valiant