label. * * @return array */ public static function languages(): array { /** * Filters the languages layouts can be translated into. * * The default language is not included — it is the layout as authored. * * @param array $languages code => label. */ return (array) apply_filters('aumframe/translatable_languages', []); } public static function assets(string $hook): void { if (strpos($hook, self::SLUG) === false) { return; } wp_enqueue_style( 'aumframe-admin', AUMFRAME_URL . 'assets/admin.css', ['dashicons'], aumframe_asset_ver('assets/admin.css') ); wp_enqueue_script( 'aumframe-i18n', AUMFRAME_URL . 'assets/i18n.js', ['wp-i18n'], aumframe_asset_ver('assets/i18n.js'), true ); Plugin::as_module('aumframe-i18n'); wp_set_script_translations('aumframe-i18n', 'aumframe', AUMFRAME_DIR . 'languages'); wp_add_inline_script( 'aumframe-i18n', 'window.AUMFRAME_I18N = ' . wp_json_encode([ 'restUrl' => esc_url_raw(rest_url(Rest::NS . '/i18n')), 'nonce' => wp_create_nonce('wp_rest'), /* * Same versioned url as the editor uses. `packages/core` is bare-URL ESM, so a change * there with an unchanged url leaves the browser baking with the old compiler — and the * output then disagrees with the front end while every file on the server is correct. */ 'coreUrl' => add_query_arg( 'ver', aumframe_module_ver(['assets/editor.js', 'packages/core/src']), AUMFRAME_URL . 'packages/core/src/index.js' ), 'languages' => self::languages(), ]) . ';', 'before' ); } public static function page(): void { $languages = self::languages(); ?>