mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-08 07:11:03 -04:00
feat(i18n): yaml to json
This commit is contained in:
parent
7a70dbbe0c
commit
9c5688027a
3 changed files with 23 additions and 4 deletions
9
src/tools/yaml-to-json-converter/locales/en.yml
Normal file
9
src/tools/yaml-to-json-converter/locales/en.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
tools:
|
||||
yaml-to-json-converter:
|
||||
title: 'YAML to JSON converter'
|
||||
description: 'Simply convert YAML to JSON with this live online converter.'
|
||||
invalid: 'Provided JSON is not valid.'
|
||||
your-yaml: 'Your YAML'
|
||||
json-from-yaml: 'JSON from your YAML'
|
||||
placeholder:
|
||||
your-yaml: 'Paste your YAML here...'
|
9
src/tools/yaml-to-json-converter/locales/zh.yml
Normal file
9
src/tools/yaml-to-json-converter/locales/zh.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
tools:
|
||||
yaml-to-json-converter:
|
||||
title: 'YAML to JSON'
|
||||
description: '使用这个在线转换工具,简单地将YAML转换为JSON'
|
||||
invalid: '提供的YAML有问题'
|
||||
your-yaml: '原始YAML'
|
||||
json-from-yaml: '转换后的JSON'
|
||||
placeholder:
|
||||
your-yaml: '在这粘贴你的YAML...'
|
|
@ -4,6 +4,7 @@ import type { UseValidationRule } from '@/composable/validation';
|
|||
import { isNotThrowing } from '@/utils/boolean';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
|
||||
const { t } = useI18n();
|
||||
function transformer(value: string) {
|
||||
return withDefaultOnError(() => {
|
||||
const obj = parseYaml(value);
|
||||
|
@ -14,16 +15,16 @@ function transformer(value: string) {
|
|||
const rules: UseValidationRule<string>[] = [
|
||||
{
|
||||
validator: (value: string) => isNotThrowing(() => parseYaml(value)),
|
||||
message: 'Provided YAML is not valid.',
|
||||
message: computed(()=>t('tools.yaml-to-json-converter.invalid')),
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<format-transformer
|
||||
input-label="Your YAML"
|
||||
input-placeholder="Paste your yaml here..."
|
||||
output-label="JSON from your YAML"
|
||||
:input-label="t('tools.yaml-to-json-converter.your-yaml')"
|
||||
:input-placeholder="t('tools.yaml-to-json-converter.placeholder.your-yaml')"
|
||||
:output-label="t('tools.yaml-to-json-converter.json-from-yaml')"
|
||||
output-language="json"
|
||||
:input-validation-rules="rules"
|
||||
:transformer="transformer"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue