mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-05 15:00:29 +00:00
Add a tool to verify language files are well formed
I'm not going to pretend this is a beautiful script, but it's good enough for basic validation of language files.
This commit is contained in:
parent
379076a5e2
commit
1290a4402c
@ -42,26 +42,36 @@ upgrade.computercraft:speaker.adjective=Laut
|
||||
chat.computercraft.wired_modem.peripheral_connected=Peripheriegerät "%s" mit dem Netzwerk verbunden
|
||||
chat.computercraft.wired_modem.peripheral_disconnected=Peripheriegerät "%s" vom Netzwerk getrennt
|
||||
|
||||
gui.computercraft:config.http_enable=HTTP-API aktivieren
|
||||
gui.computercraft:config.http_websocket_enable=HTTP-Websockets aktivieren
|
||||
gui.computercraft:config.http_whitelist=HTTP-Whitelist
|
||||
gui.computercraft:config.http_blacklist=HTTP-Blacklist
|
||||
gui.computercraft:config.disable_lua51_features=Lua 5.1-Funktionen deaktivieren
|
||||
gui.computercraft:config.default_computer_settings=Computer-Standardeinstellungen
|
||||
gui.computercraft:config.debug_enable=Debug-Library aktivieren
|
||||
gui.computercraft:config.log_peripheral_errors=Peripheriefehler loggen
|
||||
gui.computercraft:config.enable_command_block=Befehlsblöcke als Peripheriegerät erlauben
|
||||
gui.computercraft:config.modem_range=Modemreichweite (normal)
|
||||
gui.computercraft:config.modem_high_altitude_range=Modemreichweite (in großer Höhe)
|
||||
gui.computercraft:config.modem_range_during_storm=Modemreichweite (bei schlechtem Wetter)
|
||||
gui.computercraft:config.modem_high_altitude_range_during_storm=Modemreichweite (in großer Höhe bei schlechtem Wetter)
|
||||
# Command descriptions, usage and any additional messages.
|
||||
|
||||
# Names for the various tracking fields.
|
||||
|
||||
# Misc tooltips
|
||||
|
||||
# Config options
|
||||
gui.computercraft:config.computer_space_limit=Speicherplatz von Computern (bytes)
|
||||
gui.computercraft:config.floppy_space_limit=Speicherplatz von Disketten (bytes)
|
||||
gui.computercraft:config.turtles_need_fuel=Treibstoffverbrauch aktivieren
|
||||
gui.computercraft:config.turtle_fuel_limit=Treibstofflimit von Turtles
|
||||
gui.computercraft:config.advanced_turtle_fuel_limit=Treibstofflimit von Erweiterten Turtles
|
||||
gui.computercraft:config.turtles_obey_block_protection=Turtles unterliegen Blockschutzrichtlinien
|
||||
gui.computercraft:config.turtles_can_push=Turtles können Entities bewegen
|
||||
gui.computercraft:config.turtle_disabled_actions=Deaktivierte Turtle-Aktionen
|
||||
gui.computercraft:config.maximum_files_open=Maximalanzahl an gleichzeitig offenen Dateien je Computer
|
||||
gui.computercraft:config.max_notes_per_tick=Maximalanzahl an Noten, die ein Computer gleichzeitig spielen kann
|
||||
gui.computercraft:config.maximum_open_files=Maximalanzahl an gleichzeitig offenen Dateien je Computer
|
||||
gui.computercraft:config.disable_lua51_features=Lua 5.1-Funktionen deaktivieren
|
||||
gui.computercraft:config.default_computer_settings=Computer-Standardeinstellungen
|
||||
gui.computercraft:config.debug_enabled=Debug-Library aktivieren
|
||||
gui.computercraft:config.log_computer_errors=Peripheriefehler loggen
|
||||
|
||||
gui.computercraft:config.http.enabled=HTTP-API aktivieren
|
||||
gui.computercraft:config.http.websocket_enabled=HTTP-Websockets aktivieren
|
||||
gui.computercraft:config.http.whitelist=HTTP-Whitelist
|
||||
gui.computercraft:config.http.blacklist=HTTP-Blacklist
|
||||
|
||||
gui.computercraft:config.peripheral.command_block_enabled=Befehlsblöcke als Peripheriegerät erlauben
|
||||
gui.computercraft:config.peripheral.modem_range=Modemreichweite (normal)
|
||||
gui.computercraft:config.peripheral.modem_high_altitude_range=Modemreichweite (in großer Höhe)
|
||||
gui.computercraft:config.peripheral.modem_range_during_storm=Modemreichweite (bei schlechtem Wetter)
|
||||
gui.computercraft:config.peripheral.modem_high_altitude_range_during_storm=Modemreichweite (in großer Höhe bei schlechtem Wetter)
|
||||
gui.computercraft:config.peripheral.max_notes_per_tick=Maximalanzahl an Noten, die ein Computer gleichzeitig spielen kann
|
||||
|
||||
gui.computercraft:config.turtle.need_fuel=Treibstoffverbrauch aktivieren
|
||||
gui.computercraft:config.turtle.normal_fuel_limit=Treibstofflimit von Turtles
|
||||
gui.computercraft:config.turtle.advanced_fuel_limit=Treibstofflimit von Erweiterten Turtles
|
||||
gui.computercraft:config.turtle.obey_block_protection=Turtles unterliegen Blockschutzrichtlinien
|
||||
gui.computercraft:config.turtle.can_push=Turtles können Entities bewegen
|
||||
gui.computercraft:config.turtle.disabled_actions=Deaktivierte Turtle-Aktionen
|
||||
|
@ -39,11 +39,17 @@ upgrade.minecraft:crafting_table.adjective=Artigiano
|
||||
upgrade.computercraft:advanced_modem.adjective=Ender
|
||||
upgrade.computercraft:speaker.adjective=Rumoroso
|
||||
|
||||
gui.computercraft.wired_modem.peripheral_connected=Periferica "%s" connessa alla rete
|
||||
gui.computercraft.wired_modem.peripheral_disconnected=Periferica "%s" disconessa dalla rete
|
||||
chat.computercraft.wired_modem.peripheral_connected=Periferica "%s" connessa alla rete
|
||||
chat.computercraft.wired_modem.peripheral_disconnected=Periferica "%s" disconessa dalla rete
|
||||
|
||||
# Command descriptions, usage and any additional messages.
|
||||
|
||||
# Names for the various tracking fields.
|
||||
|
||||
# Misc tooltips
|
||||
gui.computercraft.tooltip.copy=Copia negli appunti
|
||||
|
||||
# Config options
|
||||
gui.computercraft:config.computer_space_limit=Limite spazio Computer (bytes)
|
||||
gui.computercraft:config.floppy_space_limit=Limite spazio Disco Floppy (bytes)
|
||||
gui.computercraft:config.maximum_open_files=Massimo file aperti per computer
|
||||
|
@ -42,8 +42,14 @@ upgrade.computercraft:speaker.adjective=(Alto-Falante)
|
||||
chat.computercraft.wired_modem.peripheral_connected=Periférico "%s" conectado à rede
|
||||
chat.computercraft.wired_modem.peripheral_disconnected=Periférico "%s" desconectado da rede
|
||||
|
||||
# Command descriptions, usage and any additional messages.
|
||||
|
||||
# Names for the various tracking fields.
|
||||
|
||||
# Misc tooltips
|
||||
gui.computercraft.tooltip.copy=Copiar para a área de transferência
|
||||
|
||||
# Config options
|
||||
gui.computercraft:config.computer_space_limit=Limite de espaço dos Computadores (bytes)
|
||||
gui.computercraft:config.floppy_space_limit=Limite de espaço dos Disquetes (bytes)
|
||||
gui.computercraft:config.maximum_open_files=Número máximo de arquivos em um computador
|
||||
|
@ -42,8 +42,14 @@ upgrade.computercraft:speaker.adjective=Högljudd
|
||||
chat.computercraft.wired_modem.peripheral_connected=Kringutrustning "%s" är kopplad till nätverket
|
||||
chat.computercraft.wired_modem.peripheral_disconnected=Kringutrustning "%s" är frånkopplad från nätverket
|
||||
|
||||
# Command descriptions, usage and any additional messages.
|
||||
|
||||
# Names for the various tracking fields.
|
||||
|
||||
# Misc tooltips
|
||||
gui.computercraft.tooltip.copy=Kopiera till urklipp
|
||||
|
||||
# Config options
|
||||
gui.computercraft:config.computer_space_limit=Dator maximalt utrymme (bytes)
|
||||
gui.computercraft:config.floppy_space_limit=Diskett maximalt utrymme (bytes)
|
||||
gui.computercraft:config.maximum_open_files=Max antal filer öppna per dator
|
||||
|
111
tools/language.lua
Normal file
111
tools/language.lua
Normal file
@ -0,0 +1,111 @@
|
||||
--- Rewrites language files in order to be consistent with en_us.
|
||||
--
|
||||
-- This will take every given language file and rewrite it to be in the same
|
||||
-- order as the en_us file. Any keys which appear in the given file, but not
|
||||
-- in en_us are warned about.
|
||||
--
|
||||
-- When passing the `-v` flag, we also print any missing commands.
|
||||
--
|
||||
-- Note, this is not intended to be a fool-proof tool, rather a quick way to
|
||||
-- ensure language files are mostly correct.
|
||||
--
|
||||
-- @example
|
||||
--
|
||||
-- # Reformat all files
|
||||
-- > lua tools/language.lua
|
||||
-- # Reformat German, and warn about missing entries
|
||||
-- > lua tools/language.lua -v de_de
|
||||
|
||||
local primary = "en_us"
|
||||
|
||||
local secondary = {
|
||||
"de_de",
|
||||
"fr_fr",
|
||||
"it_it",
|
||||
"pt_br",
|
||||
"sv_se",
|
||||
}
|
||||
|
||||
local verbose = false
|
||||
|
||||
local path = "src/main/resources/assets/computercraft/lang/%s.lang"
|
||||
|
||||
|
||||
local args = {...}
|
||||
for i = #args, 1, -1 do
|
||||
if args[i] == "-v" or args[i] == "--verbose" then
|
||||
table.remove(args, i)
|
||||
verbose = true
|
||||
end
|
||||
end
|
||||
if #args > 0 then secondary = args end
|
||||
|
||||
-- Read the contents of the primary language file
|
||||
local primary_contents, n = {}, 1
|
||||
for line in io.lines(path:format(primary)) do
|
||||
local key = line:match("^([^=]+)=.*$")
|
||||
if key then
|
||||
primary_contents[n], n = key, n + 1
|
||||
elseif line == "" or line:sub(1, 1) == "#" then
|
||||
primary_contents[n], n = line, n + 1
|
||||
else
|
||||
io.stderr:write(("Unknown line %q in %s\n"):format(line, primary))
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
for _, language in ipairs(secondary) do
|
||||
local keys = {}
|
||||
|
||||
for line in io.lines(path:format(language)) do
|
||||
local key, value = line:match("^([^=]+)=(.*)$")
|
||||
if key then
|
||||
if keys[key] then
|
||||
io.stderr:write(("Duplicate keys for %q in %q\n"):format(key, language))
|
||||
os.exit(10)
|
||||
end
|
||||
|
||||
keys[key] = value
|
||||
elseif line ~= "" and line:sub(1, 1) ~= "#" then
|
||||
io.stderr:write(("Unknown line %q in %s\n"):format(line, language))
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
local h = io.open(path:format(language), "wb")
|
||||
local previous_blank = flase
|
||||
for _, line in ipairs(primary_contents) do
|
||||
if line == "" then
|
||||
if not previous_blank then
|
||||
previous_blank = true
|
||||
h:write("\n")
|
||||
end
|
||||
elseif line:sub(1, 1) == "#" then
|
||||
h:write(line .. "\n")
|
||||
previous_blank = false
|
||||
else
|
||||
local translated = keys[line]
|
||||
if translated then
|
||||
h:write(("%s=%s\n"):format(line, translated))
|
||||
keys[line] = nil
|
||||
previous_blank = false
|
||||
elseif verbose then
|
||||
io.stderr:write(("Missing translation %q for %q\n"):format(line, language))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if next(keys) ~= nil then
|
||||
local extra = {}
|
||||
for k, v in pairs(keys) do extra[#extra + 1] = ("%s=%s\n"):format(k, v) end
|
||||
table.sort(extra)
|
||||
|
||||
io.stderr:write(("%d additional unknown translation keys or %q\n"):format(#extra, language))
|
||||
|
||||
if not previous_blank then h:write("\n") end
|
||||
h:write("#Unknown translations\n")
|
||||
for _, line in ipairs(extra) do h:write(line) end
|
||||
end
|
||||
|
||||
h:close()
|
||||
end
|
Loading…
Reference in New Issue
Block a user