From 0c0bcecb9e6e4d605c7d754f58d95dc7682c9d9f Mon Sep 17 00:00:00 2001 From: Harvey Zack Date: Sun, 17 Aug 2025 13:18:08 +0800 Subject: [PATCH] Add internationalization support and build process for multiple languages - Implemented a build script to compile i18n files and copy them to the docs directory. - Added compiled i18n files for Arabic, Czech, Spanish, Persian, French, Indonesian, Polish, Russian, Turkish, Vietnamese, and Traditional Chinese. - Created an HTML file to demonstrate the usage of Artplayer with i18n support, including language options and a sample video. --- docs/compiled/i18n/ar.js | 1 + docs/compiled/i18n/cs.js | 1 + docs/compiled/i18n/es.js | 1 + docs/compiled/i18n/fa.js | 1 + docs/compiled/i18n/fr.js | 1 + docs/compiled/i18n/id.js | 1 + docs/compiled/i18n/pl.js | 1 + docs/compiled/i18n/ru.js | 1 + docs/compiled/i18n/tr.js | 1 + docs/compiled/i18n/vi.js | 1 + docs/compiled/i18n/zh-tw.js | 1 + docs/i18n.html | 54 +++++++++++++++++++++++++++++++++++++ scripts/build-i18n.js | 4 ++- 13 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 docs/compiled/i18n/ar.js create mode 100644 docs/compiled/i18n/cs.js create mode 100644 docs/compiled/i18n/es.js create mode 100644 docs/compiled/i18n/fa.js create mode 100644 docs/compiled/i18n/fr.js create mode 100644 docs/compiled/i18n/id.js create mode 100644 docs/compiled/i18n/pl.js create mode 100644 docs/compiled/i18n/ru.js create mode 100644 docs/compiled/i18n/tr.js create mode 100644 docs/compiled/i18n/vi.js create mode 100644 docs/compiled/i18n/zh-tw.js create mode 100644 docs/i18n.html diff --git a/docs/compiled/i18n/ar.js b/docs/compiled/i18n/ar.js new file mode 100644 index 000000000..df699e26a --- /dev/null +++ b/docs/compiled/i18n/ar.js @@ -0,0 +1 @@ +!function(e,t,n,r,o,i,l,u){var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},d="function"==typeof f[r]&&f[r],a=d.i||{},c=d.cache||{},s="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,n){if(!c[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof f[r]&&f[r];if(!n&&i)return i(t,!0);if(d)return d(t,!0);if(s&&"string"==typeof t)return s(t);var l=Error("Cannot find module '"+t+"'");throw l.code="MODULE_NOT_FOUND",l}a.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},a.cache={};var u=c[t]=new p.Module(t);e[t][0].call(u.exports,a,u,u.exports,f)}return c[t].exports;function a(e){var t=a.resolve(e);return!1===t?{}:p(t)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=s,this.exports={}},p.modules=e,p.cache=c,p.parent=d,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=a,p.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(p,"root",{get:function(){return f[r]}}),f[r]=p;for(var y=0;y + + + + + Artplayer with i18n + + + + +
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/scripts/build-i18n.js b/scripts/build-i18n.js index 689d97e7a..e0870210f 100644 --- a/scripts/build-i18n.js +++ b/scripts/build-i18n.js @@ -2,11 +2,13 @@ import fs from 'node:fs' import path from 'node:path' import process from 'node:process' import { Parcel } from '@parcel/core' +import cpy from 'cpy' import { glob } from 'glob' const basePath = 'packages/artplayer' const i18nSrcDir = path.join(basePath, 'src/i18n') const distDir = path.join(basePath, 'dist/i18n') +const compiledPath = path.resolve('docs/compiled/i18n') const entries = glob.sync('*.js', { cwd: i18nSrcDir, @@ -42,7 +44,7 @@ const entries = glob.sync('*.js', { const { bundleGraph, buildTime } = await bundler.run() const bundles = bundleGraph.getBundles() console.log(`✨ Built [i18n] ${bundles.length} bundles in ${buildTime}ms`) - bundles.forEach(b => console.log('📦 Output:', b.filePath)) + await cpy(distDir, compiledPath) } catch (err) { console.error('❌ Build i18n failed.')