Support Log in

28. Database Schema

Developer Guide
Prefer video? Watch the Lang Forge tutorials 9 short guides covering every feature Watch

Lang Forge creates five custom tables on activation. All table names use the WordPress table prefix (typically wp_). Understanding the schema is important for writing custom queries, building reports, and debugging translation issues.

wp_langforge_translations

Stores the relationship between posts and their translations. This is the core table that links posts across languages.

sql
CREATE TABLE wp_langforge_translations (
    id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    element_id bigint(20) unsigned NOT NULL,
    element_type varchar(60) NOT NULL DEFAULT 'post',
    translation_group bigint(20) unsigned NOT NULL,
    language_code varchar(10) NOT NULL,
    source_language_code varchar(10) DEFAULT NULL,
    PRIMARY KEY (id),
    UNIQUE KEY element_language (element_id, element_type, language_code),
    KEY translation_group (translation_group),
    KEY language_code (language_code)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Columns:
ColumnTypeNullableDescription
idbigintNoAuto-increment primary key
element_idbigintNoWordPress post ID
element_typevarchar(60)NoPost type slug (e.g., post, page, product)
translation_groupbigintNoGroups translations of the same content together
language_codevarchar(10)NoLanguage code (e.g., en, ru)
source_language_codevarchar(10)YesLanguage of the original post (nullable)
Example queries:
sql
-- Find all translations of post #42
SELECT t2.element_id, t2.language_code
FROM wp_langforge_translations t1
JOIN wp_langforge_translations t2 ON t1.translation_group = t2.translation_group
WHERE t1.element_id = 42;

-- Find posts that have no English translation
SELECT t1.element_id, t1.language_code
FROM wp_langforge_translations t1
WHERE t1.translation_group NOT IN (
    SELECT translation_group FROM wp_langforge_translations WHERE language_code = 'en'
)
AND t1.language_code = 'ru';

-- Count translations per language for a post type
SELECT language_code, COUNT(*) as post_count
FROM wp_langforge_translations
WHERE element_type = 'post'
GROUP BY language_code;

wp_langforge_strings

Stores registered strings and their translations. The domain and the name of a string are compared byte for byte (a binary collation of the character set of the site, utf8mb4_bin on most sites), so names that differ only in letter case or accent, such as “Size” and “size”, are separate strings, each with its own translation for every language. On a table made by an earlier version, Lang Forge changes the key once, when an administrator opens an admin page; a table of more than 500,000 rows is left as it was until you run wp langforge strings-key --yes.

sql
CREATE TABLE wp_langforge_strings (
    id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    string_domain varchar(160) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 'default',
    string_name varchar(160) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
    string_value text NOT NULL,
    string_language varchar(10) NOT NULL,
    status tinyint(1) NOT NULL DEFAULT 0,
    PRIMARY KEY (id),
    UNIQUE KEY string_key (string_domain, string_name, string_language),
    KEY string_domain (string_domain),
    KEY string_language (string_language)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

wp_langforge_translation_memory (PRO)

Stores previously translated segments for reuse.

sql
CREATE TABLE wp_langforge_translation_memory (
    id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    source_text text NOT NULL,
    source_hash varchar(64) NOT NULL,
    translated_text text NOT NULL,
    source_lang varchar(10) NOT NULL,
    target_lang varchar(10) NOT NULL,
    context varchar(255) DEFAULT '',
    usage_count int(11) NOT NULL DEFAULT 1,
    created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    UNIQUE KEY source_target (source_hash, source_lang, target_lang),
    KEY langs (source_lang, target_lang),
    KEY usage_count (usage_count)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

wp_langforge_glossary (Free)

Brand terminology dictionary for translation consistency.

sql
CREATE TABLE wp_langforge_glossary (
    id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    source_term varchar(255) NOT NULL,
    translated_term varchar(255) NOT NULL DEFAULT '',
    source_lang varchar(10) NOT NULL,
    target_lang varchar(10) NOT NULL,
    description text,
    do_not_translate tinyint(1) NOT NULL DEFAULT 0,
    case_sensitive tinyint(1) NOT NULL DEFAULT 0,
    created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    UNIQUE KEY term_pair (source_term(191), source_lang, target_lang),
    KEY source_lang (source_lang),
    KEY target_lang (target_lang)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

wp_langforge_analytics (PRO)

Tracks translation events for the analytics dashboard.

sql
CREATE TABLE wp_langforge_analytics (
    id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    event_type varchar(50) NOT NULL,
    post_id bigint(20) unsigned DEFAULT 0,
    language_code varchar(10) NOT NULL DEFAULT '',
    user_id bigint(20) unsigned DEFAULT 0,
    created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    meta text,
    PRIMARY KEY (id),
    KEY event_type (event_type, created_at),
    KEY language_code (language_code, created_at),
    KEY user_id (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

—

Forge AI Assistant Online

Hi! I'm the Lang Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs