mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-08 07:11:03 -04:00
feat(i18n): uuid and ulid generator
This commit is contained in:
parent
4365226d01
commit
4d0ada342f
6 changed files with 42 additions and 15 deletions
|
@ -1,10 +1,11 @@
|
||||||
import { SortDescendingNumbers } from '@vicons/tabler';
|
import { SortDescendingNumbers } from '@vicons/tabler';
|
||||||
import { defineTool } from '../tool';
|
import { defineTool } from '../tool';
|
||||||
|
import { translate } from '@/plugins/i18n.plugin';
|
||||||
|
|
||||||
export const tool = defineTool({
|
export const tool = defineTool({
|
||||||
name: 'ULID generator',
|
name: translate('tools.ulid-generator.title'),
|
||||||
path: '/ulid-generator',
|
path: '/ulid-generator',
|
||||||
description: 'Generate random Universally Unique Lexicographically Sortable Identifier (ULID).',
|
description: translate('tools.ulid-generator.description'),
|
||||||
keywords: ['ulid', 'generator', 'random', 'id', 'alphanumeric', 'identity', 'token', 'string', 'identifier', 'unique'],
|
keywords: ['ulid', 'generator', 'random', 'id', 'alphanumeric', 'identity', 'token', 'string', 'identifier', 'unique'],
|
||||||
component: () => import('./ulid-generator.vue'),
|
component: () => import('./ulid-generator.vue'),
|
||||||
icon: SortDescendingNumbers,
|
icon: SortDescendingNumbers,
|
||||||
|
|
11
src/tools/ulid-generator/locales/en.yml
Normal file
11
src/tools/ulid-generator/locales/en.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
tools:
|
||||||
|
ulid-generator:
|
||||||
|
title: 'ULID generator'
|
||||||
|
description: 'Generate random Universally Unique Lexicographically Sortable Identifier (ULID).'
|
||||||
|
|
||||||
|
copied: 'ULIDs copied to the clipboard'
|
||||||
|
quantity: 'Quantity'
|
||||||
|
formatLabel: 'Format'
|
||||||
|
button:
|
||||||
|
copy: Copy
|
||||||
|
refresh: Refresh
|
|
@ -7,7 +7,7 @@ import { useCopy } from '@/composable/copy';
|
||||||
const amount = useStorage('ulid-generator-amount', 1);
|
const amount = useStorage('ulid-generator-amount', 1);
|
||||||
const formats = [{ label: 'Raw', value: 'raw' }, { label: 'JSON', value: 'json' }] as const;
|
const formats = [{ label: 'Raw', value: 'raw' }, { label: 'JSON', value: 'json' }] as const;
|
||||||
const format = useStorage<typeof formats[number]['value']>('ulid-generator-format', formats[0].value);
|
const format = useStorage<typeof formats[number]['value']>('ulid-generator-format', formats[0].value);
|
||||||
|
const { t } = useI18n();
|
||||||
const [ulids, refreshUlids] = computedRefreshable(() => {
|
const [ulids, refreshUlids] = computedRefreshable(() => {
|
||||||
const ids = _.times(amount.value, () => ulid());
|
const ids = _.times(amount.value, () => ulid());
|
||||||
|
|
||||||
|
@ -18,17 +18,17 @@ const [ulids, refreshUlids] = computedRefreshable(() => {
|
||||||
return ids.join('\n');
|
return ids.join('\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
const { copy } = useCopy({ source: ulids, text: 'ULIDs copied to the clipboard' });
|
const { copy } = useCopy({ source: ulids, text: t('tools.ulid-generator.copied') });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div flex flex-col justify-center gap-2>
|
<div flex flex-col justify-center gap-2>
|
||||||
<div flex items-center>
|
<div flex items-center>
|
||||||
<label w-75px> Quantity:</label>
|
<label w-75px>{{ t('tools.ulid-generator.quantity') }}:</label>
|
||||||
<n-input-number v-model:value="amount" min="1" max="100" flex-1 />
|
<n-input-number v-model:value="amount" min="1" max="100" flex-1 />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<c-buttons-select v-model:value="format" :options="formats" label="Format: " label-width="75px" />
|
<c-buttons-select v-model:value="format" :options="formats" :label="`${t('tools.ulid-generator.formatLabel')}:`" label-width="75px" />
|
||||||
|
|
||||||
<c-card mt-5 flex data-test-id="ulids">
|
<c-card mt-5 flex data-test-id="ulids">
|
||||||
<pre m-0 m-x-auto>{{ ulids }}</pre>
|
<pre m-0 m-x-auto>{{ ulids }}</pre>
|
||||||
|
@ -36,10 +36,10 @@ const { copy } = useCopy({ source: ulids, text: 'ULIDs copied to the clipboard'
|
||||||
|
|
||||||
<div flex justify-center gap-2>
|
<div flex justify-center gap-2>
|
||||||
<c-button data-test-id="refresh" @click="refreshUlids()">
|
<c-button data-test-id="refresh" @click="refreshUlids()">
|
||||||
Refresh
|
{{ t('tools.ulid-generator.button.refresh') }}
|
||||||
</c-button>
|
</c-button>
|
||||||
<c-button @click="copy()">
|
<c-button @click="copy()">
|
||||||
Copy
|
{{ t('tools.ulid-generator.button.copy') }}
|
||||||
</c-button>
|
</c-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { Fingerprint } from '@vicons/tabler';
|
import { Fingerprint } from '@vicons/tabler';
|
||||||
import { defineTool } from '../tool';
|
import { defineTool } from '../tool';
|
||||||
|
import { translate } from '@/plugins/i18n.plugin';
|
||||||
|
|
||||||
export const tool = defineTool({
|
export const tool = defineTool({
|
||||||
name: 'UUIDs v4 generator',
|
name: translate('tools.uuid-generator.title'),
|
||||||
path: '/uuid-generator',
|
path: '/uuid-generator',
|
||||||
description:
|
description: translate('tools.uuid-generator.description'),
|
||||||
'A Universally Unique Identifier (UUID) is a 128-bit number used to identify information in computer systems. The number of possible UUIDs is 16^32, which is 2^128 or about 3.4x10^38 (which is a lot!).',
|
|
||||||
keywords: ['uuid', 'v4', 'random', 'id', 'alphanumeric', 'identity', 'token', 'string', 'identifier', 'unique'],
|
keywords: ['uuid', 'v4', 'random', 'id', 'alphanumeric', 'identity', 'token', 'string', 'identifier', 'unique'],
|
||||||
component: () => import('./uuid-generator.vue'),
|
component: () => import('./uuid-generator.vue'),
|
||||||
icon: Fingerprint,
|
icon: Fingerprint,
|
||||||
|
|
14
src/tools/uuid-generator/locales/en.yml
Normal file
14
src/tools/uuid-generator/locales/en.yml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
tools:
|
||||||
|
uuid-generator:
|
||||||
|
title: 'UUIDs v4 generator'
|
||||||
|
description: 'A Universally Unique Identifier (UUID) is a 128-bit number used to identify information in computer systems. The number of possible UUIDs is 16^32, which is 2^128 or about 3.4x10^38 (which is a lot!).'
|
||||||
|
|
||||||
|
copied: 'UUIDs copied to the clipboard'
|
||||||
|
quantity: 'Quantity'
|
||||||
|
button:
|
||||||
|
copy: Copy
|
||||||
|
refresh: Refresh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,19 +3,20 @@ import { v4 as generateUUID } from 'uuid';
|
||||||
import { useCopy } from '@/composable/copy';
|
import { useCopy } from '@/composable/copy';
|
||||||
import { computedRefreshable } from '@/composable/computedRefreshable';
|
import { computedRefreshable } from '@/composable/computedRefreshable';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
const count = useStorage('uuid-generator:quantity', 1);
|
const count = useStorage('uuid-generator:quantity', 1);
|
||||||
|
|
||||||
const [uuids, refreshUUIDs] = computedRefreshable(() =>
|
const [uuids, refreshUUIDs] = computedRefreshable(() =>
|
||||||
Array.from({ length: count.value }, () => generateUUID()).join('\n'),
|
Array.from({ length: count.value }, () => generateUUID()).join('\n'),
|
||||||
);
|
);
|
||||||
|
|
||||||
const { copy } = useCopy({ source: uuids, text: 'UUIDs copied to the clipboard' });
|
const { copy } = useCopy({ source: uuids, text: t('tools.uuid-generator.copied') });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div flex items-center justify-center gap-3>
|
<div flex items-center justify-center gap-3>
|
||||||
Quantity :
|
{{ t('tools.uuid-generator.quantity') }}:
|
||||||
<n-input-number v-model:value="count" :min="1" :max="50" placeholder="UUID quantity" />
|
<n-input-number v-model:value="count" :min="1" :max="50" placeholder="UUID quantity" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -35,10 +36,10 @@ const { copy } = useCopy({ source: uuids, text: 'UUIDs copied to the clipboard'
|
||||||
|
|
||||||
<div flex justify-center gap-3>
|
<div flex justify-center gap-3>
|
||||||
<c-button autofocus @click="copy()">
|
<c-button autofocus @click="copy()">
|
||||||
Copy
|
{{ t('tools.uuid-generator.button.copy') }}
|
||||||
</c-button>
|
</c-button>
|
||||||
<c-button @click="refreshUUIDs">
|
<c-button @click="refreshUUIDs">
|
||||||
Refresh
|
{{ t('tools.uuid-generator.button.refresh') }}
|
||||||
</c-button>
|
</c-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue