Skip to content

Latest commit

 

History

History
133 lines (98 loc) · 3.71 KB

File metadata and controls

133 lines (98 loc) · 3.71 KB

Umbraco.DictionaryBuilder

An Umbraco-CMS strongly typed dictionary item builder

Nuget

Usage

All dictionary models are properties in the Umbraco.Web.Dictionaries class, with a name matching the dictionary item key.

To write a dictionary item value in a Razor file, just write

Example dictionary value: "Apple"

@Dictionaries.Apple
// Returns: "Apple"

Dictionary values are return in Thread.CurrentUICulture, unless another culture is specified in the Format extension methods.

Format extension methods

In namespace Umbraco.DictionaryBuilder.Extensions

string Format(params object[] args)

Example dictionary value: "{0} apple"

@Dictionaries.Apple.Format("green")
// Returns: "green apple"

Equivalent to @string.Format(Dictionaries.Apple)

string Format(int count, params object[] args)

A pluralization method

Example dictionary value "no apples|one apple|{count} apples"

@Dictionaries.Apple.Format(0)
// Returns: "no apples"
@Dictionaries.Apple.Format(1)
// Returns: "one apple"
@Dictionaries.Apple.Format(2)
// Returns: "2 apples"
@Dictionaries.Apple.Format(33)
// Returns: "33 apples"

Example dictionary value: "no {0} apples | one {0} apple | {count} {0} apples"

@Dictionaries.Apple.Format(0, "red")
// Returns: "no red apples"
@Dictionaries.Apple.Format(1, "red")
// Returns: "one red apple"
@Dictionaries.Apple.Format(2, "red")
// Returns: "2 red apples"
@Dictionaries.Apple.Format(33, "red")
// Returns: "33 red apples"

string Format(CultureInfo culture, params object[] args)

Like string Format(params object[] args), but returns the tranlated value of the requested culture.

string Format(CultureInfo culture, int count, params object[] args)

Like string Format(int count, params object[] args), but returns the tranlated value of the requested culture.

Configuration

AppSettings

Umbraco.DictionaryBuilder.ModelsMode

Valid values: LiveAppData

Default value: LiveAppData

Note: More modes are in the pipeline.

Umbraco.DictionaryBuilder.DictionaryNamespace

The namespace in witch the dictionary models will be generated.

Default value: Umbraco.Web

Umbraco.DictionaryBuilder.DictionaryItemsPartialClassName

The name of the partial class that contains all the generated dictionary models.

Default value: Dictionaries

Umbraco.DictionaryBuilder.DictionaryDirectory

The relative path to the folder where to generate the dictionary models

Default value: ~/App_Data/Dictionaries

Umbraco.DictionaryBuilder.AcceptUnsafeModelsDirectory

An indicator of whether is accepted to generate dictionary models in a folder outside of the current project.

Valid values: True/False

Default value: False

Umbraco.DictionaryBuilder.UseNestedStructure

Todo: Write documentation

Valid values: True/False

Default value: False

Umbraco.DictionaryBuilder.GenerateFilePerDictionaryItem

An indicator of whether the dictionary models should be generated in a single file or a file per dictionary item.

Valid values: True/False

Default value: False

Umbraco.DictionaryBuilder.Enable

An indicator of whether the DictionaryBuilder is enabled.

Valid values: True/False

Default value: False