Let’s discuss a technical issue about WordPress and GlotPress. Tell me why themes, plugins, and readme.txt 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:
The Mechanism for Automatic Loading into GlotPress
- 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
- Automated Extraction Process
SVN Commit → Triggers Hook → Scans for file changes
↓
Detects readme.txt or code files
↓
Runs extraction tool (similar to wp i18n make-pot)
↓
Generates/Updates POT file
↓
Automatically imports into the GlotPress project
- Core Components
String Extraction:
- Specific fields in readme.txt (Plugin Name, Description, Tags, etc.)
- Internationalization functions in PHP code like
__(),_e(),esc_html__() - Functions in JavaScript like
wp.i18n.__()
GlotPress Integration:
- WordPress.org uses a custom integration layer to connect SVN and GlotPress
- Corresponding GlotPress projects are automatically created for each plugin/theme
- Project structure:
/plugins/plugin-slug/and/themes/theme-slug/
- Mechanism for Automatic Display After Translation
Building Language Packs:
Translators submit translations in GlotPress
↓
Approval threshold is reached (usually requires editor approval)
↓
Triggers automatic language pack build
↓
Generates .po and .mo files
↓
Packaged into ZIP (includes all translation domains)
↓
Deployed to translate.wordpress.org CDN
Automatic Download by WordPress Sites:
// WordPress core periodically checks
update_translations()
↓
Queries API: api.wordpress.org/translations/plugins/1.0/
↓
Detects available new language packs
↓
Downloads to wp-content/languages/plugins/
↓
Automatically loaded for use
- 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 files don’t exist locally, they are loaded from the 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
- Why is it Automatic?
Integration Levels:
- SVN → GlotPress: post-commit hooks
- GlotPress → Language Packs: cronjob builder
- 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 need to build the following components:
- Code Repository Hooks → Detect commits
- String Extractor → Parse POT
- GlotPress Integration → Automatic import/export
- Build Pipeline → Generate language packs
- Distribution API → Provide to clients
- Client Updater → Automatically download and load
This is a complete CI/CD + i18n automation system, with the core lying in event-driven automation and standardized file structure.