mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-24 06:40:20 +03:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cfaf63502 | ||
|
|
6db5c32bcd | ||
|
|
9bf1b93b07 | ||
|
|
7a4310ad90 | ||
|
|
c434a5f3f0 | ||
|
|
1b1be10762 |
No files matched your search
Vendored
+3
-4
@@ -20,7 +20,6 @@ declare module '@vue/runtime-core' {
|
||||
Bcrypt: typeof import('./src/tools/bcrypt/bcrypt.vue')['default']
|
||||
BenchmarkBuilder: typeof import('./src/tools/benchmark-builder/benchmark-builder.vue')['default']
|
||||
Bip39Generator: typeof import('./src/tools/bip39-generator/bip39-generator.vue')['default']
|
||||
BounceParser: typeof import('./src/tools/bounce-parser/bounce-parser.vue')['default']
|
||||
CAlert: typeof import('./src/ui/c-alert/c-alert.vue')['default']
|
||||
'CAlert.demo': typeof import('./src/ui/c-alert/c-alert.demo.vue')['default']
|
||||
CameraRecorder: typeof import('./src/tools/camera-recorder/camera-recorder.vue')['default']
|
||||
@@ -131,9 +130,10 @@ declare module '@vue/runtime-core' {
|
||||
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
|
||||
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
||||
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
||||
NCode: typeof import('naive-ui')['NCode']
|
||||
NCheckbox: typeof import('naive-ui')['NCheckbox']
|
||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||
NDivider: typeof import('naive-ui')['NDivider']
|
||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||
NH1: typeof import('naive-ui')['NH1']
|
||||
NH3: typeof import('naive-ui')['NH3']
|
||||
@@ -141,8 +141,7 @@ declare module '@vue/runtime-core' {
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
NP: typeof import('naive-ui')['NP']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NTable: typeof import('naive-ui')['NTable']
|
||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
||||
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
|
||||
|
||||
+1
-1
@@ -59,7 +59,6 @@
|
||||
"crypto-js": "^4.1.1",
|
||||
"date-fns": "^2.29.3",
|
||||
"dompurify": "^3.0.6",
|
||||
"email-bounce-parser-browser": "^1.1",
|
||||
"email-normalizer": "^1.0.0",
|
||||
"emojilib": "^3.0.10",
|
||||
"figlet": "^1.7.0",
|
||||
@@ -71,6 +70,7 @@
|
||||
"js-base64": "^3.7.6",
|
||||
"json5": "^2.2.3",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"korean-unpacker": "^1.0.3",
|
||||
"libphonenumber-js": "^1.10.28",
|
||||
"lodash": "^4.17.21",
|
||||
"markdown-it": "^14.0.0",
|
||||
|
||||
Generated
+7
-7
@@ -77,9 +77,6 @@ dependencies:
|
||||
dompurify:
|
||||
specifier: ^3.0.6
|
||||
version: 3.0.6
|
||||
email-bounce-parser-browser:
|
||||
specifier: ^1.1
|
||||
version: 1.1.0
|
||||
email-normalizer:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
@@ -113,6 +110,9 @@ dependencies:
|
||||
jwt-decode:
|
||||
specifier: ^3.1.2
|
||||
version: 3.1.2
|
||||
korean-unpacker:
|
||||
specifier: ^1.0.3
|
||||
version: 1.0.3
|
||||
libphonenumber-js:
|
||||
specifier: ^1.10.28
|
||||
version: 1.10.28
|
||||
@@ -5022,10 +5022,6 @@ packages:
|
||||
/electron-to-chromium@1.4.572:
|
||||
resolution: {integrity: sha512-RlFobl4D3ieetbnR+2EpxdzFl9h0RAJkPK3pfiwMug2nhBin2ZCsGIAJWdpNniLz43sgXam/CgipOmvTA+rUiA==}
|
||||
|
||||
/email-bounce-parser-browser@1.1.0:
|
||||
resolution: {integrity: sha512-aPMJKpvAPTFTqDI3/bMxcEHK3Wk2yy/tNK/nVWHl5zqyoxJFFgO5a2jvVno4V3e+kyLjZx2M5KJNgNmYf0ZkuQ==}
|
||||
dev: false
|
||||
|
||||
/email-normalizer@1.0.0:
|
||||
resolution: {integrity: sha512-wZYuuMtL4kUOmg/TPtCrf9hAZjbFq+FcjWA85Z5nr2lGllRnWJPxCJw3gy4Cx+adMoyVw4VJfGGvt/OHgIW+qg==}
|
||||
dependencies:
|
||||
@@ -6689,6 +6685,10 @@ packages:
|
||||
resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==}
|
||||
dev: true
|
||||
|
||||
/korean-unpacker@1.0.3:
|
||||
resolution: {integrity: sha512-s0VIyZOFOtalBSp51NECPvM1g9Af8M0Oxe1ZdMMGL7nvG/ecVNYkCAzPU+f52f0R83ytVCOd3fd14TTOFx2GXQ==}
|
||||
dev: false
|
||||
|
||||
/less@4.1.3:
|
||||
resolution: {integrity: sha512-w16Xk/Ta9Hhyei0Gpz9m7VS8F28nieJaL/VyShID7cYvP6IL5oHeL6p4TXSDJqZE/lNv0oJ2pGVjJsRkfwm5FA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
Binary file not shown.
@@ -7,15 +7,8 @@ import sqlHljs from 'highlight.js/lib/languages/sql';
|
||||
import xmlHljs from 'highlight.js/lib/languages/xml';
|
||||
import yamlHljs from 'highlight.js/lib/languages/yaml';
|
||||
import iniHljs from 'highlight.js/lib/languages/ini';
|
||||
import bashHljs from 'highlight.js/lib/languages/bash';
|
||||
import markdownHljs from 'highlight.js/lib/languages/markdown';
|
||||
import jsHljs from 'highlight.js/lib/languages/javascript';
|
||||
import cssHljs from 'highlight.js/lib/languages/css';
|
||||
import goHljs from 'highlight.js/lib/languages/go';
|
||||
import csharpHljs from 'highlight.js/lib/languages/csharp';
|
||||
import { Base64 } from 'js-base64';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -24,17 +17,12 @@ const props = withDefaults(
|
||||
language?: string
|
||||
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
|
||||
copyMessage?: string
|
||||
wordWrap?: boolean
|
||||
downloadFileName?: string
|
||||
downloadButtonText?: string
|
||||
}>(),
|
||||
{
|
||||
followHeightOf: null,
|
||||
language: 'txt',
|
||||
copyPlacement: 'top-right',
|
||||
copyMessage: 'Copy to clipboard',
|
||||
downloadFileName: '',
|
||||
downloadButtonText: 'Download',
|
||||
},
|
||||
);
|
||||
hljs.registerLanguage('sql', sqlHljs);
|
||||
@@ -43,25 +31,13 @@ hljs.registerLanguage('html', xmlHljs);
|
||||
hljs.registerLanguage('xml', xmlHljs);
|
||||
hljs.registerLanguage('yaml', yamlHljs);
|
||||
hljs.registerLanguage('toml', iniHljs);
|
||||
hljs.registerLanguage('bash', bashHljs);
|
||||
hljs.registerLanguage('markdown', markdownHljs);
|
||||
hljs.registerLanguage('css', cssHljs);
|
||||
hljs.registerLanguage('javascript', jsHljs);
|
||||
hljs.registerLanguage('go', goHljs);
|
||||
hljs.registerLanguage('csharp', csharpHljs);
|
||||
|
||||
const { value, language, followHeightOf, copyPlacement, copyMessage, downloadFileName, downloadButtonText } = toRefs(props);
|
||||
const { value, language, followHeightOf, copyPlacement, copyMessage } = toRefs(props);
|
||||
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };
|
||||
|
||||
const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
|
||||
const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.value);
|
||||
|
||||
const valueBase64 = computed(() => Base64.encode(value.value));
|
||||
const { download } = useDownloadFileFromBase64(
|
||||
{
|
||||
source: valueBase64,
|
||||
filename: downloadFileName,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -73,16 +49,11 @@ const { download } = useDownloadFileFromBase64(
|
||||
:style="height ? `min-height: ${height - 40 /* card padding */ + 10 /* negative margin compensation */}px` : ''"
|
||||
>
|
||||
<n-config-provider :hljs="hljs">
|
||||
<n-code :code="value" :language="language" :word-wrap="wordWrap" :trim="false" data-test-id="area-content" />
|
||||
<n-code :code="value" :language="language" :trim="false" data-test-id="area-content" />
|
||||
</n-config-provider>
|
||||
</n-scrollbar>
|
||||
<div
|
||||
v-if="value && copyPlacement !== 'none'"
|
||||
absolute right-10px
|
||||
:top-10px="copyPlacement === 'top-right' ? '' : 'no'"
|
||||
:bottom-10px="copyPlacement === 'bottom-right' ? '' : 'no'"
|
||||
>
|
||||
<c-tooltip v-if="value && copyPlacement !== 'outside'" :tooltip="tooltipText" position="left">
|
||||
<div absolute right-10px top-10px>
|
||||
<c-tooltip v-if="value" :tooltip="tooltipText" position="left">
|
||||
<c-button circle important:h-10 important:w-10 @click="copy()">
|
||||
<n-icon size="22" :component="Copy" />
|
||||
</c-button>
|
||||
@@ -94,11 +65,6 @@ const { download } = useDownloadFileFromBase64(
|
||||
{{ tooltipText }}
|
||||
</c-button>
|
||||
</div>
|
||||
<div v-if="downloadFileName !== '' && value !== ''" mt-5 flex justify-center>
|
||||
<c-button secondary @click="download">
|
||||
{{ downloadButtonText }}
|
||||
</c-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { extension as getExtensionFromMimeType, extension as getMimeTypeFromExtension } from 'mime-types';
|
||||
import type { MaybeRef, Ref } from 'vue';
|
||||
import type { Ref } from 'vue';
|
||||
import _ from 'lodash';
|
||||
import { get } from '@vueuse/core';
|
||||
|
||||
export {
|
||||
getMimeTypeFromBase64,
|
||||
@@ -76,11 +75,21 @@ function downloadFromBase64({ sourceValue, filename, extension, fileMimeType }:
|
||||
}
|
||||
|
||||
function useDownloadFileFromBase64(
|
||||
{ source, filename, extension }:
|
||||
{ source: MaybeRef<string>; filename?: MaybeRef<string>; extension?: MaybeRef<string> }) {
|
||||
{ source, filename, extension, fileMimeType }:
|
||||
{ source: Ref<string>; filename?: string; extension?: string; fileMimeType?: string }) {
|
||||
return {
|
||||
download() {
|
||||
downloadFromBase64({ sourceValue: get(source), filename: get(filename), extension: get(extension) });
|
||||
downloadFromBase64({ sourceValue: source.value, filename, extension, fileMimeType });
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function useDownloadFileFromBase64Refs(
|
||||
{ source, filename, extension }:
|
||||
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
|
||||
return {
|
||||
download() {
|
||||
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -107,13 +116,3 @@ function previewImageFromBase64(base64String: string): HTMLImageElement {
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
function useDownloadFileFromBase64Refs(
|
||||
{ source, filename, extension }:
|
||||
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
|
||||
return {
|
||||
download() {
|
||||
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import EmailBounceParse from 'email-bounce-parser-browser';
|
||||
|
||||
const emailContent = ref('');
|
||||
|
||||
const parsedBounce = computed(() => {
|
||||
try {
|
||||
return { email: new EmailBounceParse().read(emailContent.value) };
|
||||
}
|
||||
catch (e: any) {
|
||||
return { parsingError: e.toString() };
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="max-width: 600px;">
|
||||
<c-card title="Input" mb-2>
|
||||
<c-input-text
|
||||
v-model:value="emailContent"
|
||||
label="Bounce Email Textual Content"
|
||||
multiline
|
||||
placeholder="Put your email text content here..."
|
||||
rows="15"
|
||||
mb-2
|
||||
/>
|
||||
</c-card>
|
||||
|
||||
<c-card v-if="parsedBounce && emailContent" title="Output" mb-2>
|
||||
<n-p v-if="parsedBounce.email?.email?.error" style="color: green" mb-2>
|
||||
This mail is a bounce email
|
||||
</n-p>
|
||||
<n-p v-if="!parsedBounce.email?.email?.error" style="color: red" mb-2>
|
||||
This mail is NOT a bounce email
|
||||
</n-p>
|
||||
<c-alert v-if="parsedBounce.parsingError" mb-2>
|
||||
{{ parsedBounce.parsingError }}
|
||||
</c-alert>
|
||||
<input-copyable v-if="parsedBounce.email?.data?.recipient" label="Recipient" :value="parsedBounce.email?.data?.recipient" mb-2 />
|
||||
<div v-if="parsedBounce.email?.email?.error">
|
||||
<c-card title="Error" mb-2>
|
||||
<input-copyable v-if="parsedBounce.email?.data?.command" label="Command" :value="parsedBounce.email?.data?.command" />
|
||||
<input-copyable v-if="parsedBounce.email?.data?.error?.code?.basic || parsedBounce.email?.data?.error?.code?.enhanced" label="Code" :value="`${parsedBounce.email?.data?.error?.code?.basic}/${parsedBounce.email?.data?.error?.code?.enhanced}`" />
|
||||
<input-copyable v-if="parsedBounce.email?.data?.error?.label" label="Label" :value="parsedBounce.email?.data?.error?.label" />
|
||||
<input-copyable v-if="parsedBounce.email?.data?.error?.type" label="Type" :value="parsedBounce.email?.data?.error?.type" />
|
||||
<input-copyable v-if="parsedBounce.email?.data?.error?.temporary" label="Temporary" :value="parsedBounce.email?.data?.error?.temporary" />
|
||||
<input-copyable v-if="parsedBounce.email?.data?.error?.permanent" label="Permanent" :value="parsedBounce.email?.data?.error?.permanent" />
|
||||
<input-copyable v-if="parsedBounce.email?.data?.error?.data?.type" label="Subtype" :value="parsedBounce.email?.data?.error?.data?.type" />
|
||||
<input-copyable v-if="parsedBounce.email?.data?.error?.data?.blocked" label="Blocked" :value="parsedBounce.email?.data?.error?.data?.blocked" />
|
||||
<input-copyable v-if="parsedBounce.email?.data?.error?.data?.spam" label="Spam" :value="parsedBounce.email?.data?.error?.data?.spam" />
|
||||
</c-card>
|
||||
<c-card v-if="parsedBounce.email?.data?.server?.hostname || parsedBounce.email?.data?.server?.ip" title="Server" mb-2>
|
||||
<input-copyable v-if="parsedBounce.email?.data?.server?.hostname" label="Host" :value="parsedBounce.email?.data?.server?.hostname" />
|
||||
<input-copyable v-if="parsedBounce.email?.data?.server?.ip" label="IP" :value="parsedBounce.email?.data?.server?.ip" />
|
||||
<input-copyable v-if="parsedBounce.email?.data?.server?.port" label="Port" :value="parsedBounce.email?.data?.server?.port" />
|
||||
</c-card>
|
||||
<c-card title="Details" mb-2>
|
||||
<textarea-copyable :value="JSON.stringify(parsedBounce.email?.data, null, 2)" />
|
||||
</c-card>
|
||||
<c-card title="Raw Error" mb-2>
|
||||
<textarea-copyable :value="parsedBounce.email?.email?.error" word-wrap />
|
||||
</c-card>
|
||||
</div>
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,36 +0,0 @@
|
||||
declare module "email-bounce-parser-browser" {
|
||||
export default class EmailBounceParse {
|
||||
read(emailContent: string): {
|
||||
bounce: boolean
|
||||
email?: {
|
||||
body?: string
|
||||
intro?: string
|
||||
error?: string
|
||||
}
|
||||
data?: {
|
||||
error?: {
|
||||
code?: {
|
||||
basic?: string
|
||||
enhanced?:string
|
||||
}
|
||||
label?: string
|
||||
type?: string
|
||||
temporary?: boolean
|
||||
permanent?: boolean
|
||||
data?: {
|
||||
type?: string
|
||||
blocked?: boolean
|
||||
spam?: boolean
|
||||
}
|
||||
}
|
||||
recipient?:string
|
||||
server?: {
|
||||
hostname?: string
|
||||
ip?: string
|
||||
port?: string
|
||||
}
|
||||
command?: string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Mailbox } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Bounce Email Parser',
|
||||
path: '/bounce-parser',
|
||||
description: 'Parse SMTP Bounce Emails',
|
||||
keywords: ['bounce', 'email', 'smtp', 'parser'],
|
||||
component: () => import('./bounce-parser.vue'),
|
||||
icon: Mailbox,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
@@ -2,7 +2,6 @@ import { tool as base64FileConverter } from './base64-file-converter';
|
||||
import { tool as base64StringConverter } from './base64-string-converter';
|
||||
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||
import { tool as emailNormalizer } from './email-normalizer';
|
||||
import { tool as bounceParser } from './bounce-parser';
|
||||
|
||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
|
||||
@@ -138,7 +137,6 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
httpStatusCodes,
|
||||
jsonDiff,
|
||||
safelinkDecoder,
|
||||
bounceParser,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
declare module 'korean-unpacker' {
|
||||
function unpack(text: string): string;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,137 @@
|
||||
[
|
||||
{
|
||||
"lang": "(International)",
|
||||
"input": "TesYW 123 ? = !@",
|
||||
"output": "TANGO echo sierra YANKEE WHISKEY (SPACE) ONE TWO THREE (SPACE) (?) (SPACE) (=) (SPACE) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(France)",
|
||||
"input": "TesYW 123 ? = !@",
|
||||
"output": "THÉRÈSE eugène suzanne YVONNE WILLIAM (ESPACE) UN DEUX TROIS (ESPACE) (?) (ESPACE) (=) (ESPACE) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Belgium)",
|
||||
"input": "TesYW 123 ? = !@",
|
||||
"output": "TELEFOON emiel sofie YVONNE WATERLOO (ESPACE) (1) (2) (3) (ESPACE) (?) (ESPACE) (=) (ESPACE) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Switzerland)",
|
||||
"input": "TesYW 123 ? = !@",
|
||||
"output": "THÉRÈSE émile suzanne (Y) WILLIAM (ESPACE) (1) (2) (3) (ESPACE) (?) (ESPACE) (=) (ESPACE) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Québec)",
|
||||
"input": "TesYW 123 ? = !@",
|
||||
"output": "THOMAS édouard samuel (Y) WILLIAM (ESPACE) (1) (2) (3) (ESPACE) (?) (ESPACE) (=) (ESPACE) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Germany, 2022)",
|
||||
"input": "TesYü 123 ? = !@",
|
||||
"output": "TÜBINGEN essen salzwedel YPSILON umlaut-unna (LEERZEICHEN) (1) (2) (3) (LEERZEICHEN) (?) (LEERZEICHEN) (=) (LEERZEICHEN) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Austria)",
|
||||
"input": "TesYW 123 ? = !@",
|
||||
"output": "THEODOR emil samuel/siegfried YPSILON WILHELM (LEERZEICHEN) (1) (2) (3) (LEERZEICHEN) (?) (LEERZEICHEN) (=) (LEERZEICHEN) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Germany, informal, 2022)",
|
||||
"input": "TesYü 123 ? = !@",
|
||||
"output": "THEODOR emil samuel YPSILON überfluss (LEERZEICHEN) (1) (2) (3) (LEERZEICHEN) (?) (LEERZEICHEN) (=) (LEERZEICHEN) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Netherlands)",
|
||||
"input": "TesY huis rij 123 ? = !@",
|
||||
"output": "THEODOR eduard simon YPSILON (SPATIE) hendrik utrecht izaak simon (SPATIE) richard/rudolf ijmuiden/ijsbrand (SPATIE) (1) (2) (3) (SPATIE) (?) (SPATIE) (=) (SPATIE) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Italian",
|
||||
"input": "TesYj 123 ? = !@",
|
||||
"output": "TORINO empoli savona YORK, YOGURT jolly/juventus (SPAZIO) (1) (2) (3) (SPAZIO) (?) (SPAZIO) (=) (SPAZIO) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Spanish",
|
||||
"input": "TesYñj 123 ? = !@",
|
||||
"output": "TOLEDO españa sábado YOLANDA ñoño josé (ESPACIO) (1) (2) (3) (ESPACIO) (?) (ESPACIO) (=) (ESPACIO) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Brazil)",
|
||||
"input": "TesYÇj 123 ? = !@",
|
||||
"output": "TATU estrela saci YOLANDA (Ç) josé (ESPAÇO) (1) (2) (3) (ESPAÇO) (?) (ESPAÇO) (=) (ESPAÇO) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Portugal)",
|
||||
"input": "TesYúj 123 ? = !@",
|
||||
"output": "TAVIRA évora setúbal YORK (ú) josé (ESPAÇO) (1) (2) (3) (ESPAÇO) (?) (ESPAÇO) (=) (ESPAÇO) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Swedish",
|
||||
"input": "TesYj 123 ? = !@",
|
||||
"output": "TORE erik sigurd YNGVE johan (UTRYMME) (1) (2) (3) (UTRYMME) (?) (UTRYMME) (=) (UTRYMME) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Danish",
|
||||
"input": "TesÆYj 123 ? = !@",
|
||||
"output": "THEODOR erik søren ÆGIR YRSA johan (MELLEMRUMSTEGN) (1) (2) (3) (MELLEMRUMSTEGN) (?) (MELLEMRUMSTEGN) (=) (MELLEMRUMSTEGN) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Norwegian",
|
||||
"input": "TesYÅj 123 ? = !@",
|
||||
"output": "TEODOR edith sigrid YNGLING ÅSE johan (MELLOMROMSTEGN) (1) (2) (3) (MELLOMROMSTEGN) (?) (MELLOMROMSTEGN) (=) (MELLOMROMSTEGN) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Finnish",
|
||||
"input": "TesYj 123 ? = !@",
|
||||
"output": "TYYNE eemeli sakari YRJÖ jussi (VÄLILYÖNTI) (1) (2) (3) (VÄLILYÖNTI) (?) (VÄLILYÖNTI) (=) (VÄLILYÖNTI) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Turkish",
|
||||
"input": "TesYj 123 ? = !@",
|
||||
"output": "TOKAT edirne sinop YOZGAT jandarma (BOŞLUK) (1) (2) (3) (BOŞLUK) (?) (BOŞLUK) (=) (BOŞLUK) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Romanian",
|
||||
"input": "TesYj 123 ? = !@",
|
||||
"output": "TUDOR elena sandu I-GREC jean (SPAȚIU) (1) (2) (3) (SPAȚIU) (?) (SPAȚIU) (=) (SPAȚIU) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Czech",
|
||||
"input": "TesYj 123 ? = !@",
|
||||
"output": "TOMÁŠ emil svatopluk YPSILON josef (PROSTOROVÝ) (1) (2) (3) (PROSTOROVÝ) (?) (PROSTOROVÝ) (=) (PROSTOROVÝ) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Yugoslav",
|
||||
"input": "TesYČj 123 ? = !@",
|
||||
"output": "TUZLA evropa skopje IPSILON ČAČAK jadran (PRIESTOROVÝ) (1) (2) (3) (PRIESTOROVÝ) (?) (PRIESTOROVÝ) (=) (PRIESTOROVÝ) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Serbian",
|
||||
"input": "TesYČj 123 ? = !@",
|
||||
"output": "TIMOK evropa sava IPSILON ČAČAK jadran (PROSTORNI) (1) (2) (3) (PROSTORNI) (?) (PROSTORNI) (=) (PROSTORNI) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Slovene",
|
||||
"input": "TesYČj 123 ? = !@",
|
||||
"output": "TRIGLAV evropa soča IPSILON ČATEŽ jadran (PRESLEDKA) (1) (2) (3) (PRESLEDKA) (?) (PRESLEDKA) (=) (PRESLEDKA) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Russian",
|
||||
"input": "Зинаида !.?",
|
||||
"output": "ЗИНАИДА иван николай анна иван дмитрий анна ( ) (!) (.) (?)"
|
||||
},
|
||||
{
|
||||
"lang": "Korean",
|
||||
"input": "안녕하세요 여러분",
|
||||
"output": "잉어 아버지 나폴리 나폴리 연못 잉어 한강 아버지 서울 엑스레이 잉어 요지경 ( ) 잉어 연못 로마 어머니 바가지 우편 나폴리"
|
||||
},
|
||||
{
|
||||
"lang": "Greek",
|
||||
"input": "τίγρης !?",
|
||||
"output": "τίγρης (ί) γαλή ρήγας ηρώ σοφός ( ) (!) (?)"
|
||||
},
|
||||
{
|
||||
"lang": "Japanese",
|
||||
"input": "数字のひと おしまいのン ?:",
|
||||
"output": "(数) (字) 野原のノ 飛行機のヒ 東京のト ( ) 大阪のオ 新聞のシ マッチのマ いろはのイ 野原のノ おしまいのン ( ) (?) (:)"
|
||||
}
|
||||
]
|
||||
@@ -1,28 +1,29 @@
|
||||
export const natoAlphabet = [
|
||||
'Alpha',
|
||||
'Bravo',
|
||||
'Charlie',
|
||||
'Delta',
|
||||
'Echo',
|
||||
'Foxtrot',
|
||||
'Golf',
|
||||
'Hotel',
|
||||
'India',
|
||||
'Juliet',
|
||||
'Kilo',
|
||||
'Lima',
|
||||
'Mike',
|
||||
'November',
|
||||
'Oscar',
|
||||
'Papa',
|
||||
'Quebec',
|
||||
'Romeo',
|
||||
'Sierra',
|
||||
'Tango',
|
||||
'Uniform',
|
||||
'Victor',
|
||||
'Whiskey',
|
||||
'X-ray',
|
||||
'Yankee',
|
||||
'Zulu',
|
||||
export const allLanguagesAndCountries = [
|
||||
'(International)',
|
||||
'(France)',
|
||||
'(Belgium)',
|
||||
'(Switzerland)',
|
||||
'(Québec)',
|
||||
'(Germany, 2022)',
|
||||
'(Austria)',
|
||||
'(Germany, informal, 2022)',
|
||||
'(Netherlands)',
|
||||
'Italian',
|
||||
'Spanish',
|
||||
'(Brazil)',
|
||||
'(Portugal)',
|
||||
'Swedish',
|
||||
'Danish',
|
||||
'Norwegian',
|
||||
'Finnish',
|
||||
'Turkish',
|
||||
'Romanian',
|
||||
'Czech',
|
||||
'Yugoslav',
|
||||
'Serbian',
|
||||
'Slovene',
|
||||
'Russian',
|
||||
'Korean',
|
||||
'Greek',
|
||||
'Japanese',
|
||||
];
|
||||
@@ -0,0 +1,160 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { textToNatoAlphabet } from './text-to-nato-alphabet.service';
|
||||
|
||||
const TestCase_TestYW = 'TesYW 123 ? = !@';
|
||||
const TestCase_TestYJ = 'TesYj 123 ? = !@';
|
||||
const natoTests = [
|
||||
{
|
||||
lang: '(International)',
|
||||
input: TestCase_TestYW,
|
||||
output: 'TANGO echo sierra YANKEE WHISKEY (SPACE) (digit 1) (digit 2) (digit 3) (SPACE) (punctuation ?) (SPACE) (punctuation =) (SPACE) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(France)',
|
||||
input: TestCase_TestYW,
|
||||
output: 'THÉRÈSE eugène suzanne YVONNE WILLIAM (ESPACE) (digit 1) (digit 2) (digit 3) (ESPACE) (punctuation ?) (ESPACE) (punctuation =) (ESPACE) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Belgium)',
|
||||
input: TestCase_TestYW,
|
||||
output: 'TELEFOON emiel sofie YVONNE WATERLOO (ESPACE) (digit 1) (digit 2) (digit 3) (ESPACE) (punctuation ?) (ESPACE) (punctuation =) (ESPACE) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Switzerland)',
|
||||
input: TestCase_TestYW,
|
||||
output: 'THÉRÈSE émile suzanne (Y) WILLIAM (ESPACE) (digit 1) (digit 2) (digit 3) (ESPACE) (punctuation ?) (ESPACE) (punctuation =) (ESPACE) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Québec)',
|
||||
input: TestCase_TestYW,
|
||||
output: 'THOMAS édouard samuel (Y) WILLIAM (ESPACE) (digit 1) (digit 2) (digit 3) (ESPACE) (punctuation ?) (ESPACE) (punctuation =) (ESPACE) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Germany, 2022)',
|
||||
input: 'TesYü 123 ? = !@',
|
||||
output: 'TÜBINGEN essen salzwedel YPSILON umlaut-unna (LEERZEICHEN) (digit 1) (digit 2) (digit 3) (LEERZEICHEN) (punctuation ?) (LEERZEICHEN) (punctuation =) (LEERZEICHEN) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Austria)',
|
||||
input: TestCase_TestYW,
|
||||
output: 'THEODOR emil samuel/siegfried YPSILON WILHELM (LEERZEICHEN) (digit 1) (digit 2) (digit 3) (LEERZEICHEN) (punctuation ?) (LEERZEICHEN) (punctuation =) (LEERZEICHEN) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Germany, informal, 2022)',
|
||||
input: 'TesYü 123 ? = !@',
|
||||
output: 'THEODOR emil samuel YPSILON überfluss (LEERZEICHEN) (digit 1) (digit 2) (digit 3) (LEERZEICHEN) (punctuation ?) (LEERZEICHEN) (punctuation =) (LEERZEICHEN) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Netherlands)',
|
||||
input: 'TesY huis rij 123 ? = !@',
|
||||
output: 'THEODOR eduard simon YPSILON (SPATIE) hendrik utrecht izaak simon (SPATIE) richard/rudolf ijmuiden/ijsbrand (SPATIE) (digit 1) (digit 2) (digit 3) (SPATIE) (punctuation ?) (SPATIE) (punctuation =) (SPATIE) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Italian',
|
||||
input: TestCase_TestYJ,
|
||||
output: 'TORINO empoli savona YORK, YOGURT jolly/juventus (SPAZIO) (digit 1) (digit 2) (digit 3) (SPAZIO) (punctuation ?) (SPAZIO) (punctuation =) (SPAZIO) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Spanish',
|
||||
input: 'TesYñj 123 ? = !@',
|
||||
output: 'TOLEDO españa sábado YOLANDA ñoño josé (ESPACIO) (digit 1) (digit 2) (digit 3) (ESPACIO) (punctuation ?) (ESPACIO) (punctuation =) (ESPACIO) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Brazil)',
|
||||
input: 'TesYÇj 123 ? = !@',
|
||||
output: 'TATU estrela saci YOLANDA (Ç) josé (ESPAÇO) (digit 1) (digit 2) (digit 3) (ESPAÇO) (punctuation ?) (ESPAÇO) (punctuation =) (ESPAÇO) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Portugal)',
|
||||
input: 'TesYúj 123 ? = !@',
|
||||
output: 'TAVIRA évora setúbal YORK (ú) josé (ESPAÇO) (digit 1) (digit 2) (digit 3) (ESPAÇO) (punctuation ?) (ESPAÇO) (punctuation =) (ESPAÇO) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Swedish',
|
||||
input: TestCase_TestYJ,
|
||||
output: 'TORE erik sigurd YNGVE johan (UTRYMME) (digit 1) (digit 2) (digit 3) (UTRYMME) (punctuation ?) (UTRYMME) (punctuation =) (UTRYMME) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Danish',
|
||||
input: 'TesÆYj 123 ? = !@',
|
||||
output: 'THEODOR erik søren ÆGIR YRSA johan (MELLEMRUMSTEGN) (digit 1) (digit 2) (digit 3) (MELLEMRUMSTEGN) (punctuation ?) (MELLEMRUMSTEGN) (punctuation =) (MELLEMRUMSTEGN) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Norwegian',
|
||||
input: 'TesYÅj 123 ? = !@',
|
||||
output: 'TEODOR edith sigrid YNGLING ÅSE johan (MELLOMROMSTEGN) (digit 1) (digit 2) (digit 3) (MELLOMROMSTEGN) (punctuation ?) (MELLOMROMSTEGN) (punctuation =) (MELLOMROMSTEGN) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Finnish',
|
||||
input: TestCase_TestYJ,
|
||||
output: 'TYYNE eemeli sakari YRJÖ jussi (VÄLILYÖNTI) (digit 1) (digit 2) (digit 3) (VÄLILYÖNTI) (punctuation ?) (VÄLILYÖNTI) (punctuation =) (VÄLILYÖNTI) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Turkish',
|
||||
input: TestCase_TestYJ,
|
||||
output: 'TOKAT edirne sinop YOZGAT jandarma (BOŞLUK) (digit 1) (digit 2) (digit 3) (BOŞLUK) (punctuation ?) (BOŞLUK) (punctuation =) (BOŞLUK) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Romanian',
|
||||
input: TestCase_TestYJ,
|
||||
output: 'TUDOR elena sandu I-GREC jean (SPAȚIU) (digit 1) (digit 2) (digit 3) (SPAȚIU) (punctuation ?) (SPAȚIU) (punctuation =) (SPAȚIU) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Czech',
|
||||
input: TestCase_TestYJ,
|
||||
output: 'TOMÁŠ emil svatopluk YPSILON josef (PROSTOROVÝ) (digit 1) (digit 2) (digit 3) (PROSTOROVÝ) (punctuation ?) (PROSTOROVÝ) (punctuation =) (PROSTOROVÝ) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Yugoslav',
|
||||
input: 'TesYČj 123 ? = !@',
|
||||
output: 'TUZLA evropa skopje IPSILON ČAČAK jadran (PRIESTOROVÝ) (digit 1) (digit 2) (digit 3) (PRIESTOROVÝ) (punctuation ?) (PRIESTOROVÝ) (punctuation =) (PRIESTOROVÝ) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Serbian',
|
||||
input: 'TesYČj 123 ? = !@',
|
||||
output: 'TIMOK evropa sava IPSILON ČAČAK jadran (PROSTORNI) (digit 1) (digit 2) (digit 3) (PROSTORNI) (punctuation ?) (PROSTORNI) (punctuation =) (PROSTORNI) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Slovene',
|
||||
input: 'TesYČj 123 ? = !@',
|
||||
output: 'TRIGLAV evropa soča IPSILON ČATEŽ jadran (PRESLEDKA) (digit 1) (digit 2) (digit 3) (PRESLEDKA) (punctuation ?) (PRESLEDKA) (punctuation =) (PRESLEDKA) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Russian',
|
||||
input: 'Зинаида !.?',
|
||||
output: 'ЗИНАИДА иван николай анна иван дмитрий анна ( ) (punctuation !) (punctuation .) (punctuation ?)',
|
||||
},
|
||||
{
|
||||
lang: 'Korean',
|
||||
input: '안녕하세요 여러분',
|
||||
output: '잉어 아버지 나폴리 나폴리 연못 잉어 한강 아버지 서울 엑스레이 잉어 요지경 ( ) 잉어 연못 로마 어머니 바가지 우편 나폴리',
|
||||
},
|
||||
{
|
||||
lang: 'Greek',
|
||||
input: 'τίγρης !?',
|
||||
output: 'τίγρης (ί) γαλή ρήγας ηρώ σοφός ( ) (punctuation !) (punctuation ?)',
|
||||
},
|
||||
{
|
||||
lang: 'Japanese',
|
||||
input: '数字のひと おしまいのン ?:',
|
||||
output: '(数) (字) 野原のノ 飛行機のヒ 東京のト ( ) 大阪のオ 新聞のシ マッチのマ いろはのイ 野原のノ おしまいのン ( ) (punctuation ?) (punctuation :)',
|
||||
},
|
||||
];
|
||||
|
||||
describe('text-to-nato', () => {
|
||||
it('Convert text to NATO', async () => {
|
||||
for (const nato of natoTests) {
|
||||
const { lang, input, output } = nato;
|
||||
expect(textToNatoAlphabet({ text: input, langOrCountry: lang })).to.equal(output);
|
||||
}
|
||||
});
|
||||
|
||||
it('Convert text to NATO (includes punctuations and digits names)', async () => {
|
||||
expect(textToNatoAlphabet({ text: 'a 1 2 3 ! % ? ;', langOrCountry: '(France)', useDigitsNames: true, usePunctuationsNames: true })).to.equal(
|
||||
'anatole (ESPACE) {digit 1 => un} (ESPACE) {digit 2 => deux} (ESPACE) {digit 3 => trois} (ESPACE) {punctuation ! => point d\'exclamation} (ESPACE) {punctuation % => pour cent} (ESPACE) {punctuation ? => point d\'interrogation} (ESPACE) {punctuation ; => point-virgule}');
|
||||
expect(textToNatoAlphabet({ text: 'и 1 2 3 ! % ? ;', langOrCountry: 'Russian', useDigitsNames: true, usePunctuationsNames: true })).to.equal(
|
||||
'иван ( ) {digit 1 => один (odin)} ( ) {digit 2 => два (dva)} ( ) {digit 3 => три (tri)} ( ) {punctuation ! => восклицательный знак (vosklitsatel\'nyy znak)} ( ) {punctuation % => процент (protsent)} ( ) {punctuation ? => вопросительный знак (voprositel\'nyy znak)} ( ) {punctuation ; => точка с запятой (tochka s zapyatoy)}');
|
||||
expect(textToNatoAlphabet({ text: 'TesYj 1 2 3 ! % ? ;', langOrCountry: 'Swedish', useDigitsNames: true, usePunctuationsNames: true })).to.equal(
|
||||
'TORE erik sigurd YNGVE johan (UTRYMME) {digit 1 => ett} (UTRYMME) {digit 2 => två} (UTRYMME) {digit 3 => tre} (UTRYMME) {punctuation ! => utropstecken} (UTRYMME) {punctuation % => procent} (UTRYMME) {punctuation ? => frågetecken} (UTRYMME) {punctuation ; => semikolon}');
|
||||
});
|
||||
});
|
||||
@@ -1,19 +1,80 @@
|
||||
import { natoAlphabet } from './text-to-nato-alphabet.constants';
|
||||
import hangul from 'korean-unpacker';
|
||||
import allAlphabets from './nato.alphabets.json';
|
||||
|
||||
type AllAlphabetsKeys = keyof typeof allAlphabets[0];
|
||||
|
||||
export { textToNatoAlphabet };
|
||||
|
||||
function getLetterPositionInAlphabet({ letter }: { letter: string }) {
|
||||
return letter.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0);
|
||||
function isPunctuation(char: string) {
|
||||
const punctuations = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~';
|
||||
return punctuations.includes(char);
|
||||
}
|
||||
function isDigit(char: string) {
|
||||
const digits = '0123456789';
|
||||
return digits.includes(char);
|
||||
}
|
||||
|
||||
function textToNatoAlphabet({ text }: { text: string }) {
|
||||
return text
|
||||
.split('')
|
||||
.map((character) => {
|
||||
const alphabetIndex = getLetterPositionInAlphabet({ letter: character });
|
||||
const natoWord = natoAlphabet[alphabetIndex];
|
||||
|
||||
return natoWord ?? character;
|
||||
})
|
||||
.join(' ');
|
||||
function escapeRegExp(string: string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||
}
|
||||
|
||||
function textToNatoAlphabet({
|
||||
text, langOrCountry = '(International)',
|
||||
useDigitsNames = false, usePunctuationsNames = false,
|
||||
}: {
|
||||
text: string
|
||||
langOrCountry: string
|
||||
useDigitsNames?: boolean
|
||||
usePunctuationsNames?: boolean
|
||||
}) {
|
||||
const getNatoWord = (searchChar: string) => {
|
||||
const alphabetLetter = allAlphabets.find(letter => letter.Letter === searchChar);
|
||||
if (alphabetLetter && alphabetLetter[langOrCountry as AllAlphabetsKeys]) {
|
||||
return alphabetLetter[langOrCountry as AllAlphabetsKeys] || '';
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const charRegex = new RegExp(
|
||||
`(${
|
||||
allAlphabets
|
||||
.sort((a, b) => b.Letter.length - a.Letter.length)
|
||||
.filter(a => a[langOrCountry as AllAlphabetsKeys])
|
||||
.map(a => escapeRegExp(a.Letter))
|
||||
.join('|')
|
||||
}|.)`,
|
||||
'gi');
|
||||
return hangul.unpack(text)
|
||||
.replace(/\s+/g, ' ')
|
||||
.replace(
|
||||
charRegex,
|
||||
(character) => {
|
||||
const searchChar = character.toUpperCase();
|
||||
const isUpper = character[0].toUpperCase() === character[0];
|
||||
const natoWord = getNatoWord(searchChar);
|
||||
|
||||
if (isDigit(searchChar)) {
|
||||
if (useDigitsNames) {
|
||||
return ` {digit ${searchChar} => ${natoWord}}`;
|
||||
}
|
||||
else {
|
||||
return ` (digit ${character})`;
|
||||
}
|
||||
}
|
||||
if (isPunctuation(searchChar)) {
|
||||
if (usePunctuationsNames) {
|
||||
return ` {punctuation ${searchChar} => ${natoWord}}`;
|
||||
}
|
||||
else {
|
||||
return ` (punctuation ${character})`;
|
||||
}
|
||||
}
|
||||
|
||||
if (natoWord) {
|
||||
return ` ${isUpper ? natoWord.toUpperCase() : natoWord.toLowerCase()}`;
|
||||
}
|
||||
|
||||
return ` (${character})`;
|
||||
})
|
||||
.trim();
|
||||
}
|
||||
@@ -1,14 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import { textToNatoAlphabet } from './text-to-nato-alphabet.service';
|
||||
import { allLanguagesAndCountries } from './text-to-nato-alphabet.constants';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
|
||||
const lang = useStorage('text-to-nato:lang', '(International)');
|
||||
const input = ref('');
|
||||
const natoText = computed(() => textToNatoAlphabet({ text: input.value }));
|
||||
const useDigitsNames = useStorage('text-to-nato:digits', false);
|
||||
const usePunctuationsNames = useStorage('text-to-nato:puncts', false);
|
||||
const natoText = computed(() => textToNatoAlphabet({ text: input.value, langOrCountry: lang.value }));
|
||||
const { copy } = useCopy({ source: natoText, text: 'NATO alphabet string copied.' });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-select
|
||||
v-model:value="lang"
|
||||
:options="allLanguagesAndCountries"
|
||||
searchable
|
||||
/>
|
||||
|
||||
<div flex justify-center>
|
||||
<n-form-item label="Use digits pronunciation">
|
||||
<n-checkbox v-model:checked="usePunctuationsNames" />
|
||||
</n-form-item>
|
||||
<n-form-item label="Use punctuations pronunciation">
|
||||
<n-checkbox v-model:checked="useDigitsNames" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
|
||||
<c-input-text
|
||||
v-model:value="input"
|
||||
label="Your text to convert to NATO phonetic alphabet"
|
||||
@@ -19,7 +38,7 @@ const { copy } = useCopy({ source: natoText, text: 'NATO alphabet string copied.
|
||||
|
||||
<div v-if="natoText">
|
||||
<div mb-2>
|
||||
Your text in NATO phonetic alphabet
|
||||
Your text in NATO phonetic alphabet ({{ lang }})
|
||||
</div>
|
||||
<c-card>
|
||||
{{ natoText }}
|
||||
|
||||
@@ -113,7 +113,4 @@ export default defineConfig({
|
||||
build: {
|
||||
target: 'esnext',
|
||||
},
|
||||
optimizeDeps: {
|
||||
include: ['re2-wasm-embedded'], // optionally specify dependency name
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user