diff --git a/.l10nignore b/.l10nignore deleted file mode 100644 index 89e7f37..0000000 --- a/.l10nignore +++ /dev/null @@ -1,14 +0,0 @@ -.idea/ -*.iml - -vendor/ -vendor-bin/*/vendor/ - -.php-cs-fixer.cache -tests/.phpunit.cache - -node_modules/ -js/ -css/ - -build/ diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 74670ab..8f79091 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -22,7 +22,6 @@ $config = new MyConfig(); $config ->getFinder() ->notPath('build') - ->notPath('l10n') ->notPath('node_modules') ->notPath('src') ->notPath('vendor') diff --git a/Makefile b/Makefile index c6d23db..245c44f 100644 --- a/Makefile +++ b/Makefile @@ -106,7 +106,6 @@ appstore: --exclude="$(app_name)/.*" \ --exclude="$(app_name)/js/.*" \ --exclude="$(app_name)/tsconfig.json" \ - --exclude="$(app_name)/stylelint.config.cjs" \ --exclude="$(app_name)/README.md" \ --exclude="$(app_name)/package-lock.json" \ --exclude="$(app_name)/LICENSE" \ @@ -129,17 +128,3 @@ dev: build docker build -t $(app_name) . docker run -itd --rm --name $(app_name) -v $(CURDIR):/var/www/html/apps/$(app_name) -p 80:80 $(app_name) npm run watch || docker stop $(app_name) - -# Generate translations -.PHONY: l10n -l10n: - docker run --rm \ - -v $(CURDIR):/app \ - --entrypoint php \ - nextcloudci/translations \ - /translationtool.phar create-pot-files - docker run --rm \ - -v $(CURDIR):/app \ - --entrypoint php \ - nextcloudci/translations \ - /translationtool.phar convert-po-files diff --git a/package-lock.json b/package-lock.json index 6fbcca3..5c5ce55 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,6 @@ "@emulatorjs/emulatorjs": "^4.2.1", "@nextcloud/auth": "^2.4.0", "@nextcloud/files": "^3.10.1", - "@nextcloud/initial-state": "^2.2.0", - "@nextcloud/l10n": "^3.1.0", "@nextcloud/router": "^3.0.1", "@nextcloud/vite-config": "^2.2.2", "vite": "~5.4.11" diff --git a/package.json b/package.json index 3fd44ba..3d61ec6 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,6 @@ "@emulatorjs/emulatorjs": "^4.2.1", "@nextcloud/auth": "^2.4.0", "@nextcloud/files": "^3.10.1", - "@nextcloud/initial-state": "^2.2.0", - "@nextcloud/l10n": "^3.1.0", "@nextcloud/router": "^3.0.1", "@nextcloud/vite-config": "^2.2.2", "vite": "~5.4.11" diff --git a/src/common.ts b/src/common.ts new file mode 100644 index 0000000..f075464 --- /dev/null +++ b/src/common.ts @@ -0,0 +1,42 @@ +import af from '@emulatorjs/emulatorjs/data/localization/af-FR.json' +import ar from '@emulatorjs/emulatorjs/data/localization/ar-AR.json' +import ben from '@emulatorjs/emulatorjs/data/localization/ben-BEN.json' +import de from '@emulatorjs/emulatorjs/data/localization/de-GER.json' +import el from '@emulatorjs/emulatorjs/data/localization/el-GR.json' +import es from '@emulatorjs/emulatorjs/data/localization/es-ES.json' +import fa from '@emulatorjs/emulatorjs/data/localization/fa-AF.json' +import hi from '@emulatorjs/emulatorjs/data/localization/hi-HI.json' +import it from '@emulatorjs/emulatorjs/data/localization/it-IT.json' +import ja from '@emulatorjs/emulatorjs/data/localization/ja-JA.json' +import jv from '@emulatorjs/emulatorjs/data/localization/jv-JV.json' +import ko from '@emulatorjs/emulatorjs/data/localization/ko-KO.json' +import pt from '@emulatorjs/emulatorjs/data/localization/pt-BR.json' +import ru from '@emulatorjs/emulatorjs/data/localization/ru-RU.json' +import tr from '@emulatorjs/emulatorjs/data/localization/tr-TR.json' +import vi from '@emulatorjs/emulatorjs/data/localization/vi-VN.json' +import zh from '@emulatorjs/emulatorjs/data/localization/zh-CN.json' + +export const localizations = { + af, + fr: af, + ar, + ben, + de, + el, + gr: el, + es, + fa, + hi, + it, + ja, + jv, + ko, + pt, + br: pt, + ru, + tr, + vi, + vn: vi, + zh, + cn: zh, +} diff --git a/src/init.ts b/src/init.ts index 730ea68..29ad6c4 100644 --- a/src/init.ts +++ b/src/init.ts @@ -9,7 +9,7 @@ import { import cores from './mime.json' import { generateUrl } from '@nextcloud/router' import icon from '../img/app.svg?raw' -import { t } from '@nextcloud/l10n' +import { localizations } from './common' const getCore = (file: Node) => { if (file.type === FileType.File && file.permissions & Permission.READ) { @@ -24,7 +24,7 @@ const getCore = (file: Node) => { const action = new FileAction({ id: 'retro', - displayName: () => t('repod', 'Play'), + displayName: () => localizations[document.documentElement.lang].Play || 'Play', iconSvgInline: () => icon, enabled: (files: Node[]) => { if (files.length !== 1) return false diff --git a/src/main.ts b/src/main.ts index 188c7d4..1c98163 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,50 +7,8 @@ import '@emulatorjs/emulatorjs/data/src/GameManager.js' import '@emulatorjs/emulatorjs/data/src/socket.io.min.js' import '@emulatorjs/emulatorjs/data/src/compression.js' import '@emulatorjs/emulatorjs/data/emulator.css' - -import af from '@emulatorjs/emulatorjs/data/localization/af-FR.json' -import ar from '@emulatorjs/emulatorjs/data/localization/ar-AR.json' -import ben from '@emulatorjs/emulatorjs/data/localization/ben-BEN.json' -import de from '@emulatorjs/emulatorjs/data/localization/de-GER.json' -import el from '@emulatorjs/emulatorjs/data/localization/el-GR.json' -import es from '@emulatorjs/emulatorjs/data/localization/es-ES.json' -import fa from '@emulatorjs/emulatorjs/data/localization/fa-AF.json' import { getRequestToken } from '@nextcloud/auth' -import hi from '@emulatorjs/emulatorjs/data/localization/hi-HI.json' -import it from '@emulatorjs/emulatorjs/data/localization/it-IT.json' -import ja from '@emulatorjs/emulatorjs/data/localization/ja-JA.json' -import jv from '@emulatorjs/emulatorjs/data/localization/jv-JV.json' -import ko from '@emulatorjs/emulatorjs/data/localization/ko-KO.json' -import pt from '@emulatorjs/emulatorjs/data/localization/pt-BR.json' -import ru from '@emulatorjs/emulatorjs/data/localization/ru-RU.json' -import tr from '@emulatorjs/emulatorjs/data/localization/tr-TR.json' -import vi from '@emulatorjs/emulatorjs/data/localization/vi-VN.json' -import zh from '@emulatorjs/emulatorjs/data/localization/zh-CN.json' - -const localizations = { - af, - fr: af, - ar, - ben, - de, - el, - gr: el, - es, - fa, - hi, - it, - ja, - jv, - ko, - pt, - br: pt, - ru, - tr, - vi, - vn: vi, - zh, - cn: zh, -} +import { localizations } from './common' type Config = { gameUrl?: string @@ -176,11 +134,6 @@ class MyEmulatorJS extends window.EmulatorJS { const config: Config = {} -config.language = document.documentElement.lang -if (Object.keys(localizations).includes(config.language)) { - config.langJson = localizations[config.language] -} - const gameUrl = new URL(location.href).searchParams.get('file') if (gameUrl) { config.gameUrl = gameUrl @@ -192,6 +145,8 @@ if (system) { } config.dataPath = 'https://cdn.emulatorjs.org/stable/data/' +config.language = document.documentElement.lang +config.langJson = localizations[config.language] config.threads = !!window.SharedArrayBuffer // eslint-disable-next-line no-new