Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(i18n): add Farsi (fa) and Pashto (pa) locales for internationalization of controls #147

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"@oplayer/ui": "file:../../packages/ui",
"dashjs": "^4.6.0",
"hls.js": "^1.5.15",
"lit": "^2.7.2"
"lit": "^2.8.0"
}
}
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@
"@babel/plugin-transform-parameters": "^7.25.9",
"@babel/plugin-transform-spread": "^7.25.9",
"@babel/plugin-transform-template-literals": "^7.25.9",
"@changesets/cli": "^2.27.9",
"@changesets/cli": "^2.27.11",
"@rollup/plugin-babel": "^6.0.4",
"@types/node": "^20.17.6",
"@vitejs/plugin-react": "^4.3.3",
"@types/node": "^20.17.11",
"@vitejs/plugin-react": "^4.3.4",
"babel-plugin-syntax-trailing-function-commas": "^6.22.0",
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
"jsdom": "^24.1.3",
"lint-staged": "^15.2.10",
"nx": "^19.8.11",
"prettier": "^3.3.3",
"lint-staged": "^15.3.0",
"nx": "^19.8.14",
"prettier": "^3.4.2",
"rimraf": "^5.0.10",
"terser": "^5.36.0",
"terser": "^5.37.0",
"tslib": "^2.8.1",
"typescript": "^5.6.3",
"typescript": "^5.7.2",
"vite": "^5.4.11",
"vite-plugin-banner": "^0.7.1",
"vite-plugin-merge-exports": "^0.0.0",
Expand Down
39 changes: 39 additions & 0 deletions packages/core/src/i18n/fa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"Play": "پخش",
"Next": "بعدی",
"Previous": "قبلی",
"Pause": "توقف",
"Loop": "تکرار",
"Volume": "حجم صدا",
"Volume: %s": "حجم صدا: %s",
"Mute": "بی‌صدا کردن",
"Speed": "سرعت",
"LIVE": "زنده",
"WebFullscreen":"تمام صفحه وب",
"Chromecast": "کروم کاست",
"AirPlay":"ایر پلی",

"Language": "زبان",
"Screenshot": "عکس صفحه",
"Subtitle": "زیرنویس",
"Quality": "کیفیت",
"Fullscreen": "تمام صفحه",
"TextDecoder Not Supported": "رمزگشای متن پشتیبانی نمی‌شود",
"Settings": "تنظیمات",
"Picture in Picture": "تصویر در تصویر",

"Danmaku": "دانماکو",
"Display": "نمایش",
"Opacity": "شفافیت",
"FontSize": "اندازه فونت",
"Display Area": "ناحیه نمایش",

"Off": "خاموش",
"Auto": "خودکار",
"Default": "پیش‌فرض",
"Normal": "عادی",

"%ss": "%s ثانیه",
"Close": "بستن",
"Can be closed after %ss": "قابل بستن پس از %s ثانیه"
}
7 changes: 5 additions & 2 deletions packages/core/src/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import type { Lang } from '../types'
import { mergeDeep } from '../utils'
import CN from './zh-CN.json'

import FA from "./fa.json"
import PA from "./pa.json"
export default class I18n {
public lang: Lang

private languages: Partial<Record<Lang, any>> = {
zh: CN,
'zh-CN': CN,
fa: FA,
pa: PA,
en: Object.keys(CN).reduce<Record<string, string>>(
(previous, current) => ((previous[current] = current), previous),
{}
)
),
}

constructor(defaultLang: Lang) {
Expand Down
39 changes: 39 additions & 0 deletions packages/core/src/i18n/pa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"Play": "پلې‌کول",
"Next": "بل",
"Previous": "مخکېنی",
"Pause": "تم کول",
"Loop": "تکرار",
"Volume": "غږ",
"Volume: %s": "غږ: %s",
"Mute": "غلی کول",
"Speed": "چټکتیا",
"LIVE": "ژوندی",
"WebFullscreen":"د تمام صفحه وب",
"Chromecast": "کروم کاسټ",
"AirPlay":"ایر پلی",

"Language": "ژبه",
"Screenshot": "سکرین شاټ",
"Subtitle": "لاندې لیک",
"Quality": "کیفیت",
"Fullscreen": "پوره پرده",
"TextDecoder Not Supported": "د متن ډیکوډر ملاتړ نه لري",
"Settings": "ترتیبات",
"Picture in Picture": "انځور په انځور",

"Danmaku": "دانماکو",
"Display": "ښکاره کول",
"Opacity": "روڼوالی",
"FontSize": "د خط اندازه",
"Display Area": "د ښودلو ساحه",

"Off": "بند",
"Auto": "خودکار",
"Default": "پېل شوی",
"Normal": "عادي",

"%ss": "%s ثانیه",
"Close": "بندول",
"Can be closed after %ss": "د %s ثانیو وروسته تړل کېدای شي"
}
2 changes: 1 addition & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type Source = {
type?: VideoMimeType | HLSMimeType | DASHMimeType
}

export type Lang = 'auto' | 'zh' | 'zh-CN' | 'en'
export type Lang = 'auto' | 'zh' | 'zh-CN' | 'en' | 'fa' | 'pa'

export type VideoMimeType =
| 'video/mp4'
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/airplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AirPlay implements PlayerPlugin {
const { menu, icons } = this.player.context.ui

menu?.register({
name: 'AirPlay',
name: this.player.locales.get('AirPlay'),
position: 'top',
icon: icons.airplay || ICON,
onClick: () => this.start()
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/chromecast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Chromecast implements PlayerPlugin {
const { menu, icons } = this.player.context.ui

menu?.register({
name: 'Chromecast',
name: this.player.locales.get('Chromecast'),
position: 'top',
icon: icons.chromecast || ICON,
onClick: () => this.start()
Expand Down
Loading
Loading