Готовый перевод Sapiens / Сапиенс: localizations.lua 6
local function getTimeSplit(durationSeconds, dayLength, yearLength)
local result = {
years = 0,
days = 0,
hours = 0,
}
if durationSeconds >= yearLength then
result.years = math.floor(durationSeconds / yearLength)
durationSeconds = durationSeconds - result.years * yearLength
end
if durationSeconds >= dayLength then
result.days = math.floor(durationSeconds / dayLength)
durationSeconds = durationSeconds - result.days * dayLength
end
if durationSeconds > 0 then
result.hours = math.floor(durationSeconds / dayLength * 24)
end
return result
end
local function getTimeDurationDescriptionFromSplitTime(timeSplit)
local result = ""
local empty = true
if timeSplit.years > 0 then
local postfix = " год"
if timeSplit.years > 1 then
postfix = " лет"
end
result = mj:tostring(timeSplit.years) .. postfix
empty = false
end
if timeSplit.days > 0 then
local postfix = " день"
if timeSplit.days > 1 then
postfix = " дней"
end
if not empty then
result = result .. ", "
end
result = result .. mj:tostring(timeSplit.days) .. postfix
empty = false
end
if timeSplit.hours > 0 then
local postfix = " час"
if timeSplit.hours > 1 then
postfix = " часов"
end
if not empty then
result = result .. ", "
end
result = result .. mj:tostring(timeSplit.hours) .. postfix
empty = false
else
if empty then
return "< 1 час"
end
end
return result
end
function localizations.getTimeDurationDescription(durationSeconds, dayLength, yearLength)
local timeSplit = getTimeSplit(durationSeconds, dayLength, yearLength)
return getTimeDurationDescriptionFromSplitTime(timeSplit)
end
function localizations.getTimeRangeDescription(durationSecondsMin, durationSecondsMax, dayLength, yearLength)
local minHourCount = math.floor(durationSecondsMin / dayLength * 24)
local maxHourCount = math.floor(durationSecondsMax / dayLength * 24)
if minHourCount == maxHourCount then
return localizations.getTimeDurationDescription(durationSecondsMin, dayLength, yearLength)
end
if minHourCount == 0 then
local maxDescription = localizations.getTimeDurationDescription(durationSecondsMax, dayLength, yearLength)
return "< " .. maxDescription
end
local timeSplitMin = getTimeSplit(durationSecondsMin, dayLength, yearLength)
local timeSplitMax = getTimeSplit(durationSecondsMax, dayLength, yearLength)
if (timeSplitMin.years == 0 and timeSplitMax.years == 0) then
if (timeSplitMin.days == 0 and timeSplitMax.days == 0) then
return mj:tostring(timeSplitMin.hours) .. " - " .. mj:tostring(timeSplitMax.hours) .. " часов"
end
if (timeSplitMin.hours == 0 and timeSplitMax.hours == 0) then
return mj:tostring(timeSplitMin.days) .. " - " .. mj:tostring(timeSplitMax.days) .. " дней"
end
elseif (timeSplitMin.days == 0 and timeSplitMax.days == 0) and (timeSplitMin.hours == 0 and timeSplitMax.hours == 0) then
return mj:tostring(timeSplitMin.years) .. " - " .. mj:tostring(timeSplitMax.years) .. " лет"
end
local minDescription = getTimeDurationDescriptionFromSplitTime(timeSplitMin)
local maxDescription = getTimeDurationDescriptionFromSplitTime(timeSplitMax)
return minDescription .. " - " .. maxDescription
--[[local minHourCount = math.floor(durationSecondsMin / dayLength * 24)
local maxHourCount = math.floor(durationSecondsMax / dayLength * 24)
if minHourCount == maxHourCount then
return localizations.getTimeDurationDescription(durationSecondsMin, dayLength, yearLength)
end
local maxDescription = localizations.getTimeDurationDescription(durationSecondsMax, dayLength, yearLength)
if minHourCount == 0 then
return "< " .. maxDescription
end
local minDescription = localizations.getTimeDurationDescription(durationSecondsMin, dayLength, yearLength)
return minDescription .. " - " .. maxDescription]]
end
function localizations.getBiomeForestDescription(biomeTags)
local typeString = nil
if biomeTags.coniferous then
if biomeTags.birch then
typeString = "сосна и береза"
elseif biomeTags.bamboo then
typeString = "сосна и бамбук"
else
typeString = "сосна"
end
else
typeString = "береза"
end
if not typeString then
return "Нет деревьев."
end
local forestString = true
if biomeTags.mediumForest then
forestString = string.format("%s лес.", mj:capitalize(typeString))
elseif biomeTags.denseForest then
forestString = string.format("Густой %s лес.", typeString)
elseif biomeTags.sparseForest then
forestString = string.format("%s деревья.", mj:capitalize(typeString))
elseif biomeTags.verySparseForest then
forestString = string.format("Очень мало %s деревьев.", typeString)
else
return "Нет деревьев."
end
return forestString
end
function localizations.getBiomeMainDescription(biomeTags)
local descriptionString = nil
if biomeTags.tropical then
descriptionString = "Тропический"
elseif biomeTags.polar or biomeTags.icecap or biomeTags.heavySnowSummer or biomeTags.medSnowSummer or biomeTags.lightSnowSummer then
descriptionString = "Ледяной"
elseif biomeTags.temperate then
descriptionString = "Умеренный"
elseif biomeTags.dry then
descriptionString = "Сухой"
end
local mainAdded = false
local function addMain(value)
if descriptionString then
descriptionString = descriptionString .. " " .. value .. "."
else
descriptionString = mj:capitalize(value) .. "."
end
mainAdded = true
end
if biomeTags.desert then
addMain("пустыня")
elseif biomeTags.steppe then
addMain("степь")
elseif biomeTags.rainforest then
addMain("тропический лес")
elseif biomeTags.savanna then
addMain("саванна")
elseif biomeTags.tundra then
addMain("тундра")
end
if not mainAdded then
if not descriptionString then
return ""
end
return descriptionString .. "."
end
return descriptionString
end
function localizations.getBiomeTemperatureDescription(biomeTags)
local descriptionString = nil
if biomeTags.temperatureSummerVeryHot then
descriptionString = "Очень жаркое лето."
elseif biomeTags.temperatureSummerHot then
descriptionString = "Жаркое лето."
elseif biomeTags.temperatureSummerCold then
descriptionString = "Холодное лето."
elseif biomeTags.temperatureSummerVeryCold then
descriptionString = "Очень холодное лето."
else
descriptionString = "Умеренное лето."
end
if biomeTags.temperatureWinterVeryHot then
descriptionString = descriptionString .. " Очень жаркая зима."
elseif biomeTags.temperatureWinterHot then
descriptionString = descriptionString .. " Жаркая зимаr."
elseif biomeTags.temperatureWinterCold then
descriptionString = descriptionString .. " Холодная зима."
elseif biomeTags.temperatureWinterVeryCold then
descriptionString = descriptionString .. " Очень холодная зима."
else
descriptionString = descriptionString .. " Умеренная зима."
end
turn descriptionString
end
function localizations.getBiomeFullDescription(biomeTags) --b13
return localizations.getBiomeMainDescription(biomeTags) .. " " .. localizations.getBiomeForestDescription(biomeTags) .. " " .. localizations.getBiomeTemperatureDescription(biomeTags)
end
--mj:log("localizations count:", #(localizations.localizations))
return localizations
Внимание! Этот перевод, возможно, ещё не готов.
Его статус: идёт перевод
Переведено на Нотабеноиде
http://notabenoid.org/book/84391/535828
Переводчики: DrKirk
Настройки
Готово:
