From 0bf207f32a4e1d31ef6df62a0f60afd0752a95cb Mon Sep 17 00:00:00 2001 From: Austin Hicks Date: Mon, 12 Aug 2024 15:20:50 -0700 Subject: [PATCH] Renamespace localisation strings to fa.* Fixes #212 --- control.lua | 30 ++++++++++++++-------------- locale/en/factorio-access.cfg | 2 +- scripts/building-tools.lua | 6 +++--- scripts/building-vehicle-sectors.lua | 6 +++--- scripts/fa-info.lua | 8 ++++---- scripts/fa-utils.lua | 4 ++-- scripts/kruise-kontrol-wrapper.lua | 14 ++++++------- scripts/scanner.lua | 6 +++--- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/control.lua b/control.lua index 411f29d7..53db854d 100644 --- a/control.lua +++ b/control.lua @@ -357,12 +357,12 @@ function read_hand(pindex) printout(fa_localising.get(cursor_stack, pindex) .. remote_info, pindex) else --Any other valid item - local out = { "access.cursor-description" } + local out = { "fa.cursor-description" } table.insert(out, cursor_stack.prototype.localised_name) local build_entity = cursor_stack.prototype.place_result if build_entity and build_entity.supports_direction then table.insert(out, 1) - table.insert(out, { "access.facing-direction", players[pindex].building_direction }) + table.insert(out, { "fa.facing-direction", players[pindex].building_direction }) else table.insert(out, 0) table.insert(out, "") @@ -378,12 +378,12 @@ function read_hand(pindex) end elseif cursor_ghost ~= nil then --Any ghost - local out = { "access.cursor-description" } + local out = { "fa.cursor-description" } table.insert(out, cursor_ghost.localised_name) local build_entity = cursor_ghost.place_result if build_entity and build_entity.supports_direction then table.insert(out, 1) - table.insert(out, { "access.facing-direction", players[pindex].building_direction }) + table.insert(out, { "fa.facing-direction", players[pindex].building_direction }) else table.insert(out, 0) table.insert(out, "") @@ -397,7 +397,7 @@ function read_hand(pindex) end printout(out, pindex) else - printout({ "access.empty_cursor" }, pindex) + printout({ "fa.empty_cursor" }, pindex) end end @@ -2930,7 +2930,7 @@ script.on_event("read-cursor-distance-and-direction", function(event) local cursor_location_description = "At" local cursor_production = " " local cursor_description_of = " " - local result = { "access.thing-producing-listpos-dirdist", cursor_location_description } + local result = { "fa.thing-producing-listpos-dirdist", cursor_location_description } table.insert(result, cursor_production) --no production table.insert(result, cursor_description_of) --listpos table.insert(result, dir_dist) @@ -4821,7 +4821,7 @@ script.on_event("click-menu", function(event) fa_graphics.draw_cursor_highlight(pindex, ent, nil) fa_graphics.sync_build_cursor_graphics(pindex) printout({ - "access.teleported-cursor-to", + "fa.teleported-cursor-to", "" .. math.floor(players[pindex].cursor_pos.x) .. " " .. math.floor(players[pindex].cursor_pos.y), }, pindex) -- players[pindex].menu = "" @@ -5683,7 +5683,7 @@ function do_multi_stack_transfer(ratio, pindex) table.insert(result, ", ") end if table_size(moved) == 0 then - table.insert(result, { "access.grabbed-nothing" }) + table.insert(result, { "fa.grabbed-nothing" }) else game.get_player(pindex).play_sound({ path = "utility/inventory_move" }) local item_list = { "" } @@ -5691,7 +5691,7 @@ function do_multi_stack_transfer(ratio, pindex) local listed_count = 0 for name, amount in pairs(moved) do if listed_count <= 5 then - table.insert(item_list, { "access.item-quantity", game.item_prototypes[name].localised_name, amount }) + table.insert(item_list, { "fa.item-quantity", game.item_prototypes[name].localised_name, amount }) table.insert(item_list, ", ") else other_items = other_items + amount @@ -5699,12 +5699,12 @@ function do_multi_stack_transfer(ratio, pindex) listed_count = listed_count + 1 end if other_items > 0 then - table.insert(item_list, { "access.item-quantity", "other items", other_items }) --***todo localize "other items + table.insert(item_list, { "fa.item-quantity", "other items", other_items }) --***todo localize "other items table.insert(item_list, ", ") end --trim traling comma off item_list[#item_list] = nil - table.insert(result, { "access.grabbed-stuff", item_list }) + table.insert(result, { "fa.grabbed-stuff", item_list }) end elseif sector and sector.name == "fluid" then --Do nothing @@ -5727,7 +5727,7 @@ function do_multi_stack_transfer(ratio, pindex) if table_size(moved) == 0 then if full then table.insert(result, "Inventory full or not applicable, ") end - table.insert(result, { "access.placed-nothing" }) + table.insert(result, { "fa.placed-nothing" }) else if full then table.insert(result, "Partial success, ") end game.get_player(pindex).play_sound({ path = "utility/inventory_move" }) @@ -5736,7 +5736,7 @@ function do_multi_stack_transfer(ratio, pindex) local listed_count = 0 for name, amount in pairs(moved) do if listed_count <= 5 then - table.insert(item_list, { "access.item-quantity", game.item_prototypes[name].localised_name, amount }) + table.insert(item_list, { "fa.item-quantity", game.item_prototypes[name].localised_name, amount }) table.insert(item_list, ", ") else other_items = other_items + amount @@ -5744,12 +5744,12 @@ function do_multi_stack_transfer(ratio, pindex) listed_count = listed_count + 1 end if other_items > 0 then - table.insert(item_list, { "access.item-quantity", "other items", other_items }) --***todo localize "other items + table.insert(item_list, { "fa.item-quantity", "other items", other_items }) --***todo localize "other items table.insert(item_list, ", ") end --trim trailing comma off item_list[#item_list] = nil - table.insert(result, { "access.placed-stuff", fa_utils.breakup_string(item_list) }) + table.insert(result, { "fa.placed-stuff", fa_utils.breakup_string(item_list) }) end end end diff --git a/locale/en/factorio-access.cfg b/locale/en/factorio-access.cfg index 1b73e9d3..f841a73c 100644 --- a/locale/en/factorio-access.cfg +++ b/locale/en/factorio-access.cfg @@ -1,5 +1,5 @@ #all keys should be part of category to not pollute the main namespace -[access] +[fa] #direction #eg North direction=__plural_for_parameter_1_{0=North|1=NorthEast|2=East|3=SouthEast|4=South|5=SouthWest|6=West|7=NorthWest|rest=}__ diff --git a/scripts/building-tools.lua b/scripts/building-tools.lua index 2e3ddf13..8fe0a519 100644 --- a/scripts/building-tools.lua +++ b/scripts/building-tools.lua @@ -512,7 +512,7 @@ function mod.nudge_key(direction, event) temporary_teleported = ent.teleport({ 0, 0 }) if not temporary_teleported then game.get_player(pindex).play_sound({ path = "utility/cannot_build" }) - printout({ "access.failed-to-nudge" }, pindex) + printout({ "fa.failed-to-nudge" }, pindex) return end @@ -535,11 +535,11 @@ function mod.nudge_key(direction, event) end if not actually_teleported then --Failed to teleport - printout({ "access.failed-to-nudge" }, pindex) + printout({ "fa.failed-to-nudge" }, pindex) return else --Successfully teleported and so nudged - printout({ "access.nudged-one-direction", { "access.direction", direction } }, pindex) + printout({ "fa.nudged-one-direction", { "fa.direction", direction } }, pindex) if players[pindex].cursor then players[pindex].cursor_pos = fa_utils.offset_position(players[pindex].cursor_pos, direction, 1) fa_graphics.draw_cursor_highlight(pindex, ent, "train-visualization") diff --git a/scripts/building-vehicle-sectors.lua b/scripts/building-vehicle-sectors.lua index baeb46ba..6a38a645 100644 --- a/scripts/building-vehicle-sectors.lua +++ b/scripts/building-vehicle-sectors.lua @@ -16,8 +16,8 @@ function mod.add_to_inventory_bar(ent, amount) local inventory = ent.get_inventory(defines.inventory.chest) --Checks - if not inventory then return { "access.failed-inventory-limit-ajust-notcontainter" } end - if not inventory.supports_bar() then return { "access.failed-inventory-limit-ajust-no-limit" } end + if not inventory then return { "fa.failed-inventory-limit-ajust-notcontainter" } end + if not inventory.supports_bar() then return { "fa.failed-inventory-limit-ajust-no-limit" } end local max_bar = #inventory + 1 local current_bar = inventory.get_bar() @@ -43,7 +43,7 @@ function mod.add_to_inventory_bar(ent, amount) else current_bar = value end - return { "access.inventory-limit-status", value, current_bar } + return { "fa.inventory-limit-status", value, current_bar } end --Increases the selected inserter's hand stack size by 1 diff --git a/scripts/fa-info.lua b/scripts/fa-info.lua index eeaae1d3..bfe18c06 100644 --- a/scripts/fa-info.lua +++ b/scripts/fa-info.lua @@ -1437,9 +1437,9 @@ function mod.read_selected_entity_status(pindex) --Entity Health if ent.is_entity_with_health and ent.get_health_ratio() == 1 then - table.insert(result, { "access.full-health" }) + table.insert(result, { "fa.full-health" }) elseif ent.is_entity_with_health then - table.insert(result, { "access.percent-health", math.floor(ent.get_health_ratio() * 100) }) + table.insert(result, { "fa.percent-health", math.floor(ent.get_health_ratio() * 100) }) end -- Report nearest rail intersection position -- laterdo find better keybind @@ -1497,9 +1497,9 @@ function mod.read_character_status(pindex) end --Character health if char.is_entity_with_health and char.get_health_ratio() == 1 then - table.insert(result, { "access.full-health" }) + table.insert(result, { "fa.full-health" }) elseif char.is_entity_with_health then - table.insert(result, { "access.percent-health", math.floor(char.get_health_ratio() * 100) }) + table.insert(result, { "fa.percent-health", math.floor(char.get_health_ratio() * 100) }) end printout(result, pindex) return diff --git a/scripts/fa-utils.lua b/scripts/fa-utils.lua index b5e1699f..1e2180da 100644 --- a/scripts/fa-utils.lua +++ b/scripts/fa-utils.lua @@ -691,7 +691,7 @@ function mod.dir_dist_locale(pos1, pos2) local dir_dist = mod.dir_dist(pos1, pos2) local aligned_note = "" if mod.is_direction_aligned(pos1, pos2) then aligned_note = "aligned " end - return { "access.dir-dist", aligned_note .. mod.direction_lookup(dir_dist[1]), math.floor(dir_dist[2] + 0.5) } + return { "fa.dir-dist", aligned_note .. mod.direction_lookup(dir_dist[1]), math.floor(dir_dist[2] + 0.5) } end function mod.ent_name_locale(ent) @@ -701,7 +701,7 @@ function mod.ent_name_locale(ent) end if ent.name == "forest" then print("todo: forest isn't an entity") - return { "access.forest" } + return { "fa.forest" } end local entity_prototype = game.entity_prototypes[ent.name] local resource_prototype = game.resource_category_prototypes[ent.name] diff --git a/scripts/kruise-kontrol-wrapper.lua b/scripts/kruise-kontrol-wrapper.lua index 8b2f1a04..e70e2b65 100644 --- a/scripts/kruise-kontrol-wrapper.lua +++ b/scripts/kruise-kontrol-wrapper.lua @@ -46,7 +46,7 @@ function mod.activate_kk(pindex) local hand = p.cursor_stack if hand and hand.valid_for_read and (hand.name == "blueprint" or hand.name == "blueprint-book") then - return { "access.kk-blueprints-not-allowed" } + return { "fa.kk-blueprints-not-allowed" } end -- Okay. Finally we're good. Let's kick this off. @@ -63,10 +63,10 @@ function mod.activate_kk(pindex) remote.call(interface_name, "start_job", pindex, { x = math.floor(kk_pos.x), y = math.floor(kk_pos.y) }, target) local desc = remote.call(interface_name, "get_description", pindex) - if not desc then return { "access.kk-not-started" } end + if not desc then return { "fa.kk-not-started" } end - return { "access.kk-start", desc } - end, { "access.kk-not-available" }) + return { "fa.kk-start", desc } + end, { "fa.kk-not-available" }) printout(announcing, pindex) end @@ -90,7 +90,7 @@ function mod.cancel_kk(pindex) -- cursor mode. fix_walk(pindex) - printout({ "access.kk-cancel" }, pindex) + printout({ "fa.kk-cancel" }, pindex) end) end @@ -102,9 +102,9 @@ function mod.status_read(pindex, short_version) local was_active = players[pindex].kruise_kontrol_active_last_time players[pindex].kruise_kontrol_active_last_time = active if active then - printout({ "access.kk-state", remote.call(interface_name, "get_description", pindex) }, pindex) + printout({ "fa.kk-state", remote.call(interface_name, "get_description", pindex) }, pindex) elseif not active and was_active then - printout({ "access.kk-done" }, pindex) + printout({ "fa.kk-done" }, pindex) end end) end diff --git a/scripts/scanner.lua b/scripts/scanner.lua index 8dc8d732..8336e5e7 100644 --- a/scripts/scanner.lua +++ b/scripts/scanner.lua @@ -779,7 +779,7 @@ function mod.list_index(pindex) local dir_dist = fa_utils.dir_dist_locale(p.position, players[pindex].cursor_pos) if players[pindex].nearby.count == false then --Read the entity in terms of distance and direction, taking the cursor position as the reference point - local result = { "access.thing-producing-listpos-dirdist", fa_utils.ent_name_locale(ent) } + local result = { "fa.thing-producing-listpos-dirdist", fa_utils.ent_name_locale(ent) } table.insert(result, mod.ent_extra_list_info(ent, pindex, true)) table.insert( result, @@ -794,8 +794,8 @@ function mod.list_index(pindex) else --Read the entity in terms of count, and give the direction and distance of an example local result = { - "access.item_and_quantity-example-at-dirdist", - { "access.item-quantity", fa_utils.ent_name_locale(ent), ents[players[pindex].nearby.index].count }, + "fa.item_and_quantity-example-at-dirdist", + { "fa.item-quantity", fa_utils.ent_name_locale(ent), ents[players[pindex].nearby.index].count }, dir_dist, } local final_result = { "" }