This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy under /_llms/. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

Skip to main content Skip to navigation

LocalizationOptions Pennington.Localization

Options for localization.

Properties

DefaultLocale string
Locale code used when no URL locale prefix is present.
IsMultiLocale bool
True when more than one locale is configured.
Locales IReadOnlyDictionary<string, LocaleInfo>
Configured locales keyed by locale code.

Methods

AddLocale

#
public void AddLocale(string code, LocaleInfo info)

Registers a locale with the supplied metadata.

Parameters

code string
info LocaleInfo

AddLocale

#
public void AddLocale(string code, string displayName)

Registers a locale with just a display name.

Parameters

code string
displayName string

BuildLocaleUrl

#
public string BuildLocaleUrl(string contentPath, string locale)

Builds a full URL for a content path in a specific locale.

Parameters

contentPath string
locale string

Returns

string

GetAlternateLanguages

#
public IReadOnlyList<AlternateLanguage> GetAlternateLanguages(string url)

Gets alternate language versions for a page URL across all configured locales. Pure URL math — does not check if content exists (fallback handles that).

Parameters

url string

Returns

IReadOnlyList<AlternateLanguage>

GetLocaleFromUrl

#
public string GetLocaleFromUrl(string url)

Extracts the locale code from a URL path. Returns the default locale when the first segment is not a known non-default locale.

Parameters

url string

Returns

string

StripLocalePrefix

#
public string StripLocalePrefix(string url, string locale)

Strips the locale prefix from a URL, returning the content-relative path. For the default locale (no prefix), returns the URL unchanged.

Parameters

url string
locale string

Returns

string

Pennington.Localization.LocalizationOptions

namespace Pennington.Localization;

/// Options for localization.
public class LocalizationOptions
{
    /// Registers a locale with the supplied metadata.
    
public void AddLocale(string code, LocaleInfo info)
; /// Registers a locale with just a display name.
public void AddLocale(string code, string displayName)
; /// Builds a full URL for a content path in a specific locale.
public string BuildLocaleUrl(string contentPath, string locale)
; /// Locale code used when no URL locale prefix is present.
public string DefaultLocale { get; set; }
/// Gets alternate language versions for a page URL across all configured locales. Pure URL math — does not check if content exists (fallback handles that).
public IReadOnlyList<AlternateLanguage> GetAlternateLanguages(string url)
; /// Extracts the locale code from a URL path. Returns the default locale when the first segment is not a known non-default locale.
public string GetLocaleFromUrl(string url)
; /// True when more than one locale is configured.
public bool IsMultiLocale { get; }
/// Configured locales keyed by locale code.
public IReadOnlyDictionary<string, LocaleInfo> Locales { get; }
/// Strips the locale prefix from a URL, returning the content-relative path. For the default locale (no prefix), returns the URL unchanged.
public string StripLocalePrefix(string url, string locale)
; }