WowAddons

World of Warcraft Forever API · LuaLocaleContextAPI.md, for your AI

LuaLocaleContextAPI (widget methods)

22 functions, as Blizzard documents them for Forever 1.60.1 (70959).

Making an addon with an AI? Tell it: Read https://wowaddons.gg/agents.md, then make me a World of Warcraft Forever addon that …, try it with me in the game, and publish it. It checks every call against this API before you try it in the game, then publishes it here. How it works.

Functions

CompareStrings

result = self:CompareStrings(left, right, strength)

Compares two UTF-8 strings using the options specified on a collator.

May return nothing.

Arguments

leftcstringThe first UTF-8 string passed to collation comparison.
rightcstringThe second UTF-8 string passed to collation comparison.
strengthCollationStrengthThe comparison level used by the collator for ordering and equality.

Returns

resultnumberThe comparison result: less than, equal to, or greater than zero.

FindBreaks

byteOffsets = self:FindBreaks(text, breakType)

Opens a break iterator for locating text boundaries in the context locale.

May return nothing.

Arguments

textcstringThe UTF-8 text whose boundary offsets are requested.
breakTypeBreakTypeThe break iterator kind to use for boundary analysis.

Returns

byteOffsetsluaIndex[]The native UTF-8 string indices for the text boundaries (returned with 1-based indexes for lua convenience).

FindStringMatches

byteOffsets = self:FindStringMatches(text, pattern, strength)

Creates a string search iterator using a collator and returns every match position.

May return nothing.

Arguments

textcstringThe UTF-8 text scanned by the string search iterator.
patterncstringThe UTF-8 pattern whose collation-aware matches are returned.
strengthCollationStrengthThe comparison level used by the collator while searching for matches.

Returns

byteOffsetsluaIndex[]The UTF-8 byte offsets of matches in the text (returned with 1-based indexes for lua convenience).

FoldCase

result = self:FoldCase(text)

Case-folds the characters in a string; case-folding is locale-independent and not context-sensitive.

May return nothing.

Arguments

textcstringThe UTF-8 text converted with locale-independent case folding.

Returns

resultstringThe case-folded string, which may be longer or shorter than the original.

FormatCurrency

result = self:FormatCurrency(number, currencyCode)

Formats a double as a localized currency value using the provided ISO 4217 currency code.

May return nothing.

Arguments

numbernumberThe double value formatted by the locale currency formatter.
currencyCodecstringThe 3-letter null-terminated ISO 4217 currency code for currency formatting.

Returns

resultstringThe localized currency text produced by the formatter.

FormatDate

result = self:FormatDate(unixTimeSeconds, style, timeZone)

Formats Unix time as localized date text using locale date patterns, symbols, style, and optional time zone.

May return nothing.

Arguments

unixTimeSecondsnumberThe date as seconds since the Unix epoch; this API converts it to milliseconds.
styleDateTimeStyleThe date format length; None omits the date portion.
timeZonecstringThe time zone ID applied to the formatter; empty strings keep the formatter default.

Returns

resultstringThe formatted date string.

FormatDateTime

result = self:FormatDateTime(unixTimeSeconds, dateStyle, timeStyle, timeZone)

Formats Unix time as localized date and time text using locale patterns, symbols, styles, and optional time zone.

May return nothing.

Arguments

unixTimeSecondsnumberThe date and time as seconds since the Unix epoch; this API converts it to milliseconds.
dateStyleDateTimeStyleThe date format length; None omits the date portion.
timeStyleDateTimeStyleThe time format length; None omits the time portion.
timeZonecstringThe time zone ID applied to the formatter; empty strings keep the formatter default.

Returns

resultstringThe formatted date and time string.

FormatNumber

result = self:FormatNumber(number, style)

Formats a double with locale number formatting using locale symbols, grouping, and the selected non-currency style.

May return nothing.

Arguments

numbernumberThe double value formatted according to the selected number formatter.
styleNumberStyleThe number style to format with; Currency is not accepted here, use FormatCurrency instead.

Returns

resultstringThe localized number text produced by the formatter.

FormatTime

result = self:FormatTime(unixTimeSeconds, style, timeZone)

Formats Unix time as localized time text using locale time patterns, symbols, style, and optional time zone.

May return nothing.

Arguments

unixTimeSecondsnumberThe time as seconds since the Unix epoch; this API converts it to milliseconds.
styleDateTimeStyleThe time format length; None omits the time portion.
timeZonecstringThe time zone ID applied to the formatter; empty strings keep the formatter default.

Returns

resultstringThe formatted time string.

GetCurrencyName

result = self:GetCurrencyName(currencyCode, style)

Returns the display name for a currency in the context locale.

May return nothing.

Arguments

currencyCodecstringThe null-terminated 3-letter ISO 4217 currency code.
styleCurrencyNameStyleThe selector for which kind of currency name to return.

Returns

resultstringThe display string for the currency, or the currency code itself if no localized name is available.

GetDisplayName

result = self:GetDisplayName(displayLocale)

Gets a display name suitable for the specified locale.

May return nothing.

Arguments

displayLocalecstringThe locale whose language conventions are used for the display name

Returns

resultstringThe displayable name for the locale.

GetLocale

result = self:GetLocale()

Gets the locale used by this locale context.

Returns

resultstringThe locale ID of this locale context.

GetSortKey

result = self:GetSortKey(text, strength)

Transforms a string into a collation sort key.

May return nothing.

Arguments

textcstringThe UTF-8 text converted into collation sort-key bytes.
strengthCollationStrengthThe comparison level used by the collator; lower strengths ignore later-level differences.

Returns

resultstringThe sort key bytes excluding the terminating zero byte.

Length

result = self:Length(text)

Counts character break boundaries in UTF-8 text.

May return nothing.

Arguments

textcstringThe UTF-8 text counted by character break iteration.

Returns

resultnumberThe number of character boundaries minus the initial boundary.

ParseCurrency

result = self:ParseCurrency(text)

Parses an entire localized currency string into a double amount and ISO 4217 currency code.

May return nothing.

Arguments

textcstringThe localized currency text to parse for both amount and ISO 4217 code.

Returns

resultCurrencyParseResultThe numeric amount and ISO 4217 currency code parsed from the localized currency text.

ParseNumber

result = self:ParseNumber(text, style)

Parses an entire localized number string into a double using the selected non-currency number formatter.

May return nothing.

Arguments

textcstringThe localized numeric text to parse with the selected style.
styleNumberStyleThe number style to parse with; Currency is not accepted here, use ParseCurrency instead.

Returns

resultnumberThe numeric value parsed from the localized number text.

SelectPlural

result = self:SelectPlural(number, pluralType)

Returns the keyword of the first plural rule that applies to a number.

May return nothing.

Arguments

numbernumberThe number for which the plural rule has to be determined.
pluralTypePluralTypeThe plural rule type, cardinal or ordinal.

Returns

resultstringThe plural keyword for the rule that applies to the number.

SetLocale

success = self:SetLocale(locale)

Sets the locale used by this locale context.

Arguments

localecstringThe locale ID used by subsequent locale context calls.

Returns

successboolTrue if the locale was updated.

ToLower

result = self:ToLower(text)

Lowercases the characters in a string; casing is locale-dependent and context-sensitive.

May return nothing.

Arguments

textcstringThe UTF-8 text whose characters are lowercased.

Returns

resultstringThe lowercased string, which may be longer or shorter than the original.

ToTitle

result = self:ToTitle(text)

Titlecases a string using titlecase positions determined by the default Unicode algorithm.

May return nothing.

Arguments

textcstringThe UTF-8 text whose titlecase positions are mapped.

Returns

resultstringThe titlecased string, which may be longer or shorter than the original.

ToUpper

result = self:ToUpper(text)

Uppercases the characters in a string; casing is locale-dependent and context-sensitive.

May return nothing.

Arguments

textcstringThe UTF-8 text whose characters are uppercased.

Returns

resultstringThe uppercased string, which may be longer or shorter than the original.

TransformLocale

result = self:TransformLocale(transform)

Applies a locale transform to the context locale and returns the transformed locale string.

May return nothing.

Arguments

transformLocaleTransformThe locale transform to apply.

Returns

resultstringThe transformed locale string.

It takes WowAddons

Free, for Windows, macOS and Linux: it puts the addon in your game in one click and keeps it up to date. Open it once, then press Install again.

WowAddons runs on your computer: open wowaddons.gg there.

Download for Windows