Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.

### Changed
- License changed from GPL-2.0-or-later to MIT.
- Translations now load from the central `escalated-dev/locale` Composer package (`vendor/escalated-dev/locale/languages/escalated-{locale}.mo`) with optional site-level overrides from `languages/overrides/escalated-{locale}.mo`. Falls back to the in-tree `languages/` dir when the central package is not installed.

### Fixed
- Validate priority against allowed enum values in ticket creation.
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,30 @@ On activation, Escalated schedules:
- `escalated_auto_close` (daily)
- `escalated_purge_activities` (weekly)

## Translations

Escalated for WordPress consumes translations from the central
[`escalated-dev/locale`](https://github.com/escalated-dev/escalated-locale)
Composer package, which is the single source of truth for translations
across every Escalated host plugin.

At runtime the plugin loads translations in two layers (later layer wins):

1. **Central** — `vendor/escalated-dev/locale/languages/escalated-{locale}.mo`
(installed automatically via `composer install`).
2. **Local overrides** — `languages/overrides/escalated-{locale}.mo`
(drop your own compiled `.mo` here to override individual entries
without forking the central package).

If the central package is not yet installed, the plugin falls back to
the legacy in-tree `languages/*.po`/`*.mo` files so existing sites keep
working.

To submit translation fixes, open a PR against
[`escalated-dev/escalated-locale`](https://github.com/escalated-dev/escalated-locale).
Do **not** edit the in-tree `.po` files — they exist only as a fallback
and will be removed once the central package reaches a stable release.

## Development

Install dependencies:
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"description": "Escalated Helpdesk & Ticketing System for WordPress",
"type": "wordpress-plugin",
"license": "MIT",
"repositories": [
{"type": "vcs", "url": "https://github.com/escalated-dev/escalated-locale"}
],
"require": {
"php": ">=8.1"
"php": ">=8.1",
"escalated-dev/locale": "^0.1"
},
"require-dev": {
"phpunit/phpunit": "^9.6",
Expand Down
46 changes: 44 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 40 additions & 1 deletion includes/class-escalated.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static function instance(): self

public function boot(): void
{
load_plugin_textdomain('escalated', false, dirname(ESCALATED_PLUGIN_BASENAME).'/languages');
$this->load_translations();

// Register custom cron intervals.
add_filter('cron_schedules', [Activator::class, 'add_cron_schedules']);
Expand Down Expand Up @@ -51,4 +51,43 @@ public static function table(string $name): string

return $wpdb->prefix.'escalated_'.$name;
}

/**
* Load plugin translations.
*
* Loads translations in two layers, with WordPress's gettext system
* merging them so the later-loaded layer can override earlier entries:
*
* 1. Central translations from the `escalated-dev/locale` Composer
* package (vendor/escalated-dev/locale/languages/escalated-{locale}.mo).
* Source of truth, shared across all Escalated host plugins.
* 2. Local overrides from this plugin's `languages/overrides/` dir
* (escalated-{locale}.mo), giving site operators a way to tweak
* strings without forking the central package.
*
* If the central package is not installed (e.g. fresh checkout before
* `composer install`), we fall back to the legacy `languages/` dir so
* existing installs continue to work.
*/
private function load_translations(): void
{
$domain = 'escalated';
$locale = determine_locale();
$mofile = $domain.'-'.$locale.'.mo';

// 1. Central translations shipped by escalated-dev/locale.
$central = ESCALATED_PLUGIN_DIR.'vendor/escalated-dev/locale/languages/'.$mofile;
if (file_exists($central)) {
load_textdomain($domain, $central);
} else {
// Fallback to the legacy in-plugin languages/ dir (pre-central rollout).
load_plugin_textdomain($domain, false, dirname(ESCALATED_PLUGIN_BASENAME).'/languages');
}

// 2. Local overrides — entries here win over the central package.
$overrides = ESCALATED_PLUGIN_DIR.'languages/overrides/'.$mofile;
if (file_exists($overrides)) {
load_textdomain($domain, $overrides);
}
}
}
Empty file added languages/overrides/.gitkeep
Empty file.