Socket
Socket
Sign inDemoInstall

3h-localizer

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    3h-localizer

A utility lib for localization in vue.


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
316 kB
Created
Weekly downloads
 

Changelog

Source

0.2.0

  • Improve language option
  • Improve option check
  • Fix module config
  • Fix example code

Readme

Source

3h-localizer

A utility lib for localization in vue.

Example Usage

The following code creates a demo page containing a title and a select input, where the content of the title is controlled by selected language.

<template>
    <h1>{{ dict.HELLO_WORLD }}</h1>
    <select v-model="language">
        <option value="zh">中文</option>
        <option value="en">English</option>
    </select>
</template>

<script setup lang="ts">
import { Localizer, translationsToDicts, type Translations } from '3h-localizer';

type MyDict = {
    HELLO_WORLD: string;
};

type MyLanguages = 'zh' | 'en';

const translations: Translations<MyDict, MyLanguages> = {
    HELLO_WORLD: {
        zh: '你好,世界!',
        en: 'Hello, world!',
    },
};

const localizer = new Localizer<MyDict, MyLanguages>({
    defaultLanguage: 'en',
    dicts: translationsToDicts(translations),
});

const { language, dict } = localizer;
</script>
  • API Reference
  • Changelog
  • License (MIT)

Keywords

FAQs

Last updated on 20 Dec 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc