From da9ddac36538f73280592c8b78c03dbe6198425c Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Tue, 27 Aug 2024 14:53:40 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=92=84=20Add=20inLanguage=20field=20f?= =?UTF-8?q?or=20book?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/IscnRegisterForm.vue | 66 +++++++++++++++++++++++---------- locales/en.json | 1 + 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index 897cb8d8..026f5c9e 100644 --- a/components/IscnRegisterForm.vue +++ b/components/IscnRegisterForm.vue @@ -122,14 +122,25 @@ - - - +
+ + + + + + +
+
@@ -691,19 +702,24 @@ export default class IscnRegisterForm extends Vue { @walletModule.Action('initIfNecessary') initIfNecessary!: () => Promise typeOptions = [ -'Book', -'Photo', -'Image', -'CreativeWork', -] + 'Book', + 'Photo', + 'Image', + 'CreativeWork', + ] fileTypeOptions = [ -'epub', -'pdf', -'audio', -'jpg', -'png', -] + 'epub', + 'pdf', + 'audio', + 'jpg', + 'png', + ] + + languageOptions = [ + 'zh', + 'en', + ] licenseMap: { [key: string]: string | null } = { 'Copyright. All rights reserved.': 'All Rights Reserved', @@ -850,6 +866,10 @@ export default class IscnRegisterForm extends Vue { return 'CreativeWork' } + get defaultLanguage() { + return this.epubMetadata?.language || 'zh' + } + get authorDialogTitle() { return this.currentAuthorDialogType === AuthorDialogType.author ? this.$t('IscnRegisterForm.title.editAuthor') @@ -1053,6 +1073,10 @@ export default class IscnRegisterForm extends Vue { return arweaveIdList } + get isBookType() { + return this.type === 'Book' + } + @Watch('payload', { immediate: true, deep: true }) change() { this.debouncedCalculateISCNFee() @@ -1237,6 +1261,10 @@ export default class IscnRegisterForm extends Vue { this.type = value } + setLanguage(value: string) { + this.language = value + } + setLicense(value: string) { this.license = value } diff --git a/locales/en.json b/locales/en.json index 7a6d497b..275821e5 100644 --- a/locales/en.json +++ b/locales/en.json @@ -239,6 +239,7 @@ "IscnRegisterForm.label.registrant": "Registrant", "IscnRegisterForm.label.tags": "Tags", "IscnRegisterForm.label.type": "Type", + "IscnRegisterForm.label.language": "Language", "IscnRegisterForm.label.content": "Content Info", "IscnRegisterForm.label.uploading": "Loading files...", "IscnRegisterForm.label.url": "URL", From f01d61880c0afdffa2c6f09392cc083ecc9c508c Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Fri, 30 Aug 2024 22:47:43 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=9A=B8=20Auto=20detect=20language=20f?= =?UTF-8?q?or=20book?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/IscnRegisterForm.vue | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index 026f5c9e..b917cb56 100644 --- a/components/IscnRegisterForm.vue +++ b/components/IscnRegisterForm.vue @@ -140,7 +140,7 @@ />
- +
@@ -867,7 +867,14 @@ export default class IscnRegisterForm extends Vue { } get defaultLanguage() { - return this.epubMetadata?.language || 'zh' + const containsChinese = (str: any) => /[\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF]/.test(str); + + const isEpubInChinese = this.epubMetadata?.language === 'zh' + + const titleContainsChinese = this.name ? containsChinese(this.name) : isEpubInChinese; + const descriptionContainsChinese = this.description ? containsChinese(this.description) : isEpubInChinese; + + return (titleContainsChinese || descriptionContainsChinese) ? 'zh' : 'en'; } get authorDialogTitle() { @@ -1087,6 +1094,11 @@ export default class IscnRegisterForm extends Vue { if (errormsg) this.isOpenWarningSnackbar = true } + @Watch('defaultLanguage', { immediate: true }) + setLanguageValue(value: any) { + this.language = value + } + async mounted() { this.uploadStatus = 'loading' @@ -1095,7 +1107,6 @@ export default class IscnRegisterForm extends Vue { this.description = this.extractText(this.epubMetadata.description) this.author.name = this.epubMetadata.author || '' this.author.authorDescription = 'Author' - this.language = this.epubMetadata.language || '' this.tags = this.epubMetadata.tags || [] this.thumbnailUrl = this.formatArweave( this.epubMetadata.thumbnailArweaveId, From 7013a40c386ad473a0d62cd0b2a72b6d17512961 Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Mon, 2 Sep 2024 21:38:05 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=8E=A8=20Simplify=20default=20languag?= =?UTF-8?q?e=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/IscnRegisterForm.vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index b917cb56..5a97c02e 100644 --- a/components/IscnRegisterForm.vue +++ b/components/IscnRegisterForm.vue @@ -867,15 +867,15 @@ export default class IscnRegisterForm extends Vue { } get defaultLanguage() { - const containsChinese = (str: any) => /[\u4E00-\u9FFF\u3400-\u4DBF\uF900-\uFAFF]/.test(str); + const containsOnlyASCII = (str: string) => /^[ -~]*$/.test(str); - const isEpubInChinese = this.epubMetadata?.language === 'zh' + const isEpubInChinese = this.epubMetadata?.language === 'zh'; - const titleContainsChinese = this.name ? containsChinese(this.name) : isEpubInChinese; - const descriptionContainsChinese = this.description ? containsChinese(this.description) : isEpubInChinese; + const titleContainsNonASCII = this.name && !containsOnlyASCII(this.name) + const descriptionContainsNonASCII = this.description && !containsOnlyASCII(this.description) - return (titleContainsChinese || descriptionContainsChinese) ? 'zh' : 'en'; - } + return (isEpubInChinese || titleContainsNonASCII || descriptionContainsNonASCII) ? 'zh' : 'en'; +} get authorDialogTitle() { return this.currentAuthorDialogType === AuthorDialogType.author From 7f5a5a736db1c90c64104b9d9de553a2262d92d4 Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Tue, 3 Sep 2024 11:17:58 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=8E=A8=20Prioritize=20language=20from?= =?UTF-8?q?=20epubMetadata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/IscnRegisterForm.vue | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/components/IscnRegisterForm.vue b/components/IscnRegisterForm.vue index 5a97c02e..e602e862 100644 --- a/components/IscnRegisterForm.vue +++ b/components/IscnRegisterForm.vue @@ -867,15 +867,18 @@ export default class IscnRegisterForm extends Vue { } get defaultLanguage() { - const containsOnlyASCII = (str: string) => /^[ -~]*$/.test(str); + const containsOnlyASCII = (str: string) => /^[ -~]*$/.test(str) + const epubLanguage = this.epubMetadata?.language; - const isEpubInChinese = this.epubMetadata?.language === 'zh'; + if (epubLanguage === 'zh' || epubLanguage === 'en') { + return epubLanguage; + } const titleContainsNonASCII = this.name && !containsOnlyASCII(this.name) - const descriptionContainsNonASCII = this.description && !containsOnlyASCII(this.description) - - return (isEpubInChinese || titleContainsNonASCII || descriptionContainsNonASCII) ? 'zh' : 'en'; -} + const descriptionContainsNonASCII = + this.description && !containsOnlyASCII(this.description) + return titleContainsNonASCII || descriptionContainsNonASCII ? 'zh' : 'en' + } get authorDialogTitle() { return this.currentAuthorDialogType === AuthorDialogType.author