Skip to content

Commit

Permalink
Renamespace localisation strings to fa.*
Browse files Browse the repository at this point in the history
Fixes #212
  • Loading branch information
ahicks92 committed Sep 12, 2024
1 parent 6a83b9b commit 001fb46
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
30 changes: 15 additions & 15 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,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, "")
Expand All @@ -396,12 +396,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, "")
Expand All @@ -415,7 +415,7 @@ function read_hand(pindex)
end
printout(out, pindex)
else
printout({ "access.empty_cursor" }, pindex)
printout({ "fa.empty_cursor" }, pindex)
end
end

Expand Down Expand Up @@ -3002,7 +3002,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)
Expand Down Expand Up @@ -4949,7 +4949,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 = ""
Expand Down Expand Up @@ -5844,28 +5844,28 @@ 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 = { "" }
local other_items = 0
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
end
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
Expand All @@ -5887,7 +5887,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" })
Expand All @@ -5896,20 +5896,20 @@ 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
end
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
Expand Down
2 changes: 1 addition & 1 deletion locale/en/factorio-access.cfg
Original file line number Diff line number Diff line change
@@ -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=}__
Expand Down
6 changes: 3 additions & 3 deletions scripts/building-tools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,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

Expand All @@ -543,11 +543,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")
Expand Down
6 changes: 3 additions & 3 deletions scripts/building-vehicle-sectors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/fa-info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1462,9 +1462,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
Expand Down
4 changes: 2 additions & 2 deletions scripts/fa-utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,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)
Expand All @@ -697,7 +697,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]
Expand Down
14 changes: 7 additions & 7 deletions scripts/kruise-kontrol-wrapper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

-- If in a car, make sure to activate it
Expand All @@ -71,10 +71,10 @@ function mod.activate_kk(pindex)
local opts = { x = math.floor(kk_pos.x), y = math.floor(kk_pos.y) }
remote.call(interface_name, "start_job", pindex, opts, 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
Expand All @@ -99,7 +99,7 @@ function mod.cancel_kk(pindex)
-- cursor mode.
fix_walk(pindex)

printout({ "access.kk-cancel" }, pindex)
printout({ "fa.kk-cancel" }, pindex)
end)
-- If in a car, make sure to stop it because we are exiting it too because of the overlapping keys
if p.vehicle and p.vehicle.type == "car" and p.vehicle.active == true then p.vehicle.speed = 0 end
Expand All @@ -113,9 +113,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
Expand Down
6 changes: 3 additions & 3 deletions scripts/scanner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 = { "" }
Expand Down

0 comments on commit 001fb46

Please sign in to comment.