mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-08 07:11:03 -04:00
Merge branch 'main' into dev-add-wifi-qr-code-generator
This commit is contained in:
commit
56ff2dbead
7 changed files with 40 additions and 21 deletions
|
@ -49,7 +49,7 @@ const { t } = useI18n();
|
||||||
</transition>
|
</transition>
|
||||||
|
|
||||||
<div v-if="toolStore.newTools.length > 0">
|
<div v-if="toolStore.newTools.length > 0">
|
||||||
<n-h3>{{ t('home.categories.newestTools', 'Newest tools') }}</n-h3>
|
<n-h3>{{ t('home.categories.newestTools') }}</n-h3>
|
||||||
<n-grid x-gap="12" y-gap="12" cols="1 400:2 800:3 1200:4 2000:8">
|
<n-grid x-gap="12" y-gap="12" cols="1 400:2 800:3 1200:4 2000:8">
|
||||||
<n-gi v-for="tool in toolStore.newTools" :key="tool.name">
|
<n-gi v-for="tool in toolStore.newTools" :key="tool.name">
|
||||||
<ToolCard :tool="tool" />
|
<ToolCard :tool="tool" />
|
||||||
|
|
|
@ -1,6 +1,22 @@
|
||||||
import type { App } from 'vue';
|
import type { Plugin } from 'vue';
|
||||||
import { createI18n } from 'vue-i18n';
|
import { createI18n } from 'vue-i18n';
|
||||||
import messages from '@intlify/unplugin-vue-i18n/messages';
|
import baseMessages from '@intlify/unplugin-vue-i18n/messages';
|
||||||
|
import _ from 'lodash';
|
||||||
|
import { parse as parseYaml } from 'yaml';
|
||||||
|
|
||||||
|
const i18nFiles = import.meta.glob('../tools/*/locales/**.yml', { as: 'raw' });
|
||||||
|
|
||||||
|
const messagesByTools = await Promise.all(_.map(i18nFiles, async (fileDescriptor, path) => {
|
||||||
|
const [, locale] = path.match(/\.\/tools\/.*?\/locales\/(.*)\.ya?ml$/i) ?? [];
|
||||||
|
const content = parseYaml(await fileDescriptor());
|
||||||
|
|
||||||
|
return { [locale]: content };
|
||||||
|
}));
|
||||||
|
|
||||||
|
const messages = _.merge(
|
||||||
|
baseMessages,
|
||||||
|
_.merge({}, ...messagesByTools),
|
||||||
|
);
|
||||||
|
|
||||||
const i18n = createI18n({
|
const i18n = createI18n({
|
||||||
legacy: false,
|
legacy: false,
|
||||||
|
@ -8,8 +24,8 @@ const i18n = createI18n({
|
||||||
messages,
|
messages,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const i18nPlugin = {
|
export const i18nPlugin: Plugin = {
|
||||||
install: (app: App) => {
|
install: (app) => {
|
||||||
app.use(i18n);
|
app.use(i18n);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -146,7 +146,7 @@ function formatDateUsingFormatter(formatter: (date: Date) => string, date?: Date
|
||||||
<c-input-text
|
<c-input-text
|
||||||
v-model:value="inputDate"
|
v-model:value="inputDate"
|
||||||
autofocus
|
autofocus
|
||||||
placeholder="Put you date string here..."
|
placeholder="Put your date string here..."
|
||||||
clearable
|
clearable
|
||||||
test-id="date-time-converter-input"
|
test-id="date-time-converter-input"
|
||||||
:validation="validation"
|
:validation="validation"
|
||||||
|
|
|
@ -14,6 +14,6 @@ test.describe('Tool - Password strength analyser', () => {
|
||||||
|
|
||||||
const crackDuration = await page.getByTestId('crack-duration').textContent();
|
const crackDuration = await page.getByTestId('crack-duration').textContent();
|
||||||
|
|
||||||
expect(crackDuration).toEqual('15,091 milleniums, 3 centurys');
|
expect(crackDuration).toEqual('15,091 millennia, 3 centuries');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,20 +19,20 @@ function getHumanFriendlyDuration({ seconds }: { seconds: number }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeUnits = [
|
const timeUnits = [
|
||||||
{ unit: 'millenium', secondsInUnit: 31536000000, format: prettifyExponentialNotation },
|
{ unit: 'millenium', secondsInUnit: 31536000000, format: prettifyExponentialNotation, plural: 'millennia' },
|
||||||
{ unit: 'century', secondsInUnit: 3153600000 },
|
{ unit: 'century', secondsInUnit: 3153600000, plural: 'centuries' },
|
||||||
{ unit: 'decade', secondsInUnit: 315360000 },
|
{ unit: 'decade', secondsInUnit: 315360000, plural: 'decades' },
|
||||||
{ unit: 'year', secondsInUnit: 31536000 },
|
{ unit: 'year', secondsInUnit: 31536000, plural: 'years' },
|
||||||
{ unit: 'month', secondsInUnit: 2592000 },
|
{ unit: 'month', secondsInUnit: 2592000, plural: 'months' },
|
||||||
{ unit: 'week', secondsInUnit: 604800 },
|
{ unit: 'week', secondsInUnit: 604800, plural: 'weeks' },
|
||||||
{ unit: 'day', secondsInUnit: 86400 },
|
{ unit: 'day', secondsInUnit: 86400, plural: 'days' },
|
||||||
{ unit: 'hour', secondsInUnit: 3600 },
|
{ unit: 'hour', secondsInUnit: 3600, plural: 'hours' },
|
||||||
{ unit: 'minute', secondsInUnit: 60 },
|
{ unit: 'minute', secondsInUnit: 60, plural: 'minutes' },
|
||||||
{ unit: 'second', secondsInUnit: 1 },
|
{ unit: 'second', secondsInUnit: 1, plural: 'seconds' },
|
||||||
];
|
];
|
||||||
|
|
||||||
return _.chain(timeUnits)
|
return _.chain(timeUnits)
|
||||||
.map(({ unit, secondsInUnit, format = _.identity }) => {
|
.map(({ unit, secondsInUnit, plural, format = _.identity }) => {
|
||||||
const quantity = Math.floor(seconds / secondsInUnit);
|
const quantity = Math.floor(seconds / secondsInUnit);
|
||||||
seconds %= secondsInUnit;
|
seconds %= secondsInUnit;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ function getHumanFriendlyDuration({ seconds }: { seconds: number }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const formattedQuantity = format(quantity);
|
const formattedQuantity = format(quantity);
|
||||||
return `${formattedQuantity} ${unit}${quantity > 1 ? 's' : ''}`;
|
return `${formattedQuantity} ${quantity > 1 ? plural : unit}`;
|
||||||
})
|
})
|
||||||
.compact()
|
.compact()
|
||||||
.take(2)
|
.take(2)
|
||||||
|
|
|
@ -5,7 +5,7 @@ export const tool = defineTool({
|
||||||
name: 'UUIDs v4 generator',
|
name: 'UUIDs v4 generator',
|
||||||
path: '/uuid-generator',
|
path: '/uuid-generator',
|
||||||
description:
|
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 !).',
|
'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,
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default defineConfig({
|
||||||
runtimeOnly: true,
|
runtimeOnly: true,
|
||||||
compositionOnly: true,
|
compositionOnly: true,
|
||||||
fullInstall: true,
|
fullInstall: true,
|
||||||
include: [resolve(__dirname, 'locales/**'), resolve(__dirname, 'src/tools/*/locales/**')],
|
include: [resolve(__dirname, 'locales/**')],
|
||||||
}),
|
}),
|
||||||
AutoImport({
|
AutoImport({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -106,4 +106,7 @@ export default defineConfig({
|
||||||
test: {
|
test: {
|
||||||
exclude: [...configDefaults.exclude, '**/*.e2e.spec.ts'],
|
exclude: [...configDefaults.exclude, '**/*.e2e.spec.ts'],
|
||||||
},
|
},
|
||||||
|
build: {
|
||||||
|
target: 'esnext',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue