Skip to content

Validate language code in XML files#529

Open
cammarosano wants to merge 5 commits intoalphafrom
alpha-validate_language_in_xml-rcdl
Open

Validate language code in XML files#529
cammarosano wants to merge 5 commits intoalphafrom
alpha-validate_language_in_xml-rcdl

Conversation

@cammarosano
Copy link
Copy Markdown
Collaborator

@cammarosano cammarosano commented Jan 24, 2026

Summary

Validate language codes in XML record definitions (field_name@lang_code form) against

  • known res.lang records
  • additional language codes added in the config

Details

  • Introduces a data hook system to track res.lang records, allowing the language server to maintain an up-to-date set of available language codes.
  • Introduces a new config key: "additional_languages".
  • When available language codes change (due to data files or config changes), dependent XML files are automatically rebuilt.
  • A new diagnostics is added: Warning when a language code doesn't match a known language code

@cammarosano cammarosano self-assigned this Jan 24, 2026
@cammarosano cammarosano force-pushed the alpha-validate_language_in_xml-rcdl branch 2 times, most recently from cbbc130 to d84085d Compare January 25, 2026 14:31


/// Evaluation of available languages is lazy and cached.
/// It assumes that res.lang.csv is the only source of 'res.lang' records
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@fda-odoo We have to discuss this.

@cammarosano cammarosano requested a review from fda-odoo January 25, 2026 15:35
@cammarosano cammarosano marked this pull request as draft January 27, 2026 16:02
@cammarosano cammarosano force-pushed the alpha-validate_language_in_xml-rcdl branch 2 times, most recently from b30bfce to d0a9706 Compare February 4, 2026 18:23
@cammarosano cammarosano force-pushed the alpha-validate_language_in_xml-rcdl branch from d0a9706 to 60790ad Compare February 11, 2026 14:58
This commit adds validation for language codes in the form of
"field_name@lang_code" in records definitions within XML files.

A warning is issued if the specified language code does not match one of
the known res.lang records.

In order to keep track of res.lang records, a data hook system has been
introduced (similar to python arch build and eval hooks). This allows
registering hooks for data file events, such as record creation and file
unload.

With these hooks, SyncOdoo maintains an up-to-date set of available
language codes. It also keeps track of XML file symbols whose validation
step depend on these language codes, and trigger their rebuild when the
set of language codes changes.
@cammarosano cammarosano force-pushed the alpha-validate_language_in_xml-rcdl branch from 12ad6d5 to 6a23ecf Compare February 13, 2026 13:52
@cammarosano cammarosano changed the title Language/translation validation in xml Validate language code in XML files Feb 13, 2026
@cammarosano cammarosano marked this pull request as ready for review February 13, 2026 15:12
In case someone wants to add support for a language that doesn't have a
corresponding res.lang record in the data files, they can now add it to
the additional_languages config option.

This allows the added language to be recognized as valid and prevents a
warning for unknown language code in field@lang translations in XML
files.

Lists of language codes added in different config files are merged
together.
This commits factors out the config update handling logic from
`Odoo::check_handle_config_file_update` into a dedicated
`Odoo::handle_config_update`.

This has two benefits:
- better separation of concerns (one handles the config **file** update,
while the other handles the replacement of the current config with a new
ConfigEntry)
- it allows for easier testing of config updates without needing to go
through the file update logic

Based on this, this commit introduces a test for checking whether the
OLS05058 diagnostic (unknown language code) is refreshed correctly when
the additional_languages config is updated.
@cammarosano cammarosano force-pushed the alpha-validate_language_in_xml-rcdl branch from 6a23ecf to 47817ba Compare February 16, 2026 17:06
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.

1 participant