feat(build): uniform ini parsing (#7429)

- Use the existing ini parser for the `lint-locale` and `lint-locale-usage` tooling.
- This discovered that the previous ini parser was not correctly parsing certain types of string, specifically those with `;` as it's seen as a comment. It now properly 'unescapes' that and is not seen as a comment break.
- Discovered-by: @fogti

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7429
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
Gusted 2025-04-03 08:27:02 +00:00 committed by Gusted
parent 4ab40ed6af
commit ba5b157f7e
2 changed files with 4 additions and 9 deletions

View file

@ -10,17 +10,12 @@ import (
"encoding/json" //nolint:depguard
"fmt"
"gopkg.in/ini.v1" //nolint:depguard
"forgejo.org/modules/setting"
)
func IterateMessagesContent(localeContent []byte, onMsgid func(string, string) error) error {
// Same configuration as Forgejo uses.
cfg := ini.Empty(ini.LoadOptions{
IgnoreContinuation: true,
})
cfg.NameMapper = ini.SnackCase
if err := cfg.Append(localeContent); err != nil {
cfg, err := setting.NewConfigProviderForLocale(localeContent)
if err != nil {
return err
}