'https://aumcreate.com/manual/aumframe', 'zh-hans' => 'https://aumcreate.com/zh-hans/manual/aumframe', 'zh-hant' => 'https://aumcreate.com/zh-hant/manual/aumframe', 'ja' => 'https://aumcreate.com/ja/manual/aumframe', ]; /** * WordPress admin language → which of those four to send them to. Anything unlisted gets FALLBACK. * * The language of the prose and the language of the screenshots are two different things. * This plugin ships one translation, `zh_CN` (verified against 1.25.0's `languages/`: no `zh_TW`, * no `ja`, and WordPress does not fall `zh_TW` back to `zh_CN`). So a Traditional Chinese or * Japanese administrator is reading an English admin screen — and the manual's zh-hant and ja * pages are full translations of the prose that carry the English screenshots, which is what * matches what is actually on their screen. Sending them to the English page instead would be * worse, and sending zh_TW to zh-hans would be a guess. * * This table is deliberately data rather than an `if`: the gate reads it to check that every * value here is a key in URLS. A branch would have to be parsed as code, and the first version * of the gate did exactly that and had to be rewritten the day the branching changed. */ private const WP_TO_SITE = [ 'zh_CN' => 'zh-hans', 'zh_TW' => 'zh-hant', 'zh_HK' => 'zh-hant', 'ja' => 'ja', ]; private const FALLBACK = 'en'; /** * Which page this administrator gets. * * `get_user_locale()` rather than `get_locale()`: the Plugins screen is read in whatever language * that administrator set for themselves, which can differ from the site's. */ private static function locale(): string { return self::WP_TO_SITE[\get_user_locale()] ?? self::FALLBACK; } /** The URL for this administrator, or '' when the page is not published in their language. */ public static function url(): string { return self::URLS[self::locale()] ?? ''; } /** The row action on the Plugins screen. Adds nothing while the guide is unpublished. */ public static function action_link(array $links): array { $url = self::url(); if ($url === '') { return $links; } $links[] = sprintf( '%s', \esc_url($url), \esc_html__('Guide', 'aumframe') ); return $links; } }