Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions lua/custom_chat/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,38 @@ end

function CustomChat.NiceTime( time )
local L = CustomChat.GetLanguageText
local s = time % 60

time = Floor( time / 60 )
local m = time % 60

time = Floor( time / 60 )
local h = time % 24

time = Floor( time / 24 )
local d = time % 7
local w = Floor( time / 7 )

if w > 0 then
return w .. " " .. L( "time.weeks" )
local timeUnits = {
{ value = math.floor( time / ( 60 * 60 * 24 * 30 * 12 ) ), name = "time.years" },
{ value = math.floor( time / ( 60 * 60 * 24 * 30 ) ) % 12, name = "time.months" },
{ value = math.floor( time / ( 60 * 60 * 24 ) ) % 30, name = "time.days" },
{ value = math.floor( time / ( 60 * 60 ) ) % 24, name = "time.hours" },
{ value = math.floor( time / 60 ) % 60, name = "time.minutes" },
{ value = time % 60, name = "time.seconds" }
}

local nonZeroUnits = {}
for _, unit in ipairs( timeUnits ) do
if unit.value > 0 then
table.insert( nonZeroUnits, unit )
end
end

if d > 0 then
return d .. " " .. L( "time.days" )
local selectedUnits = {}
for i = 1, math.min( 2, #nonZeroUnits ) do
table.insert( selectedUnits, nonZeroUnits[i] )
end

if h > 0 then
return h .. " " .. L( "time.hours" )
if #selectedUnits == 0 then
return "0 " .. L( "time.seconds" )
end

if m > 0 and h < 1 and d < 1 then
return m .. " " .. L( "time.minutes" )
local parts = {}
for _, unit in ipairs( selectedUnits ) do
table.insert( parts, unit.value .. " " .. L( unit.name ) )
end

return s .. " " .. L( "time.seconds" )
return table.concat( parts, ", " )
end

function CustomChat.PrintMessage( text )
Expand Down
2 changes: 2 additions & 0 deletions resource/localization/en/custom_chat.properties
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ custom_chat.server_theme.tip=This action will force all players (including those
custom_chat.friend_spawned1=Your friend
custom_chat.friend_spawned2=has spawned in.
custom_chat.last_seen1=last played
custom_chat.time.years=years
custom_chat.time.months=months
custom_chat.time.weeks=weeks
custom_chat.time.days=days
custom_chat.time.hours=hours
Expand Down
2 changes: 2 additions & 0 deletions resource/localization/pt-br/custom_chat.properties
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ custom_chat.server_theme.tip=Esta ação forçará todos os jogadores (incluindo
custom_chat.friend_spawned1=Seu amigo
custom_chat.friend_spawned2=acabou de aparecer aqui.
custom_chat.last_seen1=jogou pela última vez há
custom_chat.time.years=anos
custom_chat.time.months=meses
custom_chat.time.weeks=semanas
custom_chat.time.days=dias
custom_chat.time.hours=horas
Expand Down
2 changes: 2 additions & 0 deletions resource/localization/ru/custom_chat.properties
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ custom_chat.server_theme.tip=Это действие заставит всех
custom_chat.friend_spawned1=Ваш друг
custom_chat.friend_spawned2=загрузился.
custom_chat.last_seen1=заходил последний раз
custom_chat.time.years=лет
custom_chat.time.months=месяцев
custom_chat.time.weeks=нед.
custom_chat.time.days=д.
custom_chat.time.hours=ч.
Expand Down
2 changes: 2 additions & 0 deletions resource/localization/tr/custom_chat.properties
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ custom_chat.server_theme.tip=Bu işlem, tüm oyuncuları (daha sonra katılanlar
custom_chat.friend_spawned1=Arkadaşın
custom_chat.friend_spawned2=burada.
custom_chat.last_seen1=en son
custom_chat.time.years=yıl
custom_chat.time.months=aylar
custom_chat.time.weeks=hafta
custom_chat.time.days=gün
custom_chat.time.hours=saat
Expand Down