Zum Inhalt

lang_util

Quelle: base/tealdef/scripts/lang_util.d.tl

Hinweise

Typen von /scripts/lang_util.tl (LangUtil): formatiert übersetzte Texte und Zahlen für die GUI. Es baut auf StringUtil.format und den Funktionen api.util.lang der Engine auf. Du lädst es mit local lang_util = ug_require "/scripts/lang_util.tl" as LangUtil.

Beispiel

-- from base/content/game_mechanics/game_mechanics/notifications/types/animaldespawn.script.tl
description = lang_util.format(_("{animalName} became a victim of technological advance. It is now on its way to heaven."), { animalName = animalName }),

LangUtil

record global base/tealdef/scripts/lang_util.d.tl:3

global record LangUtil

Laden: local lang_util = ug_require "::/scripts/lang_util.tl" as LangUtil

Hinweise

Helfer zum Formatieren von Texten für die GUI, die ug_require "/scripts/lang_util.tl" zurückgibt.

Funktionen

format(string, {string : string}) : string base/tealdef/scripts/lang_util.d.tl:4

Aufruf: lang_util.format(…)

Hinweise

Dasselbe wie StringUtil.format. Füllt {name}-Platzhalter, meist in einem übersetzten Text _("...").

Rückgabe string

Beispiel

return lang_util.format(_("There is no electrified path for {vehicle}."), { vehicle = names[1] })
Im Basisspiel verwendet: 432-mal in 114 Dateien

base/content/base/base/difficulty_util.tl:239

