package models

import "odoo-go/pkg/orm"

// initIrTranslation registers ir.translation — Translation storage.
// Mirrors: odoo/addons/base/models/ir_translation.py class IrTranslation
//
// Stores translated strings for model fields, code terms, and structured terms.
// The web client loads translations via /web/webclient/translations and uses them
// to render UI elements in the user's language.
func initIrTranslation() {
	m := orm.NewModel("ir.translation", orm.ModelOpts{
		Description: "Translation",
		Order:       "lang, name",
	})

	m.AddFields(
		orm.Char("name", orm.FieldOpts{String: "Translated field", Required: true, Index: true}),
		orm.Char("res_id", orm.FieldOpts{String: "Record ID"}),
		orm.Char("lang", orm.FieldOpts{String: "Language", Required: true, Index: true}),
		orm.Selection("type", []orm.SelectionItem{
			{Value: "model", Label: "Model Field"},
			{Value: "model_terms", Label: "Structured Model Field"},
			{Value: "code", Label: "Code"},
		}, orm.FieldOpts{String: "Type", Index: true}),
		orm.Text("src", orm.FieldOpts{String: "Source"}),
		orm.Text("value", orm.FieldOpts{String: "Translation Value"}),
		orm.Char("module", orm.FieldOpts{String: "Module"}),
		orm.Selection("state", []orm.SelectionItem{
			{Value: "to_translate", Label: "To Translate"},
			{Value: "translated", Label: "Translated"},
		}, orm.FieldOpts{String: "Status", Default: "to_translate"}),
	)
}
