feat(i18n): implement dynamic system wording management
Add database schema and API endpoints for system wording keys and values Replace hardcoded translations in frontend and backend with dynamic messages Add System Wordings management interface to Admin view
This commit is contained in:
@@ -85,6 +85,39 @@ CREATE TABLE IF NOT EXISTS users (
|
||||
CHECK (length(display_name) BETWEEN 1 AND 40)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS system_wording_keys (
|
||||
key text PRIMARY KEY,
|
||||
module text NOT NULL,
|
||||
surface text NOT NULL CHECK (surface IN ('frontend', 'backend', 'email')),
|
||||
description text NOT NULL DEFAULT '',
|
||||
placeholders jsonb NOT NULL DEFAULT '[]'::jsonb CHECK (jsonb_typeof(placeholders) = 'array'),
|
||||
enabled boolean NOT NULL DEFAULT true,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
CHECK (key ~ '^[A-Za-z][A-Za-z0-9]*(\.[A-Za-z][A-Za-z0-9]*)+$'),
|
||||
CHECK (length(module) BETWEEN 1 AND 80)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS system_wording_keys_module_idx
|
||||
ON system_wording_keys(module, key);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS system_wording_keys_surface_idx
|
||||
ON system_wording_keys(surface, key);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS system_wording_values (
|
||||
key text NOT NULL REFERENCES system_wording_keys(key) ON DELETE CASCADE,
|
||||
locale text NOT NULL REFERENCES languages(code) ON DELETE CASCADE,
|
||||
value text NOT NULL CHECK (length(value) > 0),
|
||||
created_by_user_id integer REFERENCES users(id) ON DELETE SET NULL,
|
||||
updated_by_user_id integer REFERENCES users(id) ON DELETE SET NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (key, locale)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS system_wording_values_locale_idx
|
||||
ON system_wording_values(locale, key);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS email_verification_tokens (
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
user_id integer NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
|
||||
Reference in New Issue
Block a user