summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-09-20 00:45:42 +0200
committermetamuffin <metamuffin@disroot.org>2024-09-20 00:50:05 +0200
commit3b3c7b900d4eeccb57eb983ce5bc41efa4d5f457 (patch)
tree9608ff402d95ea927fb3b0c9dbddd7a927f9bf87
parent2b2b1957b80c0743b455e3decba56d0551e69162 (diff)
downloadhurrycurry-3b3c7b900d4eeccb57eb983ce5bc41efa4d5f457.tar
hurrycurry-3b3c7b900d4eeccb57eb983ce5bc41efa4d5f457.tar.bz2
hurrycurry-3b3c7b900d4eeccb57eb983ce5bc41efa4d5f457.tar.zst
replace % operator with String.format()
-rw-r--r--client/game.gd6
-rw-r--r--client/menu/hairstyle_preview.gd2
-rw-r--r--client/menu/lobby.gd2
-rw-r--r--client/menu/popup_message/popup_message.gd16
-rw-r--r--client/menu/rating/rating.gd1
-rw-r--r--client/menu/settings/input/input_manager.gd8
-rw-r--r--client/multiplayer.gd4
7 files changed, 20 insertions, 19 deletions
diff --git a/client/game.gd b/client/game.gd
index 407c1243..8cd648a6 100644
--- a/client/game.gd
+++ b/client/game.gd
@@ -263,8 +263,8 @@ func handle_packet(p):
"server_message":
var mstr := get_message_str(p.message)
if p.error:
- popup_message.display_server_msg(tr("c.error.server") % mstr)
- push_error(tr("c.error.server") % mstr)
+ popup_message.display_server_msg(tr("c.error.server").format([mstr]))
+ push_error(tr("c.error.server").format([mstr]))
else:
popup_message.display_server_msg(mstr)
"server_hint":
@@ -308,7 +308,7 @@ func _process(delta):
func get_message_str(m: Dictionary) -> String:
if "text" in m: return m.text
- if "translation" in m: return tr(m.translation.id) % m.translation.params.map(get_message_str)
+ if "translation" in m: return tr(m.translation.id).format(m.translation.params.map(get_message_str))
if "tile" in m: return tile_names[m.tile]
if "item" in m: return item_names[m.item]
return "[unknown message type]"
diff --git a/client/menu/hairstyle_preview.gd b/client/menu/hairstyle_preview.gd
index 324f7de1..fb2cabce 100644
--- a/client/menu/hairstyle_preview.gd
+++ b/client/menu/hairstyle_preview.gd
@@ -21,5 +21,5 @@ signal selected(character: int)
func setup(character: int, group: ButtonGroup):
$HairViewport/Node3D/Character.select_hairstyle(character)
$Select.button_group = group
- $Select.text = tr("Hairstyle %d") % (character + 1)
+ $Select.text = tr("Hairstyle %d") % (character + 1) # TODO localize
$Select.pressed.connect(func(): selected.emit(character))
diff --git a/client/menu/lobby.gd b/client/menu/lobby.gd
index 39199d59..0dca6f4c 100644
--- a/client/menu/lobby.gd
+++ b/client/menu/lobby.gd
@@ -105,7 +105,7 @@ func select_map(i: int):
selected_map = i
var map_data: Dictionary = game.maps[i][1]
map_name_label.text = map_data["name"]
- map_player_label.text = tr("c.map.players_recommended") % map_data["players"]
+ map_player_label.text = tr("c.map.players_recommended").format([map_data["players"]])
map_difficulty_label.text = tr("c.map.difficulty.%d" % (map_data["difficulty"] - 1))
selected_map_name = game.maps[i][0]
if not game.menu.covered:
diff --git a/client/menu/popup_message/popup_message.gd b/client/menu/popup_message/popup_message.gd
index ead11977..6413a887 100644
--- a/client/menu/popup_message/popup_message.gd
+++ b/client/menu/popup_message/popup_message.gd
@@ -153,35 +153,35 @@ func _input(_event):
func _on_boost_timeout():
if not Global.get_hint("has_boosted") and not Global.using_touch:
- display_hint_msg(tr("c.hint.boost") % display_keybind("boost"))
+ display_hint_msg(tr("c.hint.boost").format([display_keybind("boost")]))
func _on_move_timeout():
if not Global.get_hint("has_moved") and not Global.using_touch:
- display_hint_msg(tr("c.hint.movement") % ", ".join(
+ display_hint_msg(tr("c.hint.movement").format([", ".join(
[
display_keybind("forwards"),
display_keybind("left"),
display_keybind("backwards"),
display_keybind("right")
]
- ))
+ )]))
func _on_interact_timeout():
if not Global.get_hint("has_interacted") and not Global.using_touch:
- display_hint_msg(tr("c.hint.interact") % display_keybind("interact"))
+ display_hint_msg(tr("c.hint.interact").format([display_keybind("interact")]))
func _on_reset_timeout():
if not Global.get_hint("has_reset") and not Global.using_touch:
- display_hint_msg(tr("c.hint.reset_camera") % display_keybind("reset"))
+ display_hint_msg(tr("c.hint.reset_camera").format([display_keybind("reset")]))
func _on_zoom_timeout():
if not Global.get_hint("has_zoomed") and not Global.using_touch:
- display_hint_msg(tr("c.hint.zoom_camera") % ", ".join(
+ display_hint_msg(tr("c.hint.zoom_camera").format([", ".join(
[
display_keybind("zoom_in"),
display_keybind("zoom_out")
]
- ))
+ )]))
func display_keybind(action_name: String) -> String:
var events := InputManager.get_events(action_name)
@@ -227,7 +227,7 @@ func _on_nametags_timeout():
func _on_join_while_running_timeout():
if not game.is_joined and not Global.get_hint("has_seen_join_while_running"):
Global.set_hint("has_seen_join_while_running", true)
- display_hint_msg(tr("c.hint.join_while_running") % display_keybind("menu"))
+ display_hint_msg(tr("c.hint.join_while_running").format([display_keybind("menu")]))
func _on_performance_timeout() -> void:
if not Global.get_hint("has_seen_performance") and Engine.get_frames_per_second() < DisplayServer.screen_get_refresh_rate() * 0.75:
diff --git a/client/menu/rating/rating.gd b/client/menu/rating/rating.gd
index 1669e5fc..abe4d426 100644
--- a/client/menu/rating/rating.gd
+++ b/client/menu/rating/rating.gd
@@ -32,6 +32,7 @@ func _process(_delta):
particles.emission_rect_extents = get_viewport_rect().size * Vector2(0.5, 0.5)
func show_rating(stars_: int, points: int):
+ # TODO localize
match stars_:
0: title.text = tr("Poor service")
1: title.text = tr("Acceptable service")
diff --git a/client/menu/settings/input/input_manager.gd b/client/menu/settings/input/input_manager.gd
index 640410d0..b612bde3 100644
--- a/client/menu/settings/input/input_manager.gd
+++ b/client/menu/settings/input/input_manager.gd
@@ -93,12 +93,12 @@ func get_event_type(input_event: InputEvent) -> EventType:
func display_input_event(input_event: InputEvent) -> String:
if input_event is InputEventKey:
- return tr("c.settings.input.keyboard") % OS.get_keycode_string(input_event.physical_keycode)
+ return tr("c.settings.input.keyboard").format([OS.get_keycode_string(input_event.physical_keycode)])
elif input_event is InputEventMouseButton:
- return tr("c.settings.input.mouse_button") % input_event.button_index
+ return tr("c.settings.input.mouse_button").format([input_event.button_index])
elif input_event is InputEventJoypadButton:
- return tr("c.settings.input.joypad") % input_event.button_index
+ return tr("c.settings.input.joypad").format([input_event.button_index])
elif input_event is InputEventJoypadMotion:
- return tr("c.settings.input.joypad_axis") % [input_event.axis]
+ return tr("c.settings.input.joypad_axis").format([input_event.axis])
else:
return tr("c.settings.input.other_event")
diff --git a/client/multiplayer.gd b/client/multiplayer.gd
index 44e900af..e9b2a4ec 100644
--- a/client/multiplayer.gd
+++ b/client/multiplayer.gd
@@ -49,7 +49,7 @@ func _process(_delta):
elif state == WebSocketPeer.STATE_CLOSED:
var code = socket.get_close_code()
var reason = socket.get_close_reason() if code == socket.STATE_CLOSED else tr("c.error.websocket.unavailable")
- connection_closed.emit(tr("c.error.websocket") % [code, reason, code != -1])
+ connection_closed.emit(tr("c.error.websocket").format([code, reason, code != -1]))
self.queue_free()
func fix_packet_types(val):
@@ -85,7 +85,7 @@ func handle_packet(coded):
if major != VERSION_MAJOR and minor >= VERSION_MINOR:
socket.close()
connected = false
- connection_closed.emit(tr("c.error.version_mismatch") % [major, minor, VERSION_MAJOR, VERSION_MINOR])
+ connection_closed.emit(tr("c.error.version_mismatch").format([major, minor, VERSION_MAJOR, VERSION_MINOR]))
_: packet.emit(p)
func send_join(player_name: String, character: int):