diff --git a/lua/custom_chat/client/main.lua b/lua/custom_chat/client/main.lua index 64059a8..a26324f 100644 --- a/lua/custom_chat/client/main.lua +++ b/lua/custom_chat/client/main.lua @@ -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 ) diff --git a/resource/localization/en/custom_chat.properties b/resource/localization/en/custom_chat.properties index d8605e4..3bce8af 100644 --- a/resource/localization/en/custom_chat.properties +++ b/resource/localization/en/custom_chat.properties @@ -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 diff --git a/resource/localization/pt-br/custom_chat.properties b/resource/localization/pt-br/custom_chat.properties index 6afbc0e..efb83d1 100644 --- a/resource/localization/pt-br/custom_chat.properties +++ b/resource/localization/pt-br/custom_chat.properties @@ -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 diff --git a/resource/localization/ru/custom_chat.properties b/resource/localization/ru/custom_chat.properties index 02d602d..8b172fc 100644 --- a/resource/localization/ru/custom_chat.properties +++ b/resource/localization/ru/custom_chat.properties @@ -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=ч. diff --git a/resource/localization/tr/custom_chat.properties b/resource/localization/tr/custom_chat.properties index 77e76e5..9e40e10 100644 --- a/resource/localization/tr/custom_chat.properties +++ b/resource/localization/tr/custom_chat.properties @@ -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