log.warning(lang_util.format("Did not find {modParam}, hence no difficulty scale can be provided.", { modParam = modParam }))
base/content/game_mechanics/game_mechanics/achievements/achievements.script.tl:85
log.message(lang_util.format("Updating legacy achievement state from version: {fromVersion} to version: {toVersion}", {
base/content/game_mechanics/game_mechanics/celebrations/celebration_react_util.tl:30
return lang_util.format(_("Congratulations, you have just started the delivery of products requested by {townName}!"), {
base/content/game_mechanics/game_mechanics/company/company.script.tl:398
log.message(lang_util.format("Initializing basePopulation with {basePopulation}.", {
base/content/game_mechanics/game_mechanics/company/company.tl:235
text = lang_util.format(
base/content/game_mechanics/game_mechanics/company/company_legacy_util.tl:15
log.message(lang_util.format("Updating legacy company state from version: {fromVersion} to version: {toVersion}", {
… und 108 weitere Dateien.

formatInt(integer) : string base/tealdef/scripts/lang_util.d.tl:5

Aufruf: lang_util.formatInt(…)

Hinweise

Formatiert eine Ganzzahl für die Anzeige mit api.util.lang.formatInt der Engine.

Rückgabe string

Im Basisspiel verwendet: 241-mal in 60 Dateien

base/content/game_mechanics/game_mechanics/company/company.script.tl:603

errorMessages[lang_util.format(nGetText("{numPermits} Permit Used Up", "All {numPermits} Permits Used Up", maxPermits), {numPermits = lang_util.formatInt(maxPer
base/content/game_mechanics/game_mechanics/company/company.tl:237
{ population = lang_util.formatInt(currentRank.requiredExp) }
base/content/game_mechanics/game_mechanics/company/company_static_util.tl:31
return lang_util.format(_("Rank {rank}"), {rank = lang_util.formatInt(companyLevel)})
base/content/game_mechanics/game_mechanics/finance/finances_assets.tl:33
label = lang_util.formatInt(numberTotal),
base/content/game_mechanics/game_mechanics/finance/finances_cargo_lifetime.tl:70
text = labelInMilliSeconds == 0 and lang_util.formatInt(0) or util.formatDurationWithCurrentCalenderSpeed(labelInMilliSeconds, millisPerDayState:old(), "Month")
base/content/game_mechanics/game_mechanics/finance/finances_charts.tl:175
postfix = lang_util.format(nGetText("{count} Year", "{count} Years", sliderChartState:old().numYears), { count = lang_util.formatInt(sliderChartState:old().numY
… und 54 weitere Dateien.

formatPlainInt(integer) : string base/tealdef/scripts/lang_util.d.tl:6

Aufruf: lang_util.formatPlainInt(…)

Hinweise

Wandelt eine Ganzzahl mit tostring in einen String um, ohne Formatierung nach Gebietsschema.

Rückgabe string

Im Basisspiel verwendet: 25-mal in 14 Dateien

base/content/game_mechanics/game_mechanics/achievements/achievements.script.tl:86

fromVersion = lang_util.formatPlainInt(stateVersion),
base/content/game_mechanics/game_mechanics/company/company.script.tl:399
basePopulation = lang_util.formatPlainInt(companiesState.basePopulation)
base/content/game_mechanics/game_mechanics/company/company_legacy_util.tl:16
fromVersion = lang_util.formatPlainInt(version),
base/content/game_mechanics/game_mechanics/emission/emission_legacy_util.tl:15
fromVersion = lang_util.formatPlainInt(version),
base/content/game_mechanics/game_mechanics/industries/industries.script.tl:57
fromVersion = lang_util.formatPlainInt(version),
base/content/game_mechanics/game_mechanics/towns/town_growth.script.tl:323
local logName = "experience_raw_" .. lang_util.formatPlainInt(tier) .. "_" .. source
… und 8 weitere Dateien.

formatNumber(value : number, decimals : integer) : string base/tealdef/scripts/lang_util.d.tl:7

Aufruf: lang_util.formatNumber(…)

Hinweise

Formatiert eine Zahl mit der angegebenen Anzahl Nachkommastellen über api.util.lang.formatNumber der Engine.

Parameter Typ Beschreibung
value number Die Zahl.
decimals integer Anzahl der Nachkommastellen.

Rückgabe string

Im Basisspiel verwendet: 28-mal in 10 Dateien

base/content/gui/gui/construction/construction_desc_react_util.tl:58

return lang_util.formatNumber(minMax.min, minMax.min < 1 and 1 or 0)
base/content/gui/gui/construction/construction_react_util.tl:156
return lang_util.formatNumber(value, 1)
base/content/gui/gui/debug_panel/make_entity_debug_panel.tl:438
local tooltip = lang_util.format("{label}: {value}", { label = v.name, value = lang_util.formatNumber(v.getRating(entityId, townState), 2) })
base/content/gui/gui/entity_window/double_slip_switch.tl:378
text = lang_util.formatNumber(state.duration, 1) .. " s",
base/content/gui/gui/entity_window/entity_window_util.tl:1051
return lang_util.formatNumber(val, 0)
base/content/gui/gui/entity_window/town_building/town_building.tl:181
barTooltip = lang_util.format(_("Noise at Building Position: {noise}"), {noise = lang_util.formatNumber(state:old(), 1)}),
… und 4 weitere Dateien.

stringContains(string, string) : boolean base/tealdef/scripts/lang_util.d.tl:9

Aufruf: lang_util.stringContains(…)

Hinweise

Textsuche der GUI (api.util.lang.stringContains). True, wenn der erste String den zweiten enthält.

Rückgabe boolean

Im Basisspiel verwendet: 30-mal in 12 Dateien

base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:1666

if searchString == "" or lang_util.stringContains(lineName, searchString) then
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_util.tl:746
if not lang_util.stringContains(elemStatic.name, filter.text) then
base/content/gui/gui/menu/mod_selector_page.tl:1963
return lang_util.stringContains(modInfo.title, modSelectorProvider:get():getDisplayData().searchString)
base/content/gui/gui/menu/savegame_react_util.tl:129
if not filter or lang_util.stringContains(savegame.saveName, filter) then
base/content/gui/gui/menu/settings_page.tl:1698
if not lang_util.stringContains(desc.uiName, keyBindingsFilterState:old()) then
base/content/gui/gui/statistics/statistic_depots.tl:250
if lang_util.stringContains(depotName, params.searchString) then
… und 6 weitere Dateien.

compareStrings(string, string) : integer base/tealdef/scripts/lang_util.d.tl:10

Aufruf: lang_util.compareStrings(…)

Hinweise

Vergleicht zwei Strings zum Sortieren (api.util.lang.compareStrings). Negativ, wenn der erste vor dem zweiten einsortiert wird.

Rückgabe integer

Beispiel

-- from base/content/game_mechanics/game_mechanics/notifications/gui/notification_log.tl
table.sort(list, function(a, b) return lang_util.compareStrings(a, b) < 0 end)
Im Basisspiel verwendet: 10-mal in 8 Dateien

base/content/game_mechanics/game_mechanics/notifications/gui/notification_log.tl:209

return lang_util.compareStrings(a, b) < 0
base/content/gui/gui/construction/construction_react_util.tl:2787
return lang_util.compareStrings(a.name, b.name) < 0
base/content/gui/gui/entity_window/line/line_eow.script.tl:207
return lang_util.compareStrings(a[1], b[1]) < 0
base/content/gui/gui/entity_window/maintenance_station/maintenance_station_eow.script.tl:200
return lang_util.compareStrings(aName, bName) < 0
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:4540
return lang_util.compareStrings(a.lineName, b.lineName) < 0
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_window.tl:1806
local cmp = lang_util.compareStrings(a.dynamic.sortKey as string, b.dynamic.sortKey as string)
… und 2 weitere Dateien.

formatPercentageBoost(value : number) : string base/tealdef/scripts/lang_util.d.tl:12

Aufruf: lang_util.formatPercentageBoost(…)

Hinweise

Formatiert einen Anteil mit api.util.toStringPercent als Prozentwert mit Vorzeichen (+12%, -5%). Null bekommt kein Vorzeichen.

Parameter Typ Beschreibung
value number Der Anteil (zum Beispiel 0.12 für +12 %).

Rückgabe string

Im Basisspiel verwendet: 7-mal in 2 Dateien

base/content/gui/gui/construction/construction_desc_react_util.tl:121

text = lang_util.format(_("Comfort: {percent}"), { percent = lang_util.formatPercentageBoost(range.min) }),
base/content/gui/gui/main/cargo_react_util.tl:54
return lang_util.format(_("Specialized Warehouse: {boost}"), { boost = lang_util.formatPercentageBoost(warehouseBoost) })