Add Str numeronym (i18n) tool

This commit is contained in:
Illya Marchenko 2024-04-19 14:25:41 +03:00
parent c82bf33d50
commit 373dbff423
Signed by: stuzer05
GPG Key ID: A6ABAAA9268F9F4F
3 changed files with 61 additions and 0 deletions

View File

@ -48,6 +48,7 @@ export default {
'str_to_lower_upper': 'Str to lower/upper',
'str_remove_duplicate_lines': 'Str remove duplicate lines',
'str_pad': 'Str pad',
'numeronym': 'Str numeronym (i18n)',
'url_encode_decode': 'URL encode/decode',
'url_query_viewer': 'URL query viewer',
},

View File

@ -65,6 +65,11 @@ const router = createRouter({
name: 'str_to_php_array',
component: () => import('../views/StrToPHPArray.vue'),
},
{
path: '/numeronym',
name: 'numeronym',
component: () => import('../views/StrNumeronym.vue'),
},
{
path: '/php_array_to_json',
name: 'php_array_to_json',

View File

@ -0,0 +1,55 @@
<template>
<h2 class="tool-title">Str numeronym</h2>
<hr class="mt-5 mb-5">
<div class="input-group">
<label for="data">Data</label>
<input id="data" v-model="toolData.data" v-on:keyup="result" type="text">
</div>
<hr class="mt-5 mb-5">
<div class="input-group">
<label for="result">Result</label>
<MonacoEditor name="result" language="text" :value="toolResult"></MonacoEditor>
</div>
</template>
<script>
import MonacoEditor from "@/components/MonacoEditor.vue";
import { unproxy } from "../utils/unproxy";
export default {
components: {
MonacoEditor
},
data() {
return {
toolData: {
data: '',
},
toolResult: '',
};
},
methods: {
result() {
const word = unproxy(this.toolData.data);
if (word.length <= 3) {
this.toolResult = word;
return
}
const firstLetter = word[0];
const lastLetter = word[word.length - 1];
const numberOfLetters = word.length - 2;
this.toolResult = `${firstLetter}${numberOfLetters}${lastLetter}`;
},
},
}
</script>
<style lang="scss">
</style>