mirror of
https://github.com/LamGC/wp-asciiplayer.git
synced 2026-11-27 05:05:50 +00:00
Compare commits
3
Commits
85474494b1
...
9f026221f2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f026221f2 | ||
|
|
3b2b213b6f | ||
|
|
41395f4102 |
@@ -73,10 +73,19 @@ jobs:
|
||||
npx --no-install wp-env run cli wp plugin is-active wp-asciiplayer
|
||||
npx --no-install wp-env run cli wp core version | tee wordpress-version.txt
|
||||
npx --no-install wp-env run cli wp plugin list
|
||||
npx --no-install wp-env run cli wp language core install zh_CN
|
||||
npx --no-install wp-env run cli wp site switch-language en_US
|
||||
npx --no-install wp-env run cli wp user meta update admin locale en_US
|
||||
- name: Install Chromium
|
||||
run: npx --no-install playwright install --with-deps chromium
|
||||
- name: Exercise editor iframe, saved blocks, Pages, posts and legacy shortcodes
|
||||
run: npm run test:e2e
|
||||
env:
|
||||
PLAYWRIGHT_HTML_OUTPUT_DIR: playwright-report/en-US
|
||||
run: npm run test:e2e -- --grep-invert @i18n --output=test-results/en-US
|
||||
- name: Exercise real en_US and zh_CN site and user locale combinations
|
||||
env:
|
||||
PLAYWRIGHT_HTML_OUTPUT_DIR: playwright-report/i18n
|
||||
run: npm run test:e2e -- --grep @i18n --output=test-results/i18n
|
||||
- name: Run Plugin Check (advisory until directory review)
|
||||
if: always() && matrix.wordpress == 'latest'
|
||||
continue-on-error: true
|
||||
|
||||
+16
-2
@@ -3,6 +3,18 @@
|
||||
为 WordPress 提供原生 Asciicast Player 区块,可在编辑器内真实播放终端录屏,
|
||||
同时兼容原有 `[asciiplayer]` shortcode。
|
||||
|
||||
## 开发预览:1.1.0-dev
|
||||
|
||||
当前 PR 为尚未发布的开发预览。此前安装包的 1.1.0、1.2.0–1.2.3 仅为迭代标记,不代表正式发布。
|
||||
供测试的安装包使用 `wp-asciiplayer-1.1.0-dev-<提交号>.zip` 命名;不会自动创建发布标签或部署。
|
||||
|
||||
## 界面语言
|
||||
|
||||
插件自己的界面支持英文和简体中文(`zh_CN`)。编辑器跟随「用户 → 个人资料 → 语言」
|
||||
(未单独设置时跟随站点),前台跟随「设置 → 常规 → 站点语言」。翻译文件随安装包附带,可离线使用。
|
||||
英文为默认回退语言。不会把 `zh_TW` 等其他中文地区设置自动映射为简体中文。
|
||||
录屏中的终端内容和作者填写的说明文字不会被翻译。上游播放器自身的播放控件和帮助仍为英文,播放器文件保持原样。
|
||||
|
||||
## 安装与使用
|
||||
|
||||
将构建得到的 `wp-asciiplayer.zip` 上传到「插件 → 安装插件 → 上传插件」并启用。
|
||||
@@ -53,10 +65,12 @@ URL 必须指向录制文件(例如 `.cast`),不能直接使用分享页
|
||||
|
||||
本插件保持 GPL-3.0-only,播放器及依赖保留各自的兼容许可证。
|
||||
|
||||
### 素材库与原始终端尺寸(1.2.2)
|
||||
### 媒体库与原始终端尺寸
|
||||
|
||||
点击区块中的 **Choose recording** 可通过 WordPress 素材库选择或上传 `.cast` 录制文件。上传权限沿用 WordPress 的 `upload_files` 能力,不会为低权限用户开放上传。插件仅为经过格式校验的 `.cast` 文件添加支持,不放开任意 JSON、HTML 或 SVG。
|
||||
点击区块中的 **选择录制文件(Choose recording)** 可通过 WordPress 媒体库选择或上传 `.cast` 录制文件。上传权限沿用 WordPress 的 `upload_files` 能力,不会为低权限用户开放上传。插件仅为经过格式校验的 `.cast` 文件添加支持,不放开任意 JSON、HTML 或 SVG。
|
||||
|
||||
浮动工具栏和折叠侧栏中的 Columns / Rows 留空时,会在录制加载后显示原始终端尺寸作为占位提示。更换 URL 会刷新提示,但保留你明确填写的覆盖值;恢复录制尺寸会清空覆盖值,继续尊重录制中的尺寸变化。未知或加载失败时不猜测尺寸。
|
||||
|
||||
上传文件会完整校验:最多 32 MiB、100,000 个事件或流内行、每条 JSONL 行 256 KiB、终端任一方向不超过 1,000。旧版 v1 最多 2 MiB,需使用起始 `{` 单独一行的格式化 JSON;内置播放器不支持压成一行的 v1。v2/v3 使用标准 JSONL。站点和服务器更低的上传限制仍生效,多站点还需网络允许 `cast` 扩展名。原始尺寸提示只检查同一次预览响应的前 64 KiB,无法读取时保留通用提示。
|
||||
|
||||
区块内常驻的录制/隐私说明和播放操作说明位于侧栏默认折叠的 **帮助(Help)** 面板,保留标题、错误提示和必要控件标签。
|
||||
|
||||
@@ -3,6 +3,23 @@
|
||||
An Asciicast Player block for WordPress, with real playback in the editor and
|
||||
backwards-compatible `[asciiplayer]` shortcodes. [中文说明](README-zh.md)
|
||||
|
||||
## Development preview: 1.1.0-dev
|
||||
|
||||
This PR is an unreleased development preview. Earlier draft ZIP labels 1.1.0 and
|
||||
1.2.0–1.2.3 were iteration labels, not published releases. Review packages use
|
||||
`wp-asciiplayer-1.1.0-dev-<commit>.zip`; no release tag or deployment is implied.
|
||||
|
||||
## Languages
|
||||
|
||||
Plugin-owned UI includes English and Simplified Chinese (`zh_CN`). The editor
|
||||
follows **Users → Profile → Language** (or the site default); public pages follow
|
||||
**Settings → General → Site Language**. Catalogs ship inside the ZIP and need no
|
||||
translation server at runtime. English is the source/fallback language, so a
|
||||
separate `en_US` catalog is unnecessary. `zh_TW` and other locales are not silently
|
||||
mapped to Simplified Chinese. Recorded terminal output and author captions stay
|
||||
unchanged. The bundled upstream player's own playback controls and help remain
|
||||
English; its vendor files are not modified.
|
||||
|
||||
## Install
|
||||
|
||||
Install the built `wp-asciiplayer.zip` through **Plugins → Add New → Upload
|
||||
@@ -36,6 +53,8 @@ Existing saved blocks load their valid recording URL automatically on reopening
|
||||
the editor. Typed URL changes are debounced for 500ms; empty or invalid URLs do
|
||||
not start a recording request.
|
||||
Preview does not autoplay even when front-end autoplay is enabled.
|
||||
Recording/privacy and playback explanations are available in the collapsed
|
||||
**Help** sidebar panel, keeping the block canvas focused on editing.
|
||||
The inserter preview is a local static example and never loads a recording.
|
||||
|
||||
Terminal typography is scoped against common theme `pre`/`span` styles so
|
||||
|
||||
@@ -33,3 +33,28 @@ Chromium; the repository CI records the exact WordPress version under test and
|
||||
installs the release ZIP into the test site before checking it. Refer to the
|
||||
workflow for setup details. Running a unit test is not a substitute for the
|
||||
WordPress browser integration suite.
|
||||
|
||||
## Translation maintenance
|
||||
|
||||
The English gettext strings are the fallback. Edit `languages/wp-asciiplayer-zh_CN.po`
|
||||
to maintain Simplified Chinese; `npm run i18n` extracts the current static PHP/JS
|
||||
and block-metadata strings into the POT and compiles the MO and WordPress Jed JSON.
|
||||
`npm run i18n:check` fails for missing/fuzzy translations, stale generated files,
|
||||
unsupported plural extraction, and mismatched printf placeholders. Build runs
|
||||
compilation and tests check it reproducibly, without a network service or timestamps.
|
||||
For new strings, run `node scripts/i18n.mjs --pot-only`, merge into the maintained
|
||||
PO with a gettext editor, translate, and run `npm run i18n` again.
|
||||
|
||||
JSON files use WordPress's supported domain-locale-script-handle names for the
|
||||
actual `lamgc-asciiplayer-editor` and `lamgc-asciiplayer-view` handles. The editor
|
||||
bundle has no lazy translated chunks. `wp_set_script_translations` registers both
|
||||
paths after scripts; PHP registers `load_plugin_textdomain` during `init`, before
|
||||
block metadata is translated. The generated assets and all catalogs are packaged.
|
||||
The upstream vendor bundle is byte-for-byte unchanged and its own controls remain
|
||||
English. Runtime JS/CSS versions use build content hashes even though the preview
|
||||
package version stays `1.1.0-dev`.
|
||||
|
||||
References:
|
||||
- https://developer.wordpress.org/reference/functions/wp_set_script_translations/
|
||||
- https://developer.wordpress.org/reference/functions/load_script_textdomain/
|
||||
- https://developer.wordpress.org/reference/functions/load_plugin_textdomain/
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
* Plugin Name: Asciicast Player
|
||||
* Plugin URI: https://github.com/LamGC/wp-asciiplayer
|
||||
* Description: Add interactive terminal recordings to posts and pages with a block or shortcode.
|
||||
* Version: 1.2.2
|
||||
* Version: 1.1.0-dev
|
||||
* Requires at least: 6.3
|
||||
* Requires PHP: 7.4
|
||||
* Author: LamGC
|
||||
* Author URI: https://blog.lamgc.moe
|
||||
* License: GPL-3.0-only
|
||||
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
* Domain Path: /languages
|
||||
* Text Domain: wp-asciiplayer
|
||||
*
|
||||
* @package LamGC\Asciiplayer
|
||||
@@ -21,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
const VERSION = '1.2.2';
|
||||
const VERSION = '1.1.0-dev';
|
||||
const PLUGIN_FILE = __FILE__;
|
||||
const SHORTCODE = 'asciiplayer';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "lamgc/asciiplayer",
|
||||
"version": "1.2.2",
|
||||
"version": "1.1.0-dev",
|
||||
"title": "Asciicast Player",
|
||||
"category": "media",
|
||||
"icon": "editor-code",
|
||||
|
||||
+9
-6
@@ -17,6 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
* @return void
|
||||
*/
|
||||
function register_plugin() {
|
||||
load_plugin_textdomain( 'wp-asciiplayer', false, dirname( plugin_basename( PLUGIN_FILE ) ) . '/languages' );
|
||||
$base = plugin_dir_url( PLUGIN_FILE ) . 'build/';
|
||||
$asset = array(
|
||||
'dependencies' => array( 'wp-blocks', 'wp-element', 'wp-block-editor', 'wp-components', 'wp-i18n' ),
|
||||
@@ -31,7 +32,9 @@ function register_plugin() {
|
||||
$view_asset = require dirname( PLUGIN_FILE ) . '/build/view.asset.php';
|
||||
}
|
||||
|
||||
wp_register_script( 'lamgc-asciiplayer-player', $base . 'player.js', array(), VERSION, true );
|
||||
$versions = file_exists( dirname( PLUGIN_FILE ) . '/build/runtime.asset.php' ) ? require dirname( PLUGIN_FILE ) . '/build/runtime.asset.php' : array();
|
||||
$player_version = $versions['player.js'] ?? VERSION;
|
||||
wp_register_script( 'lamgc-asciiplayer-player', $base . 'player.js', array(), $player_version, true );
|
||||
wp_register_script(
|
||||
'lamgc-asciiplayer-view',
|
||||
$base . 'view.js',
|
||||
@@ -46,16 +49,16 @@ function register_plugin() {
|
||||
$asset['version'],
|
||||
true
|
||||
);
|
||||
wp_register_style( 'lamgc-asciiplayer-player-style', $base . 'player.css', array(), VERSION );
|
||||
wp_register_style( 'lamgc-asciiplayer-style', $base . 'style-index.css', array( 'lamgc-asciiplayer-player-style' ), VERSION );
|
||||
wp_register_style( 'lamgc-asciiplayer-editor-style', $base . 'index.css', array( 'lamgc-asciiplayer-player-style' ), VERSION );
|
||||
wp_register_style( 'lamgc-asciiplayer-player-style', $base . 'player.css', array(), $versions['player.css'] ?? VERSION );
|
||||
wp_register_style( 'lamgc-asciiplayer-style', $base . 'style-index.css', array( 'lamgc-asciiplayer-player-style' ), $versions['style-index.css'] ?? VERSION );
|
||||
wp_register_style( 'lamgc-asciiplayer-editor-style', $base . 'index.css', array( 'lamgc-asciiplayer-player-style' ), $versions['index.css'] ?? VERSION );
|
||||
|
||||
wp_add_inline_script(
|
||||
'lamgc-asciiplayer-editor',
|
||||
'window.wpAsciiplayerSettings = ' . wp_json_encode(
|
||||
array(
|
||||
'playerScriptUrl' => add_query_arg( 'ver', VERSION, $base . 'player.js' ),
|
||||
'playerStyleUrl' => add_query_arg( 'ver', VERSION, $base . 'player.css' ),
|
||||
'playerScriptUrl' => add_query_arg( 'ver', $player_version, $base . 'player.js' ),
|
||||
'playerStyleUrl' => add_query_arg( 'ver', $versions['player.css'] ?? VERSION, $base . 'player.css' ),
|
||||
),
|
||||
JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT
|
||||
) . ';',
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
{
|
||||
"domain": "wp-asciiplayer",
|
||||
"locale_data": {
|
||||
"messages": {
|
||||
"": {
|
||||
"domain": "wp-asciiplayer",
|
||||
"lang": "zh_CN",
|
||||
"plural-forms": "nplurals=1; plural=0;"
|
||||
},
|
||||
"Columns": [
|
||||
"列数"
|
||||
],
|
||||
"From recording": [
|
||||
"使用录制尺寸"
|
||||
],
|
||||
"Rows": [
|
||||
"行数"
|
||||
],
|
||||
"Placeholders show the recording’s original columns and rows once loaded. Leave blank to follow its terminal size and recorded resize events. These overrides change the character grid, not the display width, and may alter or crop the layout.": [
|
||||
"加载后,占位提示会显示录制文件的原始行列数。留空可使用录制尺寸,并跟随录制中的尺寸变化。手动设置会改变字符网格,而非显示宽度,可能影响排版或裁切内容。"
|
||||
],
|
||||
"Use recording size": [
|
||||
"使用录制尺寸"
|
||||
],
|
||||
"Asciinema": [
|
||||
"Asciinema"
|
||||
],
|
||||
"Recording theme (automatic)": [
|
||||
"录制文件主题(自动)"
|
||||
],
|
||||
"Custom": [
|
||||
"自定义"
|
||||
],
|
||||
"Width": [
|
||||
"按宽度缩放"
|
||||
],
|
||||
"Original size": [
|
||||
"原始大小"
|
||||
],
|
||||
"Height (legacy)": [
|
||||
"按高度缩放(旧版)"
|
||||
],
|
||||
"Width and height (legacy)": [
|
||||
"按宽高缩放(旧版)"
|
||||
],
|
||||
"Example terminal recording": [
|
||||
"终端录屏示例"
|
||||
],
|
||||
"A terminal recording, right in your post.": [
|
||||
"在文章中直接播放终端录屏。"
|
||||
],
|
||||
"Terminal size": [
|
||||
"终端尺寸"
|
||||
],
|
||||
"Terminal size (columns × rows)": [
|
||||
"终端尺寸(列数 × 行数)"
|
||||
],
|
||||
"Close": [
|
||||
"关闭"
|
||||
],
|
||||
"Display": [
|
||||
"显示"
|
||||
],
|
||||
"Player width": [
|
||||
"播放器宽度"
|
||||
],
|
||||
"Custom width": [
|
||||
"自定义宽度"
|
||||
],
|
||||
"Use a CSS length, such as 480px or 65%. The player stays within its available space.": [
|
||||
"使用 CSS 长度,例如 480px 或 65%。播放器不会超出可用空间。"
|
||||
],
|
||||
"Enter a positive width with a unit, such as 480px or 65%. The last valid width is kept.": [
|
||||
"请输入带单位的正数宽度,例如 480px 或 65%。将保留上一次有效的宽度。"
|
||||
],
|
||||
"Display alignment": [
|
||||
"对齐方式"
|
||||
],
|
||||
"Left": [
|
||||
"左对齐"
|
||||
],
|
||||
"Center": [
|
||||
"居中"
|
||||
],
|
||||
"Right": [
|
||||
"右对齐"
|
||||
],
|
||||
"Display width scales the recording without changing its terminal columns or rows. Add a caption directly below the player.": [
|
||||
"显示宽度只缩放画面,不改变终端行列数。可在播放器下方直接添加说明文字。"
|
||||
],
|
||||
"Playback": [
|
||||
"播放"
|
||||
],
|
||||
"Playback speed": [
|
||||
"播放速度"
|
||||
],
|
||||
"Loop playback": [
|
||||
"循环播放"
|
||||
],
|
||||
"Autoplay on published page": [
|
||||
"在发布后的页面自动播放"
|
||||
],
|
||||
"The editor preview always waits for you to press play.": [
|
||||
"编辑器预览始终需要点击播放后才会开始。"
|
||||
],
|
||||
"Preload on published page": [
|
||||
"在发布后的页面预加载"
|
||||
],
|
||||
"Loads the recording before the visitor presses play. The editor preview always preloads a valid recording URL.": [
|
||||
"在访客点击播放前加载录制文件。编辑器预览始终会预加载有效的录制文件 URL。"
|
||||
],
|
||||
"Start at (seconds)": [
|
||||
"起始时间(秒)"
|
||||
],
|
||||
"Idle time limit (seconds)": [
|
||||
"最长空闲时间(秒)"
|
||||
],
|
||||
"Shorten long pauses. Use 0 to keep the recording’s default.": [
|
||||
"缩短过长的停顿。设为 0 可保留录制文件的默认设置。"
|
||||
],
|
||||
"Appearance": [
|
||||
"外观"
|
||||
],
|
||||
"Theme": [
|
||||
"主题"
|
||||
],
|
||||
"Player controls": [
|
||||
"播放控制栏"
|
||||
],
|
||||
"Show on interaction": [
|
||||
"交互时显示"
|
||||
],
|
||||
"Always show": [
|
||||
"始终显示"
|
||||
],
|
||||
"Hide": [
|
||||
"隐藏"
|
||||
],
|
||||
"Fit": [
|
||||
"缩放方式"
|
||||
],
|
||||
"Height-based fitting requires a fixed container height in your site CSS.": [
|
||||
"按高度缩放需要在站点 CSS 中设置固定的容器高度。"
|
||||
],
|
||||
"The custom container style from your shortcode is preserved on the published page.": [
|
||||
"发布后的页面会保留简码中的自定义容器样式。"
|
||||
],
|
||||
"Help": [
|
||||
"帮助"
|
||||
],
|
||||
"A valid recording URL loads its preview automatically, including when reopening this editor. That server receives your browser’s request. Published players contact the same server. Use a direct .cast URL; external servers must allow CORS.": [
|
||||
"有效的录制文件 URL 会自动加载预览,重新打开编辑器时也一样。文件所在服务器会收到浏览器请求,发布后的播放器也会访问该服务器。请使用 .cast 文件直链;外部服务器需允许跨域请求(CORS)。"
|
||||
],
|
||||
"Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.": [
|
||||
"使用播放器控件播放、暂停和跳转。仅编辑器预览禁用自动播放。"
|
||||
],
|
||||
"Recording URL": [
|
||||
"录制文件 URL"
|
||||
],
|
||||
"Apply URL": [
|
||||
"应用 URL"
|
||||
],
|
||||
"Choose an Asciicast recording": [
|
||||
"选择 Asciicast 录制文件"
|
||||
],
|
||||
"Choose recording": [
|
||||
"选择录制文件"
|
||||
],
|
||||
"Choose an Asciicast (.cast) file from the Media Library.": [
|
||||
"请从媒体库选择 Asciicast(.cast)文件。"
|
||||
],
|
||||
"Enter an HTTP(S) recording URL or a path starting with a single /.": [
|
||||
"请输入 HTTP(S) 录制文件 URL,或以单个 / 开头的路径。"
|
||||
],
|
||||
"Asciicast Player": [
|
||||
"Asciicast 播放器"
|
||||
],
|
||||
"Enter a recording URL to load its preview automatically. Playback starts only when you press play.": [
|
||||
"输入录制文件 URL 后会自动加载预览,点击播放才会开始播放。"
|
||||
],
|
||||
"Add a caption…": [
|
||||
"添加说明文字…"
|
||||
],
|
||||
"Recording caption": [
|
||||
"录屏说明文字"
|
||||
],
|
||||
"Height-based previews use the shortcode’s fixed height when available, or a 320px editor frame. Published height still comes from your container style.": [
|
||||
"按高度缩放的预览会使用简码中的固定高度;未设置时使用 320px 的编辑器预览高度。发布后的高度仍由容器样式决定。"
|
||||
],
|
||||
"block title\u0004Asciicast Player": [
|
||||
"Asciicast 播放器"
|
||||
],
|
||||
"block description\u0004Embed and preview a terminal recording with the locally bundled asciinema player.": [
|
||||
"使用本地附带的 asciinema 播放器嵌入和预览终端录屏。"
|
||||
],
|
||||
"block keyword\u0004asciinema": [
|
||||
"asciinema"
|
||||
],
|
||||
"block keyword\u0004terminal": [
|
||||
"终端"
|
||||
],
|
||||
"block keyword\u0004recording": [
|
||||
"录屏"
|
||||
],
|
||||
"Unable to load the recording. Check the URL, file format, and the source server’s CORS permissions.": [
|
||||
"无法加载录制文件。请检查 URL、文件格式及来源服务器的跨域请求(CORS)权限。"
|
||||
],
|
||||
"The recording is taking too long to load. Check your connection and try again.": [
|
||||
"录制文件加载超时。请检查网络连接后重试。"
|
||||
],
|
||||
"The local player could not start. Try again, or check that the plugin’s built assets are installed.": [
|
||||
"本地播放器无法启动。请重试,或检查插件的构建资源是否已安装。"
|
||||
],
|
||||
"Loading recording…": [
|
||||
"正在加载录制文件…"
|
||||
],
|
||||
"Retry preview": [
|
||||
"重试预览"
|
||||
],
|
||||
"Interactive terminal recording preview": [
|
||||
"可交互的终端录屏预览"
|
||||
],
|
||||
"Unable to load this terminal recording. The file may be unavailable, invalid, or blocked by the source server’s CORS policy.": [
|
||||
"无法加载此终端录屏。文件可能无法访问、格式无效,或被来源服务器的跨域请求(CORS)策略阻止。"
|
||||
],
|
||||
"You are not allowed to upload Asciicast files.": [
|
||||
"你没有上传 Asciicast 文件的权限。"
|
||||
],
|
||||
"Upload a valid Asciicast v2/v3 JSONL or pretty-printed v1 .cast recording (up to 32 MiB; v1 up to 2 MiB, 100,000 events, 256 KiB per JSONL line, and 1,000 columns or rows).": [
|
||||
"请上传有效的 Asciicast v2/v3 JSONL 或格式化的 v1 .cast 录制文件(最大 32 MiB;v1 最大 2 MiB;最多 100,000 个事件;每行 JSONL最大 256 KiB;列数和行数均不超过 1,000)。"
|
||||
],
|
||||
"Add interactive terminal recordings to posts and pages with a block or shortcode.": [
|
||||
"通过区块或简码在文章和页面中添加可交互的终端录屏。"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
{
|
||||
"domain": "wp-asciiplayer",
|
||||
"locale_data": {
|
||||
"messages": {
|
||||
"": {
|
||||
"domain": "wp-asciiplayer",
|
||||
"lang": "zh_CN",
|
||||
"plural-forms": "nplurals=1; plural=0;"
|
||||
},
|
||||
"Columns": [
|
||||
"列数"
|
||||
],
|
||||
"From recording": [
|
||||
"使用录制尺寸"
|
||||
],
|
||||
"Rows": [
|
||||
"行数"
|
||||
],
|
||||
"Placeholders show the recording’s original columns and rows once loaded. Leave blank to follow its terminal size and recorded resize events. These overrides change the character grid, not the display width, and may alter or crop the layout.": [
|
||||
"加载后,占位提示会显示录制文件的原始行列数。留空可使用录制尺寸,并跟随录制中的尺寸变化。手动设置会改变字符网格,而非显示宽度,可能影响排版或裁切内容。"
|
||||
],
|
||||
"Use recording size": [
|
||||
"使用录制尺寸"
|
||||
],
|
||||
"Asciinema": [
|
||||
"Asciinema"
|
||||
],
|
||||
"Recording theme (automatic)": [
|
||||
"录制文件主题(自动)"
|
||||
],
|
||||
"Custom": [
|
||||
"自定义"
|
||||
],
|
||||
"Width": [
|
||||
"按宽度缩放"
|
||||
],
|
||||
"Original size": [
|
||||
"原始大小"
|
||||
],
|
||||
"Height (legacy)": [
|
||||
"按高度缩放(旧版)"
|
||||
],
|
||||
"Width and height (legacy)": [
|
||||
"按宽高缩放(旧版)"
|
||||
],
|
||||
"Example terminal recording": [
|
||||
"终端录屏示例"
|
||||
],
|
||||
"A terminal recording, right in your post.": [
|
||||
"在文章中直接播放终端录屏。"
|
||||
],
|
||||
"Terminal size": [
|
||||
"终端尺寸"
|
||||
],
|
||||
"Terminal size (columns × rows)": [
|
||||
"终端尺寸(列数 × 行数)"
|
||||
],
|
||||
"Close": [
|
||||
"关闭"
|
||||
],
|
||||
"Display": [
|
||||
"显示"
|
||||
],
|
||||
"Player width": [
|
||||
"播放器宽度"
|
||||
],
|
||||
"Custom width": [
|
||||
"自定义宽度"
|
||||
],
|
||||
"Use a CSS length, such as 480px or 65%. The player stays within its available space.": [
|
||||
"使用 CSS 长度,例如 480px 或 65%。播放器不会超出可用空间。"
|
||||
],
|
||||
"Enter a positive width with a unit, such as 480px or 65%. The last valid width is kept.": [
|
||||
"请输入带单位的正数宽度,例如 480px 或 65%。将保留上一次有效的宽度。"
|
||||
],
|
||||
"Display alignment": [
|
||||
"对齐方式"
|
||||
],
|
||||
"Left": [
|
||||
"左对齐"
|
||||
],
|
||||
"Center": [
|
||||
"居中"
|
||||
],
|
||||
"Right": [
|
||||
"右对齐"
|
||||
],
|
||||
"Display width scales the recording without changing its terminal columns or rows. Add a caption directly below the player.": [
|
||||
"显示宽度只缩放画面,不改变终端行列数。可在播放器下方直接添加说明文字。"
|
||||
],
|
||||
"Playback": [
|
||||
"播放"
|
||||
],
|
||||
"Playback speed": [
|
||||
"播放速度"
|
||||
],
|
||||
"Loop playback": [
|
||||
"循环播放"
|
||||
],
|
||||
"Autoplay on published page": [
|
||||
"在发布后的页面自动播放"
|
||||
],
|
||||
"The editor preview always waits for you to press play.": [
|
||||
"编辑器预览始终需要点击播放后才会开始。"
|
||||
],
|
||||
"Preload on published page": [
|
||||
"在发布后的页面预加载"
|
||||
],
|
||||
"Loads the recording before the visitor presses play. The editor preview always preloads a valid recording URL.": [
|
||||
"在访客点击播放前加载录制文件。编辑器预览始终会预加载有效的录制文件 URL。"
|
||||
],
|
||||
"Start at (seconds)": [
|
||||
"起始时间(秒)"
|
||||
],
|
||||
"Idle time limit (seconds)": [
|
||||
"最长空闲时间(秒)"
|
||||
],
|
||||
"Shorten long pauses. Use 0 to keep the recording’s default.": [
|
||||
"缩短过长的停顿。设为 0 可保留录制文件的默认设置。"
|
||||
],
|
||||
"Appearance": [
|
||||
"外观"
|
||||
],
|
||||
"Theme": [
|
||||
"主题"
|
||||
],
|
||||
"Player controls": [
|
||||
"播放控制栏"
|
||||
],
|
||||
"Show on interaction": [
|
||||
"交互时显示"
|
||||
],
|
||||
"Always show": [
|
||||
"始终显示"
|
||||
],
|
||||
"Hide": [
|
||||
"隐藏"
|
||||
],
|
||||
"Fit": [
|
||||
"缩放方式"
|
||||
],
|
||||
"Height-based fitting requires a fixed container height in your site CSS.": [
|
||||
"按高度缩放需要在站点 CSS 中设置固定的容器高度。"
|
||||
],
|
||||
"The custom container style from your shortcode is preserved on the published page.": [
|
||||
"发布后的页面会保留简码中的自定义容器样式。"
|
||||
],
|
||||
"Help": [
|
||||
"帮助"
|
||||
],
|
||||
"A valid recording URL loads its preview automatically, including when reopening this editor. That server receives your browser’s request. Published players contact the same server. Use a direct .cast URL; external servers must allow CORS.": [
|
||||
"有效的录制文件 URL 会自动加载预览,重新打开编辑器时也一样。文件所在服务器会收到浏览器请求,发布后的播放器也会访问该服务器。请使用 .cast 文件直链;外部服务器需允许跨域请求(CORS)。"
|
||||
],
|
||||
"Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.": [
|
||||
"使用播放器控件播放、暂停和跳转。仅编辑器预览禁用自动播放。"
|
||||
],
|
||||
"Recording URL": [
|
||||
"录制文件 URL"
|
||||
],
|
||||
"Apply URL": [
|
||||
"应用 URL"
|
||||
],
|
||||
"Choose an Asciicast recording": [
|
||||
"选择 Asciicast 录制文件"
|
||||
],
|
||||
"Choose recording": [
|
||||
"选择录制文件"
|
||||
],
|
||||
"Choose an Asciicast (.cast) file from the Media Library.": [
|
||||
"请从媒体库选择 Asciicast(.cast)文件。"
|
||||
],
|
||||
"Enter an HTTP(S) recording URL or a path starting with a single /.": [
|
||||
"请输入 HTTP(S) 录制文件 URL,或以单个 / 开头的路径。"
|
||||
],
|
||||
"Asciicast Player": [
|
||||
"Asciicast 播放器"
|
||||
],
|
||||
"Enter a recording URL to load its preview automatically. Playback starts only when you press play.": [
|
||||
"输入录制文件 URL 后会自动加载预览,点击播放才会开始播放。"
|
||||
],
|
||||
"Add a caption…": [
|
||||
"添加说明文字…"
|
||||
],
|
||||
"Recording caption": [
|
||||
"录屏说明文字"
|
||||
],
|
||||
"Height-based previews use the shortcode’s fixed height when available, or a 320px editor frame. Published height still comes from your container style.": [
|
||||
"按高度缩放的预览会使用简码中的固定高度;未设置时使用 320px 的编辑器预览高度。发布后的高度仍由容器样式决定。"
|
||||
],
|
||||
"block title\u0004Asciicast Player": [
|
||||
"Asciicast 播放器"
|
||||
],
|
||||
"block description\u0004Embed and preview a terminal recording with the locally bundled asciinema player.": [
|
||||
"使用本地附带的 asciinema 播放器嵌入和预览终端录屏。"
|
||||
],
|
||||
"block keyword\u0004asciinema": [
|
||||
"asciinema"
|
||||
],
|
||||
"block keyword\u0004terminal": [
|
||||
"终端"
|
||||
],
|
||||
"block keyword\u0004recording": [
|
||||
"录屏"
|
||||
],
|
||||
"Unable to load the recording. Check the URL, file format, and the source server’s CORS permissions.": [
|
||||
"无法加载录制文件。请检查 URL、文件格式及来源服务器的跨域请求(CORS)权限。"
|
||||
],
|
||||
"The recording is taking too long to load. Check your connection and try again.": [
|
||||
"录制文件加载超时。请检查网络连接后重试。"
|
||||
],
|
||||
"The local player could not start. Try again, or check that the plugin’s built assets are installed.": [
|
||||
"本地播放器无法启动。请重试,或检查插件的构建资源是否已安装。"
|
||||
],
|
||||
"Loading recording…": [
|
||||
"正在加载录制文件…"
|
||||
],
|
||||
"Retry preview": [
|
||||
"重试预览"
|
||||
],
|
||||
"Interactive terminal recording preview": [
|
||||
"可交互的终端录屏预览"
|
||||
],
|
||||
"Unable to load this terminal recording. The file may be unavailable, invalid, or blocked by the source server’s CORS policy.": [
|
||||
"无法加载此终端录屏。文件可能无法访问、格式无效,或被来源服务器的跨域请求(CORS)策略阻止。"
|
||||
],
|
||||
"You are not allowed to upload Asciicast files.": [
|
||||
"你没有上传 Asciicast 文件的权限。"
|
||||
],
|
||||
"Upload a valid Asciicast v2/v3 JSONL or pretty-printed v1 .cast recording (up to 32 MiB; v1 up to 2 MiB, 100,000 events, 256 KiB per JSONL line, and 1,000 columns or rows).": [
|
||||
"请上传有效的 Asciicast v2/v3 JSONL 或格式化的 v1 .cast 录制文件(最大 32 MiB;v1 最大 2 MiB;最多 100,000 个事件;每行 JSONL最大 256 KiB;列数和行数均不超过 1,000)。"
|
||||
],
|
||||
"Add interactive terminal recordings to posts and pages with a block or shortcode.": [
|
||||
"通过区块或简码在文章和页面中添加可交互的终端录屏。"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,367 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: wp-asciiplayer 1.1.0-dev\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Domain: wp-asciiplayer\n"
|
||||
"Language: zh_CN\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"Language-Team: Simplified Chinese\n"
|
||||
|
||||
#: src/edit.js:91
|
||||
msgid "A terminal recording, right in your post."
|
||||
msgstr "在文章中直接播放终端录屏。"
|
||||
|
||||
#: src/edit.js:139
|
||||
msgid ""
|
||||
"A valid recording URL loads its preview automatically, including when "
|
||||
"reopening this editor. That server receives your browser’s request. "
|
||||
"Published players contact the same server. Use a direct .cast URL; external "
|
||||
"servers must allow CORS."
|
||||
msgstr ""
|
||||
"有效的录制文件 URL 会自动加载预览,重新打开编辑器时也一样。文件所在服务器会收到浏览器请求,发布后的播放器也会访问该服务器。请使用 .cast "
|
||||
"文件直链;外部服务器需允许跨域请求(CORS)。"
|
||||
|
||||
#: src/edit.js:165
|
||||
msgid "Add a caption…"
|
||||
msgstr "添加说明文字…"
|
||||
|
||||
#: asciicast-player.php:1
|
||||
msgid ""
|
||||
"Add interactive terminal recordings to posts and pages with a block or "
|
||||
"shortcode."
|
||||
msgstr "通过区块或简码在文章和页面中添加可交互的终端录屏。"
|
||||
|
||||
#: src/edit.js:132
|
||||
msgid "Always show"
|
||||
msgstr "始终显示"
|
||||
|
||||
#: src/edit.js:128
|
||||
msgid "Appearance"
|
||||
msgstr "外观"
|
||||
|
||||
#: src/edit.js:147
|
||||
msgid "Apply URL"
|
||||
msgstr "应用 URL"
|
||||
|
||||
#: src/edit.js:163
|
||||
#: asciicast-player.php:1
|
||||
msgid "Asciicast Player"
|
||||
msgstr "Asciicast 播放器"
|
||||
|
||||
#: src/edit.js:73
|
||||
msgid "Asciinema"
|
||||
msgstr "Asciinema"
|
||||
|
||||
#: src/edit.js:123
|
||||
msgid "Autoplay on published page"
|
||||
msgstr "在发布后的页面自动播放"
|
||||
|
||||
#: src/edit.js:116
|
||||
msgid "Center"
|
||||
msgstr "居中"
|
||||
|
||||
#: src/edit.js:154
|
||||
msgid "Choose an Asciicast (.cast) file from the Media Library."
|
||||
msgstr "请从媒体库选择 Asciicast(.cast)文件。"
|
||||
|
||||
#: src/edit.js:150
|
||||
msgid "Choose an Asciicast recording"
|
||||
msgstr "选择 Asciicast 录制文件"
|
||||
|
||||
#: src/edit.js:151
|
||||
msgid "Choose recording"
|
||||
msgstr "选择录制文件"
|
||||
|
||||
#: src/edit.js:104
|
||||
msgid "Close"
|
||||
msgstr "关闭"
|
||||
|
||||
#: src/edit.js:12
|
||||
msgid "Columns"
|
||||
msgstr "列数"
|
||||
|
||||
#: src/edit.js:81
|
||||
msgid "Custom"
|
||||
msgstr "自定义"
|
||||
|
||||
#: src/edit.js:115
|
||||
msgid "Custom width"
|
||||
msgstr "自定义宽度"
|
||||
|
||||
#: src/edit.js:113
|
||||
msgid "Display"
|
||||
msgstr "显示"
|
||||
|
||||
#: src/edit.js:116
|
||||
msgid "Display alignment"
|
||||
msgstr "对齐方式"
|
||||
|
||||
#: src/edit.js:117
|
||||
msgid ""
|
||||
"Display width scales the recording without changing its terminal columns or "
|
||||
"rows. Add a caption directly below the player."
|
||||
msgstr "显示宽度只缩放画面,不改变终端行列数。可在播放器下方直接添加说明文字。"
|
||||
|
||||
#: src/edit.js:115
|
||||
msgid ""
|
||||
"Enter a positive width with a unit, such as 480px or 65%. The last valid "
|
||||
"width is kept."
|
||||
msgstr "请输入带单位的正数宽度,例如 480px 或 65%。将保留上一次有效的宽度。"
|
||||
|
||||
#: src/edit.js:163
|
||||
msgid ""
|
||||
"Enter a recording URL to load its preview automatically. Playback starts "
|
||||
"only when you press play."
|
||||
msgstr "输入录制文件 URL 后会自动加载预览,点击播放才会开始播放。"
|
||||
|
||||
#: src/edit.js:155
|
||||
msgid "Enter an HTTP(S) recording URL or a path starting with a single /."
|
||||
msgstr "请输入 HTTP(S) 录制文件 URL,或以单个 / 开头的路径。"
|
||||
|
||||
#: src/edit.js:91
|
||||
msgid "Example terminal recording"
|
||||
msgstr "终端录屏示例"
|
||||
|
||||
#: src/edit.js:135
|
||||
msgid "Fit"
|
||||
msgstr "缩放方式"
|
||||
|
||||
#: src/edit.js:12
|
||||
#: src/edit.js:13
|
||||
msgid "From recording"
|
||||
msgstr "使用录制尺寸"
|
||||
|
||||
#: src/edit.js:89
|
||||
msgid "Height (legacy)"
|
||||
msgstr "按高度缩放(旧版)"
|
||||
|
||||
#: src/edit.js:135
|
||||
msgid "Height-based fitting requires a fixed container height in your site CSS."
|
||||
msgstr "按高度缩放需要在站点 CSS 中设置固定的容器高度。"
|
||||
|
||||
#: src/edit.js:167
|
||||
msgid ""
|
||||
"Height-based previews use the shortcode’s fixed height when available, or a "
|
||||
"320px editor frame. Published height still comes from your container style."
|
||||
msgstr "按高度缩放的预览会使用简码中的固定高度;未设置时使用 320px 的编辑器预览高度。发布后的高度仍由容器样式决定。"
|
||||
|
||||
#: src/edit.js:138
|
||||
msgid "Help"
|
||||
msgstr "帮助"
|
||||
|
||||
#: src/edit.js:133
|
||||
msgid "Hide"
|
||||
msgstr "隐藏"
|
||||
|
||||
#: src/edit.js:126
|
||||
msgid "Idle time limit (seconds)"
|
||||
msgstr "最长空闲时间(秒)"
|
||||
|
||||
#: src/preview.js:85
|
||||
msgid "Interactive terminal recording preview"
|
||||
msgstr "可交互的终端录屏预览"
|
||||
|
||||
#: src/edit.js:116
|
||||
msgid "Left"
|
||||
msgstr "左对齐"
|
||||
|
||||
#: src/preview.js:83
|
||||
msgid "Loading recording…"
|
||||
msgstr "正在加载录制文件…"
|
||||
|
||||
#: src/edit.js:124
|
||||
msgid ""
|
||||
"Loads the recording before the visitor presses play. The editor preview "
|
||||
"always preloads a valid recording URL."
|
||||
msgstr "在访客点击播放前加载录制文件。编辑器预览始终会预加载有效的录制文件 URL。"
|
||||
|
||||
#: src/edit.js:122
|
||||
msgid "Loop playback"
|
||||
msgstr "循环播放"
|
||||
|
||||
#: src/edit.js:87
|
||||
msgid "Original size"
|
||||
msgstr "原始大小"
|
||||
|
||||
#: src/edit.js:15
|
||||
msgid ""
|
||||
"Placeholders show the recording’s original columns and rows once loaded. "
|
||||
"Leave blank to follow its terminal size and recorded resize events. These "
|
||||
"overrides change the character grid, not the display width, and may alter "
|
||||
"or crop the layout."
|
||||
msgstr "加载后,占位提示会显示录制文件的原始行列数。留空可使用录制尺寸,并跟随录制中的尺寸变化。手动设置会改变字符网格,而非显示宽度,可能影响排版或裁切内容。"
|
||||
|
||||
#: src/edit.js:120
|
||||
msgid "Playback"
|
||||
msgstr "播放"
|
||||
|
||||
#: src/edit.js:121
|
||||
msgid "Playback speed"
|
||||
msgstr "播放速度"
|
||||
|
||||
#: src/edit.js:130
|
||||
msgid "Player controls"
|
||||
msgstr "播放控制栏"
|
||||
|
||||
#: src/edit.js:114
|
||||
msgid "Player width"
|
||||
msgstr "播放器宽度"
|
||||
|
||||
#: src/edit.js:124
|
||||
msgid "Preload on published page"
|
||||
msgstr "在发布后的页面预加载"
|
||||
|
||||
#: src/edit.js:165
|
||||
msgid "Recording caption"
|
||||
msgstr "录屏说明文字"
|
||||
|
||||
#: src/edit.js:74
|
||||
msgid "Recording theme (automatic)"
|
||||
msgstr "录制文件主题(自动)"
|
||||
|
||||
#: src/edit.js:146
|
||||
msgid "Recording URL"
|
||||
msgstr "录制文件 URL"
|
||||
|
||||
#: src/preview.js:84
|
||||
msgid "Retry preview"
|
||||
msgstr "重试预览"
|
||||
|
||||
#: src/edit.js:116
|
||||
msgid "Right"
|
||||
msgstr "右对齐"
|
||||
|
||||
#: src/edit.js:13
|
||||
msgid "Rows"
|
||||
msgstr "行数"
|
||||
|
||||
#: src/edit.js:126
|
||||
msgid "Shorten long pauses. Use 0 to keep the recording’s default."
|
||||
msgstr "缩短过长的停顿。设为 0 可保留录制文件的默认设置。"
|
||||
|
||||
#: src/edit.js:131
|
||||
msgid "Show on interaction"
|
||||
msgstr "交互时显示"
|
||||
|
||||
#: src/edit.js:125
|
||||
msgid "Start at (seconds)"
|
||||
msgstr "起始时间(秒)"
|
||||
|
||||
#: src/edit.js:99
|
||||
#: src/edit.js:101
|
||||
#: src/edit.js:110
|
||||
msgid "Terminal size"
|
||||
msgstr "终端尺寸"
|
||||
|
||||
#: src/edit.js:102
|
||||
msgid "Terminal size (columns × rows)"
|
||||
msgstr "终端尺寸(列数 × 行数)"
|
||||
|
||||
#: src/edit.js:136
|
||||
msgid ""
|
||||
"The custom container style from your shortcode is preserved on the "
|
||||
"published page."
|
||||
msgstr "发布后的页面会保留简码中的自定义容器样式。"
|
||||
|
||||
#: src/edit.js:123
|
||||
msgid "The editor preview always waits for you to press play."
|
||||
msgstr "编辑器预览始终需要点击播放后才会开始。"
|
||||
|
||||
#: src/preview.js:70
|
||||
msgid ""
|
||||
"The local player could not start. Try again, or check that the plugin’s "
|
||||
"built assets are installed."
|
||||
msgstr "本地播放器无法启动。请重试,或检查插件的构建资源是否已安装。"
|
||||
|
||||
#: src/preview.js:68
|
||||
msgid ""
|
||||
"The recording is taking too long to load. Check your connection and try "
|
||||
"again."
|
||||
msgstr "录制文件加载超时。请检查网络连接后重试。"
|
||||
|
||||
#: src/edit.js:129
|
||||
msgid "Theme"
|
||||
msgstr "主题"
|
||||
|
||||
#: src/preview.js:59
|
||||
msgid ""
|
||||
"Unable to load the recording. Check the URL, file format, and the source "
|
||||
"server’s CORS permissions."
|
||||
msgstr "无法加载录制文件。请检查 URL、文件格式及来源服务器的跨域请求(CORS)权限。"
|
||||
|
||||
#: src/view.js:12
|
||||
msgid ""
|
||||
"Unable to load this terminal recording. The file may be unavailable, "
|
||||
"invalid, or blocked by the source server’s CORS policy."
|
||||
msgstr "无法加载此终端录屏。文件可能无法访问、格式无效,或被来源服务器的跨域请求(CORS)策略阻止。"
|
||||
|
||||
#: includes/uploads.php:197
|
||||
msgid ""
|
||||
"Upload a valid Asciicast v2/v3 JSONL or pretty-printed v1 .cast recording "
|
||||
"(up to 32 MiB; v1 up to 2 MiB, 100,000 events, 256 KiB per JSONL line, and "
|
||||
"1,000 columns or rows)."
|
||||
msgstr ""
|
||||
"请上传有效的 Asciicast v2/v3 JSONL 或格式化的 v1 .cast 录制文件(最大 32 MiB;v1 最大 2 MiB;最多 "
|
||||
"100,000 个事件;每行 JSONL最大 256 KiB;列数和行数均不超过 1,000)。"
|
||||
|
||||
#: src/edit.js:115
|
||||
msgid ""
|
||||
"Use a CSS length, such as 480px or 65%. The player stays within its "
|
||||
"available space."
|
||||
msgstr "使用 CSS 长度,例如 480px 或 65%。播放器不会超出可用空间。"
|
||||
|
||||
#: src/edit.js:16
|
||||
msgid "Use recording size"
|
||||
msgstr "使用录制尺寸"
|
||||
|
||||
#: src/edit.js:140
|
||||
msgid ""
|
||||
"Use the player controls to play, pause, and seek. Autoplay is disabled only "
|
||||
"in the editor."
|
||||
msgstr "使用播放器控件播放、暂停和跳转。仅编辑器预览禁用自动播放。"
|
||||
|
||||
#: src/edit.js:86
|
||||
msgid "Width"
|
||||
msgstr "按宽度缩放"
|
||||
|
||||
#: src/edit.js:89
|
||||
msgid "Width and height (legacy)"
|
||||
msgstr "按宽高缩放(旧版)"
|
||||
|
||||
#: includes/uploads.php:195
|
||||
msgid "You are not allowed to upload Asciicast files."
|
||||
msgstr "你没有上传 Asciicast 文件的权限。"
|
||||
|
||||
#: src/index.js:19
|
||||
#: block.json:1
|
||||
msgctxt "block description"
|
||||
msgid ""
|
||||
"Embed and preview a terminal recording with the locally bundled asciinema "
|
||||
"player."
|
||||
msgstr "使用本地附带的 asciinema 播放器嵌入和预览终端录屏。"
|
||||
|
||||
#: src/index.js:20
|
||||
#: block.json:1
|
||||
msgctxt "block keyword"
|
||||
msgid "asciinema"
|
||||
msgstr "asciinema"
|
||||
|
||||
#: src/index.js:20
|
||||
#: block.json:1
|
||||
msgctxt "block keyword"
|
||||
msgid "recording"
|
||||
msgstr "录屏"
|
||||
|
||||
#: src/index.js:20
|
||||
#: block.json:1
|
||||
msgctxt "block keyword"
|
||||
msgid "terminal"
|
||||
msgstr "终端"
|
||||
|
||||
#: src/index.js:18
|
||||
#: block.json:1
|
||||
msgctxt "block title"
|
||||
msgid "Asciicast Player"
|
||||
msgstr "Asciicast 播放器"
|
||||
@@ -0,0 +1,360 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: wp-asciiplayer 1.1.0-dev\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Domain: wp-asciiplayer\n"
|
||||
|
||||
#: src/edit.js:91
|
||||
msgid "A terminal recording, right in your post."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:139
|
||||
msgid ""
|
||||
"A valid recording URL loads its preview automatically, including when "
|
||||
"reopening this editor. That server receives your browser’s request. "
|
||||
"Published players contact the same server. Use a direct .cast URL; external "
|
||||
"servers must allow CORS."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:165
|
||||
msgid "Add a caption…"
|
||||
msgstr ""
|
||||
|
||||
#: asciicast-player.php:1
|
||||
msgid ""
|
||||
"Add interactive terminal recordings to posts and pages with a block or "
|
||||
"shortcode."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:132
|
||||
msgid "Always show"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:128
|
||||
msgid "Appearance"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:147
|
||||
msgid "Apply URL"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:163
|
||||
#: asciicast-player.php:1
|
||||
msgid "Asciicast Player"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:73
|
||||
msgid "Asciinema"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:123
|
||||
msgid "Autoplay on published page"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:116
|
||||
msgid "Center"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:154
|
||||
msgid "Choose an Asciicast (.cast) file from the Media Library."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:150
|
||||
msgid "Choose an Asciicast recording"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:151
|
||||
msgid "Choose recording"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:104
|
||||
msgid "Close"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:12
|
||||
msgid "Columns"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:81
|
||||
msgid "Custom"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:115
|
||||
msgid "Custom width"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:113
|
||||
msgid "Display"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:116
|
||||
msgid "Display alignment"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:117
|
||||
msgid ""
|
||||
"Display width scales the recording without changing its terminal columns or "
|
||||
"rows. Add a caption directly below the player."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:115
|
||||
msgid ""
|
||||
"Enter a positive width with a unit, such as 480px or 65%. The last valid "
|
||||
"width is kept."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:163
|
||||
msgid ""
|
||||
"Enter a recording URL to load its preview automatically. Playback starts "
|
||||
"only when you press play."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:155
|
||||
msgid "Enter an HTTP(S) recording URL or a path starting with a single /."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:91
|
||||
msgid "Example terminal recording"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:135
|
||||
msgid "Fit"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:12
|
||||
#: src/edit.js:13
|
||||
msgid "From recording"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:89
|
||||
msgid "Height (legacy)"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:135
|
||||
msgid "Height-based fitting requires a fixed container height in your site CSS."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:167
|
||||
msgid ""
|
||||
"Height-based previews use the shortcode’s fixed height when available, or a "
|
||||
"320px editor frame. Published height still comes from your container style."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:138
|
||||
msgid "Help"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:133
|
||||
msgid "Hide"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:126
|
||||
msgid "Idle time limit (seconds)"
|
||||
msgstr ""
|
||||
|
||||
#: src/preview.js:85
|
||||
msgid "Interactive terminal recording preview"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:116
|
||||
msgid "Left"
|
||||
msgstr ""
|
||||
|
||||
#: src/preview.js:83
|
||||
msgid "Loading recording…"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:124
|
||||
msgid ""
|
||||
"Loads the recording before the visitor presses play. The editor preview "
|
||||
"always preloads a valid recording URL."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:122
|
||||
msgid "Loop playback"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:87
|
||||
msgid "Original size"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:15
|
||||
msgid ""
|
||||
"Placeholders show the recording’s original columns and rows once loaded. "
|
||||
"Leave blank to follow its terminal size and recorded resize events. These "
|
||||
"overrides change the character grid, not the display width, and may alter "
|
||||
"or crop the layout."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:120
|
||||
msgid "Playback"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:121
|
||||
msgid "Playback speed"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:130
|
||||
msgid "Player controls"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:114
|
||||
msgid "Player width"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:124
|
||||
msgid "Preload on published page"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:165
|
||||
msgid "Recording caption"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:74
|
||||
msgid "Recording theme (automatic)"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:146
|
||||
msgid "Recording URL"
|
||||
msgstr ""
|
||||
|
||||
#: src/preview.js:84
|
||||
msgid "Retry preview"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:116
|
||||
msgid "Right"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:13
|
||||
msgid "Rows"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:126
|
||||
msgid "Shorten long pauses. Use 0 to keep the recording’s default."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:131
|
||||
msgid "Show on interaction"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:125
|
||||
msgid "Start at (seconds)"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:99
|
||||
#: src/edit.js:101
|
||||
#: src/edit.js:110
|
||||
msgid "Terminal size"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:102
|
||||
msgid "Terminal size (columns × rows)"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:136
|
||||
msgid ""
|
||||
"The custom container style from your shortcode is preserved on the "
|
||||
"published page."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:123
|
||||
msgid "The editor preview always waits for you to press play."
|
||||
msgstr ""
|
||||
|
||||
#: src/preview.js:70
|
||||
msgid ""
|
||||
"The local player could not start. Try again, or check that the plugin’s "
|
||||
"built assets are installed."
|
||||
msgstr ""
|
||||
|
||||
#: src/preview.js:68
|
||||
msgid ""
|
||||
"The recording is taking too long to load. Check your connection and try "
|
||||
"again."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:129
|
||||
msgid "Theme"
|
||||
msgstr ""
|
||||
|
||||
#: src/preview.js:59
|
||||
msgid ""
|
||||
"Unable to load the recording. Check the URL, file format, and the source "
|
||||
"server’s CORS permissions."
|
||||
msgstr ""
|
||||
|
||||
#: src/view.js:12
|
||||
msgid ""
|
||||
"Unable to load this terminal recording. The file may be unavailable, "
|
||||
"invalid, or blocked by the source server’s CORS policy."
|
||||
msgstr ""
|
||||
|
||||
#: includes/uploads.php:197
|
||||
msgid ""
|
||||
"Upload a valid Asciicast v2/v3 JSONL or pretty-printed v1 .cast recording "
|
||||
"(up to 32 MiB; v1 up to 2 MiB, 100,000 events, 256 KiB per JSONL line, and "
|
||||
"1,000 columns or rows)."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:115
|
||||
msgid ""
|
||||
"Use a CSS length, such as 480px or 65%. The player stays within its "
|
||||
"available space."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:16
|
||||
msgid "Use recording size"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:140
|
||||
msgid ""
|
||||
"Use the player controls to play, pause, and seek. Autoplay is disabled only "
|
||||
"in the editor."
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:86
|
||||
msgid "Width"
|
||||
msgstr ""
|
||||
|
||||
#: src/edit.js:89
|
||||
msgid "Width and height (legacy)"
|
||||
msgstr ""
|
||||
|
||||
#: includes/uploads.php:195
|
||||
msgid "You are not allowed to upload Asciicast files."
|
||||
msgstr ""
|
||||
|
||||
#: src/index.js:19
|
||||
#: block.json:1
|
||||
msgctxt "block description"
|
||||
msgid ""
|
||||
"Embed and preview a terminal recording with the locally bundled asciinema "
|
||||
"player."
|
||||
msgstr ""
|
||||
|
||||
#: src/index.js:20
|
||||
#: block.json:1
|
||||
msgctxt "block keyword"
|
||||
msgid "asciinema"
|
||||
msgstr ""
|
||||
|
||||
#: src/index.js:20
|
||||
#: block.json:1
|
||||
msgctxt "block keyword"
|
||||
msgid "recording"
|
||||
msgstr ""
|
||||
|
||||
#: src/index.js:20
|
||||
#: block.json:1
|
||||
msgctxt "block keyword"
|
||||
msgid "terminal"
|
||||
msgstr ""
|
||||
|
||||
#: src/index.js:18
|
||||
#: block.json:1
|
||||
msgctxt "block title"
|
||||
msgid "Asciicast Player"
|
||||
msgstr ""
|
||||
Generated
+5
-3
@@ -1,20 +1,22 @@
|
||||
{
|
||||
"name": "wp-asciiplayer",
|
||||
"version": "1.2.2",
|
||||
"version": "1.1.0-dev",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "wp-asciiplayer",
|
||||
"version": "1.2.2",
|
||||
"version": "1.1.0-dev",
|
||||
"license": "GPL-3.0-only",
|
||||
"dependencies": {
|
||||
"asciinema-player": "3.17.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/parser": "7.29.9",
|
||||
"@playwright/test": "1.64.0",
|
||||
"@wordpress/env": "11.17.0",
|
||||
"@wordpress/scripts": "36.1.0"
|
||||
"@wordpress/scripts": "36.1.0",
|
||||
"gettext-parser": "1.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.22.2"
|
||||
|
||||
+9
-5
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wp-asciiplayer",
|
||||
"version": "1.2.2",
|
||||
"version": "1.1.0-dev",
|
||||
"private": true,
|
||||
"description": "Native WordPress asciicast block with real playback previews and compatible shortcodes",
|
||||
"type": "module",
|
||||
@@ -9,13 +9,15 @@
|
||||
"node": ">=22.22.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "wp-scripts build --config webpack.config.cjs && node scripts/vendor.mjs && node scripts/verify-build.mjs",
|
||||
"build": "wp-scripts build --config webpack.config.cjs && node scripts/vendor.mjs && npm run i18n && node scripts/verify-build.mjs",
|
||||
"start": "wp-scripts start --config webpack.config.cjs",
|
||||
"test": "node --test tests/js/*.test.js",
|
||||
"test": "npm run i18n:check && node --test tests/js/*.test.js",
|
||||
"test:php": "php tests/php/run.php",
|
||||
"test:e2e": "playwright test",
|
||||
"wp-env": "wp-env",
|
||||
"package": "node scripts/package.mjs"
|
||||
"package": "node scripts/package.mjs",
|
||||
"i18n": "node scripts/i18n.mjs",
|
||||
"i18n:check": "node scripts/i18n.mjs --check"
|
||||
},
|
||||
"dependencies": {
|
||||
"asciinema-player": "3.17.0"
|
||||
@@ -23,7 +25,9 @@
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.64.0",
|
||||
"@wordpress/env": "11.17.0",
|
||||
"@wordpress/scripts": "36.1.0"
|
||||
"@wordpress/scripts": "36.1.0",
|
||||
"@babel/parser": "7.29.9",
|
||||
"gettext-parser": "1.4.0"
|
||||
},
|
||||
"cssnano": {
|
||||
"preset": [
|
||||
|
||||
+11
-5
@@ -4,7 +4,7 @@ Tags: asciicast, asciiplayer, asciinema, terminal, block
|
||||
Requires at least: 6.3
|
||||
Tested up to: 7.1
|
||||
Requires PHP: 7.4
|
||||
Stable tag: 1.2.2
|
||||
Stable tag: 1.1.0-dev
|
||||
License: GPL-3.0-only
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
@@ -53,25 +53,31 @@ No. The JavaScript, CSS and WebAssembly ship with the plugin. The previous ap_us
|
||||
|
||||
Existing shortcodes work in the Classic Editor. The new visual controls and inline playback preview are for the block editor.
|
||||
|
||||
= Which languages are included? =
|
||||
|
||||
English (en_US fallback) and Simplified Chinese (zh_CN) are bundled and work offline. Plugin-owned editor controls follow the WordPress user language; public pages follow the site language. Set these in Users > Profile and Settings > General. Other Chinese locales, including zh_TW, are not mapped to zh_CN. Recording output and author captions are never translated. The upstream player's own controls and help remain English.
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.2.2 =
|
||||
= 1.1.0-dev (unreleased) =
|
||||
* Development preview only, not a tagged or published release. Earlier draft package labels 1.1.0 and 1.2.0–1.2.3 were internal iteration labels, not releases.
|
||||
* Bundle English/Simplified Chinese plugin UI translations using WordPress gettext, with reproducible PO/MO/JSON catalogs and real locale integration tests.
|
||||
* Use asset content hashes to prevent stale resources between development builds.
|
||||
* Move recording/privacy and playback explanations from the block canvas to a collapsed sidebar Help panel.
|
||||
|
||||
* Show original cast dimensions as toolbar/sidebar placeholders without forcing overrides.
|
||||
* Refresh recording metadata when the URL changes, reusing the preview request.
|
||||
* Select and upload validated .cast recordings through the native Media Library.
|
||||
|
||||
= 1.2.1 =
|
||||
* Automatically load saved recording previews without enabling playback autoplay.
|
||||
* Debounce recording URL edits; retain immediate apply, retry and request cleanup.
|
||||
* Add terminal Columns/Rows and reset controls to the floating block toolbar, synchronized with the collapsed sidebar panel.
|
||||
|
||||
= 1.2.0 =
|
||||
* Add responsive display-width presets/custom lengths, left/center/right placement and captions.
|
||||
* Preserve recorded terminal dimensions and resize events by default; expose optional row/column overrides.
|
||||
* Isolate terminal typography and frames from common host-theme code-block styles.
|
||||
* Add a local static block-inserter preview without recording requests.
|
||||
|
||||
= 1.1.0 =
|
||||
* Add a native block with typed controls and interactive, iframe-aware preview.
|
||||
* Preserve shortcode support and normalize historical parameter names and types.
|
||||
* Escape output, constrain recording URLs, and filter custom styles.
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/** Deterministic gettext catalogs. English msgids are the en_US fallback. */
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { parse } from '@babel/parser';
|
||||
import gettext from 'gettext-parser';
|
||||
|
||||
const domain = 'wp-asciiplayer';
|
||||
const version = JSON.parse(fs.readFileSync('package.json')).version;
|
||||
const entries = new Map();
|
||||
function add(msgid, context, file, line) {
|
||||
assert.equal(typeof msgid, 'string', `Static gettext string required: ${file}:${line}`);
|
||||
const key = `${context || ''}\u0004${msgid}`;
|
||||
if (!entries.has(key)) entries.set(key, { msgid, msgctxt: context || undefined, msgstr: [''], comments: { reference: '' } });
|
||||
const entry = entries.get(key);
|
||||
entry.comments.reference += `${entry.comments.reference ? '\n' : ''}${file}:${line}`;
|
||||
}
|
||||
function walk(node, file) {
|
||||
if (!node || typeof node !== 'object') return;
|
||||
if (node.type === 'CallExpression' && ['__', '_x', '_n', '_nx'].includes(node.callee?.name)) {
|
||||
const name = node.callee.name;
|
||||
assert.ok(['__', '_x'].includes(name), `Add plural extraction before using ${name}: ${file}`);
|
||||
const args = node.arguments;
|
||||
assert.equal(args[name === '__' ? 1 : 2]?.value, domain, `Explicit textdomain required: ${file}`);
|
||||
assert.equal(args[0]?.type, 'StringLiteral', `Literal gettext message required: ${file}`);
|
||||
if (name === '_x') assert.equal(args[1]?.type, 'StringLiteral');
|
||||
add(args[0].value, name === '_x' ? args[1].value : '', file, node.loc.start.line);
|
||||
}
|
||||
for (const value of Object.values(node)) {
|
||||
if (Array.isArray(value)) for (const child of value) walk(child, file);
|
||||
else if (value && typeof value === 'object') walk(value, file);
|
||||
}
|
||||
}
|
||||
for (const file of fs.readdirSync('src').filter((name) => name.endsWith('.js')).map((name) => `src/${name}`)) {
|
||||
walk(parse(fs.readFileSync(file, 'utf8'), { sourceType: 'module', plugins: ['jsx'] }), file);
|
||||
}
|
||||
for (const file of ['asciicast-player.php', ...fs.readdirSync('includes').filter((name) => name.endsWith('.php')).map((name) => `includes/${name}`)]) {
|
||||
const source = fs.readFileSync(file, 'utf8');
|
||||
const calls = [...source.matchAll(/\b__\s*\(/g)];
|
||||
const matches = [...source.matchAll(/\b__\(\s*'((?:\\.|[^'\\])*)'\s*,\s*'wp-asciiplayer'\s*\)/g)];
|
||||
assert.equal(matches.length, calls.length, `Unsupported PHP gettext syntax in ${file}; extend extractor first.`);
|
||||
assert.ok(!/\b(?:_x|_n|_nx|_e|esc_html__|esc_attr__)\s*\(/.test(source), `Extend PHP extractor for new gettext functions: ${file}`);
|
||||
for (const match of matches) add(match[1].replace(/\\(['\\])/g, '$1'), '', file, source.slice(0, match.index).split('\n').length);
|
||||
}
|
||||
const pluginHeader = fs.readFileSync('asciicast-player.php', 'utf8');
|
||||
for (const label of ['Plugin Name', 'Description']) {
|
||||
const value = pluginHeader.match(new RegExp(` \* ${label}: (.+)`))?.[1];
|
||||
if (value) add(value, '', 'asciicast-player.php', 1);
|
||||
}
|
||||
const metadata = JSON.parse(fs.readFileSync('block.json'));
|
||||
for (const [field, context] of [['title', 'block title'], ['description', 'block description'], ['keywords', 'block keyword']]) {
|
||||
for (const value of [].concat(metadata[field])) add(value, context, 'block.json', 1);
|
||||
}
|
||||
const headers = { 'project-id-version': `${domain} ${version}`, 'mime-version': '1.0', 'content-type': 'text/plain; charset=UTF-8', 'content-transfer-encoding': '8bit', 'x-domain': domain };
|
||||
const pot = { charset: 'utf-8', headers, translations: { '': {} } };
|
||||
for (const entry of [...entries.values()].sort((a, b) => `${a.msgctxt || ''}\u0004${a.msgid}`.localeCompare(`${b.msgctxt || ''}\u0004${b.msgid}`, 'en'))) {
|
||||
const context = entry.msgctxt || '';
|
||||
(pot.translations[context] ||= {})[entry.msgid] = entry;
|
||||
}
|
||||
fs.mkdirSync('languages', { recursive: true });
|
||||
const output = new Map([['languages/wp-asciiplayer.pot', gettext.po.compile(pot)]]);
|
||||
if (!process.argv.includes('--pot-only')) {
|
||||
const po = gettext.po.parse(fs.readFileSync('languages/wp-asciiplayer-zh_CN.po'));
|
||||
assert.equal(po.headers.language, 'zh_CN');
|
||||
assert.match(po.headers['plural-forms'], /^nplurals=1;\s*plural=0;$/);
|
||||
const messages = { '': { domain, lang: 'zh_CN', 'plural-forms': 'nplurals=1; plural=0;' } };
|
||||
for (const entry of entries.values()) {
|
||||
const translation = po.translations[entry.msgctxt || '']?.[entry.msgid];
|
||||
assert.ok(translation?.msgstr?.[0], `Missing zh_CN translation: ${entry.msgid}`);
|
||||
assert.ok(!translation.comments?.flag?.includes('fuzzy'), `Fuzzy translation: ${entry.msgid}`);
|
||||
assert.ok(!translation.msgid_plural && translation.msgstr.length === 1, `Unexpected plural: ${entry.msgid}`);
|
||||
const placeholders = (text) => [...text.matchAll(/%(?:\d+\$)?[sdif]/g)].map((match) => match[0]).sort();
|
||||
assert.deepEqual(placeholders(translation.msgstr[0]), placeholders(entry.msgid), `Placeholder mismatch: ${entry.msgid}`);
|
||||
messages[entry.msgctxt ? `${entry.msgctxt}\u0004${entry.msgid}` : entry.msgid] = translation.msgstr;
|
||||
}
|
||||
output.set('languages/wp-asciiplayer-zh_CN.mo', gettext.mo.compile(po));
|
||||
const json = `${JSON.stringify({ domain, locale_data: { messages } }, null, 2)}\n`;
|
||||
for (const handle of ['lamgc-asciiplayer-editor', 'lamgc-asciiplayer-view']) output.set(`languages/wp-asciiplayer-zh_CN-${handle}.json`, json);
|
||||
}
|
||||
for (const [file, content] of output) {
|
||||
if (process.argv.includes('--check')) assert.deepEqual(fs.readFileSync(file), Buffer.from(content), `Stale catalog: ${file}; run npm run i18n.`);
|
||||
else fs.writeFileSync(file, content);
|
||||
}
|
||||
console.log(`Verified ${entries.size} gettext entries; ${output.size} reproducible artifacts${process.argv.includes('--check') ? ' checked' : ' written'}.`);
|
||||
+3
-2
@@ -4,7 +4,8 @@ import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
|
||||
const root = path.resolve(import.meta.dirname, '..');
|
||||
const required = ['build/block.json', 'build/index.js', 'build/index.asset.php', 'build/view.js', 'build/view.asset.php', 'build/player.js', 'build/player.css'];
|
||||
execFileSync(process.execPath, ['scripts/i18n.mjs', '--check'], { cwd: root, stdio: 'inherit' });
|
||||
const required = ['build/block.json', 'build/index.js', 'build/index.asset.php', 'build/view.js', 'build/view.asset.php', 'build/player.js', 'build/player.css', 'build/runtime.asset.php', 'languages/wp-asciiplayer-zh_CN.mo', 'languages/wp-asciiplayer-zh_CN-lamgc-asciiplayer-editor.json', 'languages/wp-asciiplayer-zh_CN-lamgc-asciiplayer-view.json'];
|
||||
for (const file of required) await stat(path.join(root, file));
|
||||
const pkg = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8'));
|
||||
const php = await readFile(path.join(root, 'asciicast-player.php'), 'utf8');
|
||||
@@ -12,7 +13,7 @@ const readme = await readFile(path.join(root, 'readme.txt'), 'utf8');
|
||||
if (!php.includes(`Version: ${pkg.version}`) || !readme.includes(`Stable tag: ${pkg.version}`)) throw new Error('Version headers disagree.');
|
||||
const temp = await mkdtemp(path.join(os.tmpdir(), 'wp-asciiplayer-package-'));
|
||||
const target = path.join(temp, 'wp-asciiplayer');
|
||||
const inputs = ['asciicast-player.php', 'includes', 'build', 'LICENSE', 'licenses', 'THIRD-PARTY-NOTICES.md', 'README.md', 'README-zh.md', 'readme.txt', 'SOURCE.md', 'src', 'block.json', 'package.json', 'package-lock.json', 'webpack.config.cjs', 'babel.config.json', 'scripts'];
|
||||
const inputs = ['asciicast-player.php', 'includes', 'build', 'languages', 'LICENSE', 'licenses', 'THIRD-PARTY-NOTICES.md', 'README.md', 'README-zh.md', 'readme.txt', 'SOURCE.md', 'src', 'block.json', 'package.json', 'package-lock.json', 'webpack.config.cjs', 'babel.config.json', 'scripts'];
|
||||
try {
|
||||
await mkdir(target);
|
||||
for (const file of inputs) await cp(path.join(root, file), path.join(target, file), { recursive: true });
|
||||
|
||||
+10
-1
@@ -1,5 +1,6 @@
|
||||
import { copyFile, mkdir, readFile } from 'node:fs/promises';
|
||||
import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { createHash } from 'node:crypto';
|
||||
|
||||
const root = path.resolve(import.meta.dirname, '..');
|
||||
const pkg = JSON.parse(await readFile(path.join(root, 'node_modules/asciinema-player/package.json'), 'utf8'));
|
||||
@@ -13,3 +14,11 @@ for (const [source, destination] of [
|
||||
}
|
||||
await copyFile(path.join(root, 'block.json'), path.join(root, 'build/block.json'));
|
||||
console.log(`Bundled local asciinema-player ${pkg.version}; no CDN is used.`);
|
||||
|
||||
// Content hashes avoid stale assets across successive builds of 1.1.0-dev.
|
||||
const versions = [];
|
||||
for (const file of ['player.js', 'player.css', 'style-index.css', 'index.css']) {
|
||||
const hash = createHash('sha256').update(await readFile(path.join(root, 'build', file))).digest('hex').slice(0, 16);
|
||||
versions.push(`'${file}' => '${hash}'`);
|
||||
}
|
||||
await writeFile(path.join(root, 'build/runtime.asset.php'), `<?php return array(${versions.join(', ')});\n`);
|
||||
|
||||
+4
-2
@@ -135,6 +135,10 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
|
||||
<SelectControl label={ __( 'Fit', 'wp-asciiplayer' ) } value={ fit } options={ fitOptions } help={ [ 'height', 'both' ].includes( fit ) ? __( 'Height-based fitting requires a fixed container height in your site CSS.', 'wp-asciiplayer' ) : undefined } onChange={ ( value ) => setAttributes( { fit: value } ) } />
|
||||
{ attributes.legacyStyle && <p>{ __( 'The custom container style from your shortcode is preserved on the published page.', 'wp-asciiplayer' ) }</p> }
|
||||
</PanelBody>
|
||||
<PanelBody title={ __( 'Help', 'wp-asciiplayer' ) } initialOpen={ false }>
|
||||
<p className="asciiplayer-editor__privacy">{ __( 'A valid recording URL loads its preview automatically, including when reopening this editor. That server receives your browser’s request. Published players contact the same server. Use a direct .cast URL; external servers must allow CORS.', 'wp-asciiplayer' ) }</p>
|
||||
<p className="asciiplayer-editor__hint">{ __( 'Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.', 'wp-asciiplayer' ) }</p>
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
<div { ...blockProps }>
|
||||
<div className="asciiplayer-editor__source">
|
||||
@@ -148,7 +152,6 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
|
||||
) } />
|
||||
</MediaUploadCheck>
|
||||
{ mediaError && <Notice status="error" isDismissible={ false }>{ __( 'Choose an Asciicast (.cast) file from the Media Library.', 'wp-asciiplayer' ) }</Notice> }
|
||||
<p className="asciiplayer-editor__privacy">{ __( 'A valid recording URL loads its preview automatically, including when reopening this editor. That server receives your browser’s request. Published players contact the same server. Use a direct .cast URL; external servers must allow CORS.', 'wp-asciiplayer' ) }</p>
|
||||
{ urlError && <Notice status="error" isDismissible={ false }>{ __( 'Enter an HTTP(S) recording URL or a path starting with a single /.', 'wp-asciiplayer' ) }</Notice> }
|
||||
</div>
|
||||
<figure className={ `asciiplayer-figure asciiplayer-align-${ placement }` } style={ { width: normalizeWidth( width ) } }>
|
||||
@@ -161,7 +164,6 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
|
||||
) }
|
||||
<RichText tagName="figcaption" className={ `wp-element-caption${ ! isSelected && ! caption ? ' asciiplayer-caption-empty' : '' }` } value={ caption } allowedFormats={ [] } onChange={ ( value ) => setAttributes( { caption: value } ) } placeholder={ __( 'Add a caption…', 'wp-asciiplayer' ) } aria-label={ __( 'Recording caption', 'wp-asciiplayer' ) } />
|
||||
</figure>
|
||||
{ showPreview && <p className="asciiplayer-editor__hint">{ __( 'Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.', 'wp-asciiplayer' ) }</p> }
|
||||
{ [ 'height', 'both' ].includes( fit ) && <p className="asciiplayer-editor__hint">{ __( 'Height-based previews use the shortcode’s fixed height when available, or a 320px editor frame. Published height still comes from your container style.', 'wp-asciiplayer' ) }</p> }
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createBlock, registerBlockType } from '@wordpress/blocks';
|
||||
import { next } from '@wordpress/shortcode';
|
||||
import { decodeEntities } from '@wordpress/html-entities';
|
||||
import metadata from '../block.json';
|
||||
import { _x } from '@wordpress/i18n';
|
||||
import Edit from './edit.js';
|
||||
import { attributesFromShortcode, canTransformShortcode, normalizeSource } from './options.js';
|
||||
import './style.css';
|
||||
@@ -14,6 +15,9 @@ function matchShortcodeBlock( text = '' ) {
|
||||
|
||||
registerBlockType( metadata.name, {
|
||||
...metadata,
|
||||
title: _x( 'Asciicast Player', 'block title', 'wp-asciiplayer' ),
|
||||
description: _x( 'Embed and preview a terminal recording with the locally bundled asciinema player.', 'block description', 'wp-asciiplayer' ),
|
||||
keywords: [ _x( 'asciinema', 'block keyword', 'wp-asciiplayer' ), _x( 'terminal', 'block keyword', 'wp-asciiplayer' ), _x( 'recording', 'block keyword', 'wp-asciiplayer' ) ],
|
||||
edit: Edit,
|
||||
save: () => null,
|
||||
transforms: {
|
||||
|
||||
@@ -16,6 +16,9 @@ npm run package
|
||||
mkdir -p .wp-env-uploads
|
||||
npm run wp-env -- start
|
||||
npm run wp-env -- run cli wp plugin install /var/www/html/wp-content/asciiplayer-packages/wp-asciiplayer.zip --activate --force
|
||||
npm run wp-env -- run cli wp language core install zh_CN
|
||||
npm run wp-env -- run cli wp site switch-language en_US
|
||||
npm run wp-env -- run cli wp user meta update admin locale en_US
|
||||
npx --no-install playwright install chromium
|
||||
npm run test:e2e
|
||||
npm run wp-env -- stop
|
||||
@@ -88,3 +91,15 @@ overrides, URL replacement, error/empty states and recorded resize events.
|
||||
The Media Library tests use actual isolated WordPress upload dialogs to upload
|
||||
validated fixtures, reject malformed casts, cancel/reopen and select an existing
|
||||
recording. No production-site media is accessed.
|
||||
|
||||
## Plugin localization
|
||||
|
||||
Five `@i18n` cases set real site and user languages via the authenticated WordPress
|
||||
REST API, covering all en_US/zh_CN combinations and site-default inheritance.
|
||||
They verify bundled PHP upload errors, editor metadata and controls, recoverable
|
||||
preview errors, and logged-in/anonymous frontend messages. Author captions and
|
||||
actual recording content remain unchanged, and upstream player controls stay
|
||||
English. Original site/user locale values are restored after each test.
|
||||
Run these only against the isolated test site, with zh_CN installed first.
|
||||
CI runs the existing English suite before the locale suite and retains separate
|
||||
reports/screenshots. No catalog data is injected into the browser by the tests.
|
||||
|
||||
@@ -267,8 +267,21 @@ test('a saved Recording URL loads once without a click and never autoplays in th
|
||||
await readyPreview(block);
|
||||
await expect(block.getByRole('button', { name: 'Load preview', exact: true })).toHaveCount(0);
|
||||
await expect(block.locator('.ap-overlay-start .ap-play-button')).toBeVisible();
|
||||
await expect(block.locator('.asciiplayer-editor__privacy')).toContainText(/automatic/i);
|
||||
await expect(block.locator('.asciiplayer-editor__privacy')).toContainText(/server/i);
|
||||
await expect(block.locator('.asciiplayer-editor__privacy')).toHaveCount(0);
|
||||
await expect(block.locator(':scope > .asciiplayer-editor__hint')).toHaveCount(0);
|
||||
await expect(block.getByRole('textbox', { name: 'Recording URL', exact: true })).toBeVisible();
|
||||
await expect(block.getByRole('button', { name: 'Choose recording', exact: true })).toBeVisible();
|
||||
await expect(block.locator('figcaption[contenteditable="true"]')).toBeVisible();
|
||||
await page.evaluate(() => window.wp.data.dispatch('core/edit-post').openGeneralSidebar('edit-post/block'));
|
||||
const helpToggle = page.locator('.components-panel__body-toggle').filter({ hasText: /^Help$/ });
|
||||
await expect(helpToggle).toHaveAttribute('aria-expanded', 'false');
|
||||
await helpToggle.click();
|
||||
const help = page.locator('.components-panel__body').filter({ has: helpToggle });
|
||||
await expect(help.locator('.asciiplayer-editor__privacy')).toContainText(/automatic/i);
|
||||
await expect(help.locator('.asciiplayer-editor__privacy')).toContainText(/server/i);
|
||||
await expect(help).toContainText('Use the player controls to play, pause, and seek.');
|
||||
await helpToggle.click();
|
||||
await expect(helpToggle).toHaveAttribute('aria-expanded', 'false');
|
||||
await page.waitForTimeout(750); // Catch a second fetch from a pending debounce.
|
||||
expect(requests).toEqual([source]);
|
||||
await expect(block.locator('.ap-overlay-start .ap-play-button')).toBeVisible();
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
import { test as base, expect } from '@playwright/test';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
const blockName = 'lamgc/asciiplayer';
|
||||
const fixturePath = '/wp-content/uploads/asciiplayer-fixtures';
|
||||
const copy = {
|
||||
en_US: {
|
||||
title: 'Asciicast Player', source: 'Recording URL', apply: 'Apply URL',
|
||||
choose: 'Choose recording', dimensions: 'Terminal size', columns: 'Columns', rows: 'Rows',
|
||||
help: 'Help', retry: 'Retry preview', captionLabel: 'Recording caption',
|
||||
previewError: 'Unable to load the recording. Check the URL, file format, and the source server’s CORS permissions.',
|
||||
frontendError: 'Unable to load this terminal recording. The file may be unavailable, invalid, or blocked by the source server’s CORS policy.',
|
||||
uploadError: 'Upload a valid Asciicast v2/v3 JSONL or pretty-printed v1 .cast recording (up to 32 MiB; v1 up to 2 MiB, 100,000 events, 256 KiB per JSONL line, and 1,000 columns or rows).',
|
||||
},
|
||||
zh_CN: {
|
||||
title: 'Asciicast 播放器', source: '录制文件 URL', apply: '应用 URL',
|
||||
choose: '选择录制文件', dimensions: '终端尺寸', columns: '列数', rows: '行数',
|
||||
help: '帮助', retry: '重试预览', captionLabel: '录屏说明文字',
|
||||
previewError: '无法加载录制文件。请检查 URL、文件格式及来源服务器的跨域请求(CORS)权限。',
|
||||
frontendError: '无法加载此终端录屏。文件可能无法访问、格式无效,或被来源服务器的跨域请求(CORS)策略阻止。',
|
||||
uploadError: '请上传有效的 Asciicast v2/v3 JSONL 或格式化的 v1 .cast 录制文件(最大 32 MiB;v1 最大 2 MiB;最多 100,000 个事件;每行 JSONL最大 256 KiB;列数和行数均不超过 1,000)。',
|
||||
},
|
||||
};
|
||||
|
||||
async function login(page) {
|
||||
await page.goto('/wp-login.php');
|
||||
await page.locator('#user_login').fill(process.env.WP_USERNAME || 'admin');
|
||||
await page.locator('#user_pass').fill(process.env.WP_PASSWORD || 'password');
|
||||
await page.locator('#wp-submit').click();
|
||||
await expect(page).toHaveURL(/\/wp-admin\//);
|
||||
}
|
||||
|
||||
async function openEditor(page) {
|
||||
await page.goto('/wp-admin/post-new.php');
|
||||
await page.waitForFunction((name) => Boolean(
|
||||
window.wp?.apiFetch && window.wp?.blocks?.getBlockType(name) &&
|
||||
window.wp?.data?.select('core/editor')?.getCurrentPostId()
|
||||
), blockName);
|
||||
await page.evaluate(() => {
|
||||
for (const scope of ['core/edit-post', 'core/editor']) {
|
||||
window.wp.data.dispatch('core/preferences').set(scope, 'welcomeGuide', false);
|
||||
}
|
||||
});
|
||||
await expect(page.locator('iframe[name="editor-canvas"]')).toBeVisible();
|
||||
}
|
||||
|
||||
// Change actual WordPress settings, never navigator.language or wp.i18n mocks.
|
||||
// Keep an authenticated control page alive so cleanup also works if a test
|
||||
// finishes on the public site or fails during a player/media interaction.
|
||||
const test = base.extend({
|
||||
localeSession: async ({ context }, use) => {
|
||||
const control = await context.newPage();
|
||||
await login(control);
|
||||
await control.goto('/wp-admin/profile.php');
|
||||
const language = control.locator('#locale');
|
||||
await expect(language, 'Install the zh_CN core language pack before this suite.').toBeVisible();
|
||||
await expect(language.locator('option[value="zh_CN"]')).toHaveCount(1);
|
||||
const selectedUserLocale = await language.inputValue();
|
||||
const originalUserLocale = selectedUserLocale === 'site-default' ? '' : selectedUserLocale;
|
||||
await openEditor(control);
|
||||
const originalSiteLocale = await control.evaluate(async () =>
|
||||
(await window.wp.apiFetch({ path: '/wp/v2/settings' })).language
|
||||
);
|
||||
const setLocales = async (siteLocale, userLocale) => control.evaluate(async ({ site, user }) => {
|
||||
const settings = await window.wp.apiFetch({ path: '/wp/v2/settings', method: 'POST', data: { language: site } });
|
||||
const currentUser = await window.wp.apiFetch({ path: '/wp/v2/users/me', method: 'POST', data: { locale: user } });
|
||||
return { site: settings.language || 'en_US', user: currentUser.locale };
|
||||
}, { site: siteLocale, user: userLocale });
|
||||
try {
|
||||
await use({ setLocales, control });
|
||||
} finally {
|
||||
await setLocales(originalSiteLocale, originalUserLocale);
|
||||
await control.close();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
async function insertPlayer(page) {
|
||||
const id = await page.evaluate((name) => {
|
||||
const block = window.wp.blocks.createBlock(name, { controls: 'always' });
|
||||
window.wp.data.dispatch('core/block-editor').insertBlocks(block);
|
||||
window.wp.data.dispatch('core/block-editor').selectBlock(block.clientId);
|
||||
return block.clientId;
|
||||
}, blockName);
|
||||
return page.frameLocator('iframe[name="editor-canvas"]').locator(`[data-block="${id}"]`);
|
||||
}
|
||||
|
||||
async function assertTranslatedError(locator, locale, kind) {
|
||||
// Expected strings are independent literals, never read from the loaded
|
||||
// catalog: a missing translation must fail instead of defining expectations.
|
||||
await expect(locator).toHaveText(copy[locale][kind]);
|
||||
}
|
||||
|
||||
async function rejectInvalidUpload(page, block, locale, testInfo) {
|
||||
await block.getByRole('button', { name: copy[locale].choose, exact: true }).click();
|
||||
const dialog = page.locator('.media-modal[role="dialog"]');
|
||||
await expect(dialog).toBeVisible();
|
||||
await dialog.locator('#menu-item-upload').click();
|
||||
const input = page.locator('.moxie-shim input[type="file"]').last();
|
||||
await expect(input).toBeAttached();
|
||||
const response = page.waitForResponse((result) =>
|
||||
/\/wp-admin\/async-upload\.php(?:\?|$)/.test(result.url()) && result.request().method() === 'POST'
|
||||
);
|
||||
await input.setInputFiles({
|
||||
name: `asciiplayer-locale-invalid-${Date.now()}-${testInfo.retry}.cast`,
|
||||
mimeType: 'application/x-asciicast',
|
||||
buffer: await readFile(new URL('../fixtures/malformed.cast', import.meta.url)),
|
||||
});
|
||||
const result = await (await response).json();
|
||||
expect(result.success, JSON.stringify(result)).toBe(false);
|
||||
expect(result.data.message).toBe(copy[locale].uploadError);
|
||||
await expect(dialog).toContainText(result.data.message);
|
||||
await expect(dialog.locator('.media-button-select')).toBeDisabled();
|
||||
await dialog.locator('.media-modal-close').click();
|
||||
}
|
||||
|
||||
async function verifyFrontend(page, url, locale) {
|
||||
await page.goto(url);
|
||||
await expect(page.locator('html')).toHaveAttribute('lang', locale === 'zh_CN' ? /^zh-(CN|Hans)$/ : 'en-US');
|
||||
const players = page.locator('.asciiplayer-container');
|
||||
await expect(players).toHaveCount(3);
|
||||
await assertTranslatedError(players.nth(1).locator('.asciiplayer-error'), locale, 'frontendError');
|
||||
for (const index of [0, 2]) {
|
||||
const player = players.nth(index);
|
||||
await expect(player.locator('.ap-wrapper')).toBeVisible();
|
||||
await player.locator('.ap-overlay-start .ap-play-button').click();
|
||||
await expect(player.locator('.ap-term-text')).toContainText('Hello from wp-asciiplayer');
|
||||
}
|
||||
await expect(page.locator('.asciiplayer-figure figcaption')).toHaveText('Author caption / 作者说明');
|
||||
}
|
||||
|
||||
test.describe('@i18n real WordPress site and user locales', () => {
|
||||
// Locale is site-global. The repository config has one worker; do not run
|
||||
// these cases concurrently against a shared WordPress database.
|
||||
test.describe.configure({ mode: 'default' });
|
||||
for (const [siteLocale, userLocale] of [
|
||||
['en_US', 'en_US'], ['zh_CN', 'zh_CN'],
|
||||
['zh_CN', 'en_US'], ['en_US', 'zh_CN'],
|
||||
]) {
|
||||
test(`site ${siteLocale}, user ${userLocale}: editor, PHP upload and public player`, async ({ page, browser, localeSession }, testInfo) => {
|
||||
test.setTimeout(150_000);
|
||||
const locales = await localeSession.setLocales(siteLocale, userLocale);
|
||||
expect(locales).toEqual({ site: siteLocale, user: userLocale });
|
||||
const ui = copy[userLocale];
|
||||
const pageErrors = [];
|
||||
page.on('pageerror', (error) => pageErrors.push(error.message));
|
||||
await openEditor(page);
|
||||
await expect(page.locator('html')).toHaveAttribute('lang', userLocale === 'zh_CN' ? /^zh-(CN|Hans)$/ : 'en-US');
|
||||
expect(await page.evaluate((name) => window.wp.blocks.getBlockType(name).title, blockName)).toBe(ui.title);
|
||||
const block = await insertPlayer(page);
|
||||
const source = block.getByRole('textbox', { name: ui.source, exact: true });
|
||||
await expect(source).toBeVisible();
|
||||
await expect(block.getByRole('button', { name: ui.apply, exact: true })).toBeVisible();
|
||||
await expect(block.getByRole('button', { name: ui.choose, exact: true })).toBeVisible();
|
||||
await expect(block.locator('figcaption[contenteditable="true"]')).toHaveAttribute('aria-label', ui.captionLabel);
|
||||
|
||||
await page.evaluate(() => window.wp.data.dispatch('core/edit-post').openGeneralSidebar('edit-post/block'));
|
||||
await page.locator('.components-panel__body-toggle').filter({ hasText: new RegExp(`^${ui.dimensions}$`) }).click();
|
||||
await expect(page.getByRole('spinbutton', { name: ui.columns, exact: true })).toBeVisible();
|
||||
await expect(page.getByRole('spinbutton', { name: ui.rows, exact: true })).toBeVisible();
|
||||
await expect(page.locator('.components-panel__body-toggle').filter({ hasText: new RegExp(`^${ui.help}$`) })).toBeVisible();
|
||||
|
||||
const valid = new URL(`${fixturePath}/hello.cast`, page.url()).href;
|
||||
const missing = new URL(`${fixturePath}/missing-i18n.cast`, page.url()).href;
|
||||
await source.fill(missing);
|
||||
await block.getByRole('button', { name: ui.apply, exact: true }).click();
|
||||
await expect(block.locator('.asciiplayer-editor__preview')).toHaveAttribute('data-preview-status', 'error');
|
||||
await assertTranslatedError(block.locator('.components-notice__content > p'), userLocale, 'previewError');
|
||||
await expect(block.getByRole('button', { name: ui.retry, exact: true })).toBeVisible();
|
||||
await source.fill(valid);
|
||||
await block.getByRole('button', { name: ui.apply, exact: true }).click();
|
||||
await expect(block.locator('.asciiplayer-editor__preview')).toHaveAttribute('data-preview-status', 'ready');
|
||||
await block.locator('.ap-overlay-start .ap-play-button').click();
|
||||
await expect(block.locator('.ap-term-text')).toContainText('Hello from wp-asciiplayer');
|
||||
// Upstream 3.17.0 has no localization API. Its unmodified controls
|
||||
// deliberately retain their English accessibility labels in both locales.
|
||||
await expect(block.locator('.ap-playback-button')).toHaveAttribute('aria-label', 'Pause');
|
||||
await block.locator('.ap-playback-button').click();
|
||||
await expect(block.locator('.ap-playback-button')).toHaveAttribute('aria-label', 'Play');
|
||||
await rejectInvalidUpload(page, block, userLocale, testInfo);
|
||||
|
||||
const editorShot = testInfo.outputPath(`editor-${siteLocale}-${userLocale}.png`);
|
||||
await page.screenshot({ path: editorShot, fullPage: true });
|
||||
await testInfo.attach('editor-locale', { path: editorShot, contentType: 'image/png' });
|
||||
const saved = await page.evaluate(async ({ name, good, bad }) => {
|
||||
const blockContent = window.wp.blocks.serialize(window.wp.blocks.createBlock(name, {
|
||||
source: good, controls: 'always', preload: true, caption: 'Author caption / 作者说明',
|
||||
}));
|
||||
return window.wp.apiFetch({ path: '/wp/v2/posts', method: 'POST', data: {
|
||||
title: `Asciiplayer locale integration ${Date.now()}`, status: 'publish',
|
||||
content: `${blockContent}\n[asciiplayer preload="true"]${bad}[/asciiplayer]\n[asciiplayer preload="true"]${good}[/asciiplayer]`,
|
||||
} });
|
||||
}, { name: blockName, good: valid, bad: missing });
|
||||
// A logged-in user's language must not leak into public frontend JS.
|
||||
await verifyFrontend(page, saved.link, siteLocale);
|
||||
const anonymous = await browser.newContext();
|
||||
try {
|
||||
const visitor = await anonymous.newPage();
|
||||
visitor.on('pageerror', (error) => pageErrors.push(error.message));
|
||||
await verifyFrontend(visitor, saved.link, siteLocale);
|
||||
const frontendShot = testInfo.outputPath(`frontend-${siteLocale}-${userLocale}.png`);
|
||||
await visitor.screenshot({ path: frontendShot, fullPage: true });
|
||||
await testInfo.attach('frontend-locale', { path: frontendShot, contentType: 'image/png' });
|
||||
} finally {
|
||||
await anonymous.close();
|
||||
}
|
||||
expect(pageErrors).toEqual([]);
|
||||
});
|
||||
}
|
||||
|
||||
test('a user with the site default language inherits zh_CN in the editor', async ({ page, localeSession }) => {
|
||||
expect(await localeSession.setLocales('zh_CN', '')).toEqual({ site: 'zh_CN', user: 'zh_CN' });
|
||||
await openEditor(page);
|
||||
expect(await page.evaluate((name) => window.wp.blocks.getBlockType(name).title, blockName)).toBe(copy.zh_CN.title);
|
||||
const block = await insertPlayer(page);
|
||||
await expect(block.getByRole('textbox', { name: copy.zh_CN.source, exact: true })).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import gettext from 'gettext-parser';
|
||||
|
||||
const po = gettext.po.parse(fs.readFileSync('languages/wp-asciiplayer-zh_CN.po'));
|
||||
const mo = gettext.mo.parse(fs.readFileSync('languages/wp-asciiplayer-zh_CN.mo'));
|
||||
const pot = gettext.po.parse(fs.readFileSync('languages/wp-asciiplayer.pot'));
|
||||
const editor = JSON.parse(fs.readFileSync('languages/wp-asciiplayer-zh_CN-lamgc-asciiplayer-editor.json')).locale_data.messages;
|
||||
const view = JSON.parse(fs.readFileSync('languages/wp-asciiplayer-zh_CN-lamgc-asciiplayer-view.json')).locale_data.messages;
|
||||
|
||||
test('all extracted strings and gettext contexts round-trip through MO and both script catalogs', () => {
|
||||
let count = 0;
|
||||
for (const [context, entries] of Object.entries(pot.translations)) {
|
||||
for (const entry of Object.values(entries)) {
|
||||
if (!entry.msgid) continue;
|
||||
count++;
|
||||
const translated = po.translations[context][entry.msgid].msgstr;
|
||||
assert.ok(translated[0]);
|
||||
assert.deepEqual(mo.translations[context][entry.msgid].msgstr, translated);
|
||||
const key = context ? `${context}\u0004${entry.msgid}` : entry.msgid;
|
||||
assert.deepEqual(editor[key], translated);
|
||||
assert.deepEqual(view[key], translated);
|
||||
}
|
||||
}
|
||||
assert.ok(count >= 75);
|
||||
});
|
||||
|
||||
test('catalogs use Chinese plural rules, exact locale, and standard WordPress textdomain', () => {
|
||||
assert.equal(po.headers.language, 'zh_CN');
|
||||
assert.equal(mo.headers.language, 'zh_CN');
|
||||
assert.equal(editor[''].lang, 'zh_CN');
|
||||
assert.equal(editor[''].domain, 'wp-asciiplayer');
|
||||
assert.equal(editor['']['plural-forms'], 'nplurals=1; plural=0;');
|
||||
assert.equal(editor['block title\u0004Asciicast Player'][0], 'Asciicast 播放器');
|
||||
assert.equal(editor['Recording URL'][0], '录制文件 URL');
|
||||
});
|
||||
|
||||
test('Unicode, punctuation, percentages and literal author content are preserved', () => {
|
||||
assert.equal(editor['Add a caption…'][0], '添加说明文字…');
|
||||
assert.match(editor['Use a CSS length, such as 480px or 65%. The player stays within its available space.'][0], /480px.*65%/);
|
||||
assert.equal(editor['Author caption / 作者说明'], undefined);
|
||||
const serialized = JSON.stringify(editor);
|
||||
assert.deepEqual(JSON.parse(serialized), editor);
|
||||
});
|
||||
@@ -20,6 +20,12 @@ function add_action( $hook, $callback, $priority = 10 ) {
|
||||
function add_filter( $hook, $callback, $priority = 10, $accepted_args = 1 ) {
|
||||
ap_record( 'filters', array( $hook, $callback, $priority, $accepted_args ) );
|
||||
}
|
||||
function load_plugin_textdomain( $domain, $deprecated, $path ) {
|
||||
ap_record( 'textdomains', array( $domain, $path ) );
|
||||
}
|
||||
function plugin_basename( $file ) {
|
||||
return 'wp-asciiplayer/asciicast-player.php';
|
||||
}
|
||||
function __( $text, $domain = 'default' ) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
+10
-2
@@ -48,6 +48,14 @@ try {
|
||||
same( true, is_callable( $action[1] ), 'Every registered callback is callable.' );
|
||||
}
|
||||
register_plugin();
|
||||
same( array( 'wp-asciiplayer', 'wp-asciiplayer/languages' ), $GLOBALS['ap_test']['textdomains'][0], 'Bundled PHP catalogs register during init.' );
|
||||
if ( file_exists( dirname( __DIR__, 2 ) . '/build/runtime.asset.php' ) ) {
|
||||
$versions = require dirname( __DIR__, 2 ) . '/build/runtime.asset.php';
|
||||
same( $versions['player.js'], $GLOBALS['ap_test']['scripts']['lamgc-asciiplayer-player']['version'], 'Player script uses its content hash.' );
|
||||
foreach ( array( 'lamgc-asciiplayer-player-style' => 'player.css', 'lamgc-asciiplayer-style' => 'style-index.css', 'lamgc-asciiplayer-editor-style' => 'index.css' ) as $handle => $file ) {
|
||||
same( $versions[ $file ], $GLOBALS['ap_test']['styles'][ $handle ]['version'], 'Each stylesheet uses its own content hash.' );
|
||||
}
|
||||
}
|
||||
same( 'asciiplayer', $GLOBALS['ap_test']['shortcodes'][0][0], 'Legacy shortcode stays registered.' );
|
||||
contains( '/build', $GLOBALS['ap_test']['blocks'][0]['path'], 'Block uses local metadata.' );
|
||||
same( 'LamGC\\Asciiplayer\\render_block', $GLOBALS['ap_test']['blocks'][0]['args']['render_callback'], 'Block is server rendered.' );
|
||||
@@ -60,8 +68,8 @@ try {
|
||||
same( array( 'lamgc-asciiplayer-player-style' ), $GLOBALS['ap_test']['styles']['lamgc-asciiplayer-style']['deps'], 'Frontend style depends on player stylesheet.' );
|
||||
contains( 'window.wpAsciiplayerSettings = ', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Editor iframe receives trusted runtime URLs.' );
|
||||
same( 'before', $GLOBALS['ap_test']['inline_scripts'][0]['position'], 'Settings are available before editor boot.' );
|
||||
contains( 'player.js?ver=1.2.2', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge JavaScript cache-buster matches registered asset version.' );
|
||||
contains( 'player.css?ver=1.2.2', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge CSS cache-buster matches registered asset version.' );
|
||||
contains( 'player.js?ver=' . $GLOBALS['ap_test']['scripts']['lamgc-asciiplayer-player']['version'], $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge JavaScript cache-buster matches registered asset version.' );
|
||||
contains( 'player.css?ver=' . $GLOBALS['ap_test']['styles']['lamgc-asciiplayer-player-style']['version'], $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge CSS cache-buster matches registered asset version.' );
|
||||
|
||||
// Source validation covers script, HTML, credential and relative-URL attacks.
|
||||
foreach ( array( '', 'javascript:alert(1)', 'data:text/html,test', 'file:///tmp/a.cast', '//evil.test/a.cast', '/\\evil.test/a.cast', "https://example.test/a\n.cast", 'https://x.test/" onmouseover="alert(1)', 'https://user:[email protected]/a.cast', 'https:///a.cast', 'a.cast', array( 'bad' ) ) as $source ) {
|
||||
|
||||
Reference in New Issue
Block a user