Why can themes/plugins and readme.txt from WordPress.org be automatically loaded into GlotPress?

Let’s discuss a technical issue regarding WordPress and GlotPress. You tell me why the theme/plugin and readme.txt files on WordPress.org can be automatically loaded into GlotPress projects and displayed after translation?

This is a meticulously designed automated process within the WordPress.org ecosystem. Let me explain how it works:

Mechanism for Automatic Loading into GlotPress

  1. SVN Hook Monitoring
    When plugin/theme developers commit code to the WordPress.org SVN repository:

    • The SVN server is configured with post-commit hooks.
    • These hooks trigger automated scripts to detect new commits.
  2. Automatic Extraction Process

    SVN Commit → Triggers Hook → Scans file changes
          ↓
    Detects readme.txt or code files
          ↓
    Runs extraction tool (similar to wp i18n make-pot)
          ↓
    Generates/Updates POT file
          ↓
    Automatically imports into GlotPress project
    
  3. Core Components
    String Extraction:

    • Specific fields in readme.txt (Plugin Name, Description, Tags, etc.)
    • Internationalization functions in PHP code like __(), _e(), esc_html__()
    • Functions like wp.i18n.__() in JavaScript

    GlotPress Integration:

    • WordPress.org uses a custom integration layer connecting SVN and GlotPress.
    • Corresponding GlotPress projects are automatically created for each plugin/theme.
    • Project structure: /plugins/plugin-slug/ and /themes/theme-slug/
  4. Automatic Display Mechanism After Translation
    Building Language Packs:

    Translators submit translations in GlotPress
          ↓
    Approval threshold is met (usually requires editor approval)
          ↓
    Automatically triggers language pack build
          ↓
    Generates .po and .mo files
          ↓
    Packages into ZIP (includes all translation domains)
          ↓
    Deploys to translate.wordpress.org CDN
    

    Automatic Download by WordPress Sites:

    // WordPress core checks periodically
    update_translations()
          ↓
    Queries API: api.wordpress.org/translations/plugins/1.0/
          ↓
    Detects available new language packs
          ↓
    Downloads to wp-content/languages/plugins/
          ↓
    Automatically loads and uses them
    
  5. Key Technical Points
    API Endpoints:

    • https://api.wordpress.org/translations/plugins/1.0/?slug={plugin-slug}&version={version}
    • Returns metadata for all available language packs for that plugin.

    Automatic Loading Logic:

    // WordPress core when loading a plugin
    load_plugin_textdomain('plugin-slug', false, dirname(plugin_basename(__FILE__)) . '/languages');
    // If translation file doesn't exist locally, loads from CDN
    // wp-content/languages/plugins/plugin-slug-zh_CN.mo
    

    Update Frequency:

    • Language pack build: Within minutes after translation approval.
    • WordPress update check: Every 12 hours (via wp-cron).
    • Can also be triggered manually: Dashboard → Updates.
  6. Why is it Automatic?
    Integration Layers:

    1. SVN → GlotPress: post-commit hooks
    2. GlotPress → Language Packs: cronjob builders
    3. Language Packs → WordPress: core update mechanism

    WordPress.org Privileges:

    • This system is part of the official WordPress.org infrastructure.
    • Uses internal APIs and direct database access.
    • Not implemented via public APIs.

If You Want to Implement a Similar System

You would need to build the following components:

  1. Code Repository Hook → Detects commits
  2. String Extractor → Parses POT
  3. GlotPress Integration → Automatic import/export
  4. Build Pipeline → Generates language packs
  5. Distribution API → Serves to clients
  6. Client Updater → Automatically downloads and loads

This is a complete CI/CD + i18n automation system. Its core lies in event-driven automation and a standardized file structure.