Skip to content

Develop#12

Open
Insality wants to merge 9 commits into
mainfrom
develop
Open

Develop#12
Insality wants to merge 9 commits into
mainfrom
develop

Conversation

@Insality

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings June 10, 2026 21:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the language module to support adding/merging localization “packs” at runtime, introduces a central registry for language sources and the current translation dictionary, and updates docs/tests to cover the new behavior.

Changes:

  • Add lang.load_langs(pack_id, langs, [on_lang_changed]) and a lang_registry that merges base + pack translations when switching/refreshing a language.
  • Add support for custom loader functions (intended for async/bundle/HTTP loading) and move logger functionality into lang/internal/lang_logger.lua.
  • Expand test coverage for pack loading/merging and add a sample pack JSON file; update README API docs accordingly.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/test_lang.lua Adds tests covering runtime pack loading (merge into current lang, add new lang, CSV pack).
resources/lang/en_pack.json Adds a small English “pack” translation file used by tests.
README.md Updates initialization/docs and adjusts set_lang signature; should also surface load_langs in the quick API list.
lang/lang.lua Introduces load_langs, routes language operations through lang_registry, and makes set_lang callback-based.
lang/lang_registry.lua New registry handling available languages, packs, merging, and optional async loaders.
lang/lang_internal.lua Refactors CSV parsing and adds helper utilities for format detection/merging/loading.
lang/internal/lang_logger.lua New logger module; needs a small safety fix for non-string keys in logged tables.
game.project Adds an HTML5 splash image configuration entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lang/lang_registry.lua
Comment on lines +54 to +59
function M.setup_langs(available_langs)
LANGS_ORDER = {}
AVAILABLE_LANGS_MAP = {}
LANG_DICT = {}

for _, lang_data in ipairs(available_langs) do
Comment thread lang/lang_registry.lua Outdated
Comment on lines +90 to +94
for _, pack_langs in pairs(LANG_PACKS) do
for _, lang_data in ipairs(pack_langs) do
if lang_data.id == lang_id then
table.insert(sources, lang_data)
end
Comment thread lang/lang_registry.lua
Comment on lines +146 to +150
for _, source in ipairs(async_sources) do
local path_str = source.path --[[@as string]]
source.loader(path_str, function(content)
local lang_table = lang_internal.parse_lang_content(content, lang_id, path_str)
if lang_table then
Comment thread lang/internal/lang_logger.lua Outdated
Comment on lines +54 to +60
if type(value) == "table" then
if depth == 0 then
local table_len = 0
for _ in pairs(value) do
table_len = table_len + 1
end
result = result .. key .. ": {... #" .. table_len .. "}"
Comment thread README.md
Comment on lines 181 to 183
lang.init(available_langs, [lang_on_start])
lang.set_lang(lang_id)
lang.set_lang(lang_id, [on_lang_changed])
lang.get_lang()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants