From b02929edf07d3da10e3d06d84ab4aec15242b60d Mon Sep 17 00:00:00 2001 From: Ku3mi41 Date: Sat, 30 Mar 2019 22:17:29 +0700 Subject: [PATCH] feat(player_list): added internationalization --- features/gui/player_list.lua | 67 ++++++++++++++++++------------------ locale/en/redmew_gui.cfg | 16 +++++++++ locale/ru/redmew_gui.cfg | 16 +++++++++ 3 files changed, 66 insertions(+), 33 deletions(-) diff --git a/features/gui/player_list.lua b/features/gui/player_list.lua index aa46abdd..0ce68165 100644 --- a/features/gui/player_list.lua +++ b/features/gui/player_list.lua @@ -148,8 +148,9 @@ local column_builders = { sort = function(a, b) return a.name:lower() < b.name:lower() end, - draw_heading = function(parent) - local label = parent.add {type = 'label', name = player_name_heading_name, caption = 'Name'} + draw_heading = function(parent, data, sort_symbol) + local caption = {'player_list.name_caption', sort_symbol} + local label = parent.add {type = 'label', name = player_name_heading_name, caption = caption} local label_style = label.style apply_heading_style(label_style) label_style.width = 150 @@ -182,8 +183,9 @@ local column_builders = { sort = function(a, b) return a < b end, - draw_heading = function(parent) - local label = parent.add {type = 'label', name = time_heading_name, caption = 'Time'} + draw_heading = function(parent, data, sort_symbol) + local caption = {'player_list.time_caption', sort_symbol} + local label = parent.add {type = 'label', name = time_heading_name, caption = caption} local label_style = label.style apply_heading_style(label_style) label_style.width = 125 @@ -216,8 +218,9 @@ local column_builders = { end return a_rank < b_rank end, - draw_heading = function(parent) - local label = parent.add {type = 'label', name = rank_heading_name, caption = 'Rank'} + draw_heading = function(parent, data, sort_symbol) + local caption = {'player_list.rank_caption', sort_symbol} + local label = parent.add {type = 'label', name = rank_heading_name, caption = caption} local label_style = label.style apply_heading_style(label_style) label_style.width = rank_column_width @@ -258,8 +261,9 @@ local column_builders = { sort = function(a, b) return a < b end, - draw_heading = function(parent) - local label = parent.add {type = 'label', name = distance_heading_name, caption = 'Distance'} + draw_heading = function(parent, data, sort_symbol) + local caption = {'player_list.distance_caption', sort_symbol} + local label = parent.add {type = 'label', name = distance_heading_name, caption = caption} local label_style = label.style apply_heading_style(label_style) label_style.width = 70 @@ -293,12 +297,13 @@ local column_builders = { return a_coin_earned < b_coin_earned end end, - draw_heading = function(parent) + draw_heading = function(parent, data, sort_symbol) + local caption = {'player_list.coins_caption', sort_symbol} local label = parent.add { type = 'label', name = coin_heading_name, - caption = 'Coins', + caption = caption, tooltip = 'Coins earned / spent.' } local label_style = label.style @@ -329,8 +334,9 @@ local column_builders = { sort = function(a, b) return a.count < b.count end, - draw_heading = function(parent) - local label = parent.add {type = 'label', name = deaths_heading_name, caption = 'Deaths'} + draw_heading = function(parent, data, sort_symbol) + local caption = {'player_list.deaths_caption', sort_symbol} + local label = parent.add {type = 'label', name = deaths_heading_name, caption = caption} local label_style = label.style apply_heading_style(label_style) label_style.width = 60 @@ -364,8 +370,9 @@ local column_builders = { sort = function(a, b) return a.poke_count < b.poke_count end, - draw_heading = function(parent, data) - local label = parent.add {type = 'label', name = poke_name_heading_name, caption = 'Poke'} + draw_heading = function(parent, data, sort_symbol) + local caption = {'player_list.poke_caption', sort_symbol} + local label = parent.add {type = 'label', name = poke_name_heading_name, caption = caption} local label_style = label.style apply_heading_style(label_style) label_style.width = 60 @@ -406,13 +413,14 @@ local column_builders = { sort = function(a, b) return a.name:lower() < b.name:lower() end, - draw_heading = function(parent) + draw_heading = function(parent, data, sort_symbol) + local caption = {'player_list.report_caption', sort_symbol} local label = parent.add { type = 'label', name = report_heading_name, - caption = 'Report', - tooltip = 'Report player to the admin team for griefing or breaking the rules.' + caption = caption, + tooltip = {'player_list.report_tooltip'} } local label_style = label.style apply_heading_style(label_style) @@ -430,7 +438,7 @@ local column_builders = { type = 'sprite-button', name = report_cell_name, sprite = 'utility/force_editor_icon', - tooltip = 'Report ' .. cell_data.name + tooltip = {'player_list.report_button_tooltip', cell_data.name} } local label_style = label.style label_style.horizontal_align = 'center' @@ -477,9 +485,7 @@ local function redraw_title(data) local online_count = #game.connected_players local total_count = PlayerStats.get_total_player_count() - local title = table.concat {'Player list - Online: ', online_count, ' Total: ' .. total_count} - - frame.caption = title + frame.caption = {'player_list.title', online_count, total_count} end local function redraw_headings(data) @@ -488,25 +494,20 @@ local function redraw_headings(data) local sort = settings.sort local sort_column = math.abs(sort) - local sort_symbol - if sort > 0 then - sort_symbol = symbol_asc - else - sort_symbol = symbol_desc - end - local heading_table_flow = data.heading_table_flow Gui.clear(heading_table_flow) local heading_table = heading_table_flow.add {type = 'table', column_count = #columns} for i, c in ipairs(settings.columns) do - local heading = column_builders[c].draw_heading(heading_table, data) + local sort_symbol = '' if i == sort_column then - heading.caption = heading.caption .. sort_symbol + sort_symbol = sort > 0 and symbol_asc or symbol_desc end + local heading = column_builders[c].draw_heading(heading_table, data, sort_symbol) + Gui.set_data(heading, {data = data, index = i}) end end @@ -570,11 +571,11 @@ local function draw_main_frame(left, player) type = 'checkbox', name = notify_checkbox_name, state = not no_notify_players[player_index], - caption = 'Notify me when pokes happen.', - tooltip = 'Receive a message when a player pokes another player.' + caption = {'player_list.poke_notify_caption'}, + tooltip = {'player_list.poke_notify_tooltip'} } - frame.add {type = 'button', name = main_button_name, caption = 'Close'} + frame.add {type = 'button', name = main_button_name, caption = {'player_list.close_caption'}} local settings = player_settings[player_index] or get_default_player_settings() local data = { diff --git a/locale/en/redmew_gui.cfg b/locale/en/redmew_gui.cfg index 3f91cd94..d53e41fb 100644 --- a/locale/en/redmew_gui.cfg +++ b/locale/en/redmew_gui.cfg @@ -45,3 +45,19 @@ whats_new_button=What's New [toast] toast_all=__1__ sent a toast to all players. toast_player=__1__ sent a toast to __2__. + +[player_list] +title=Player list - Online: __1__ Total: __2__ +name_caption=Name __1__ +time_caption=Time __1__ +rank_caption=Rank __1__ +distance_caption=Distance __1__ +coins_caption=Coins __1__ +deaths_caption=Deaths __1__ +poke_caption=Poke __1__ +report_caption=Report __1__ +report_tooltip=Report player to the admin team for griefing or breaking the rules. +report_button_tooltip=Report __1__ +close_caption=Close +poke_notify_caption=Notify me when pokes happen. +poke_notify_tooltip=Receive a message when a player pokes another player. \ No newline at end of file diff --git a/locale/ru/redmew_gui.cfg b/locale/ru/redmew_gui.cfg index e3f43aae..41d96bcc 100644 --- a/locale/ru/redmew_gui.cfg +++ b/locale/ru/redmew_gui.cfg @@ -45,3 +45,19 @@ whats_new_button=Что нового [toast] toast_all=__1__ sent a toast to all players. toast_player=__1__ sent a toast to __2__. + +[player_list] +title=Список игроков - В игре: __1__ Всего: __2__ +name_caption=Имя __1__ +time_caption=Время __1__ +rank_caption=Ранг __1__ +distance_caption=Дистанция __1__ +coins_caption=Монеты __1__ +deaths_caption=Смерти __1__ +poke_caption=Ткнуть __1__ +report_caption=Жалоба __1__ +report_tooltip=Сообщить администраторам о грифинге или нарушении правил. +report_button_tooltip=Пожаловаться на __1__ +close_caption=Закрыть +poke_notify_caption=Сообщать мне когда кого-то ткнули. +poke_notify_tooltip=Отправлять сообщение когда один игрок ткнул другого. \ No newline at end of file