@nitra/tfm
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

@nitra/tfm

usage with Vite

<template>
  <div>Мова: {{ langStore.code }}</div>
  <button @click="setEnglish()">Set english (base)</button>
  <button @click="setLatvian()">Set latvian</button>
  <button @click="setUkrainian()">Set ukrainian</button>
  <div>{{ t`Hello Sun ${langStore.code} !` }}</div>
  <router-view />
</template>

<script setup>
import tf from '@nitra/tfm'
import { useLangStore } from '@nitra/tfm/store'

const langStore = useLangStore()

const tr = {
  'Hello Sun ': { uk: 'Привіт Сонечко ', lv: 'Sveika Saulīte ', ee: 'Tere Päike ' }
}

const t = tf.bind({ tr })

const setEnglish = () => {
  langStore.code = 'en'
}

const setUkrainian = () => {
  langStore.code = 'uk'
}

const setLatvian = () => {
  langStore.code = 'lv'
}
</script>

usage with node

import tf from '@nitra/tfm'
import Fastify from 'fastify'

const fastify = Fastify()

const tr = {
  'Привіт Сонечко ': { en: 'Hello Sun ', lv: 'Sveika Saulīte ', ee: 'Tere Päike ' }
}

// Declare a route
fastify.post('/', {}, function (req, reply) {
  const t = tf.bind({ tr, lang: req.headers.lang })

  reply.send({ result: t`Привіт Сонечко ` })
})

// Run the server!
fastify.listen({ port: 3000 })

Readme

Keywords

Package Sidebar

Install

npm i @nitra/tfm

Weekly Downloads

25

Version

1.3.0

License

MIT

Unpacked Size

3.42 kB

Total Files

7

Last publish

Collaborators

  • vitaliytv