All Projects → xpepermint → vue-translated

xpepermint / vue-translated

Licence: other
Internationalization (i18n) and localization (l10n) library for Vue.js v2.

Programming Languages

javascript
184084 projects - #8 most used programming language
Vue
7211 projects

Projects that are alternatives of or similar to vue-translated

Translatedjs
Internationalization and localization for JavaScript and Node.js
Stars: ✭ 17 (-10.53%)
Mutual labels:  i18n, time, formatter, internationalization, date, format, number
Moment.php
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Stars: ✭ 900 (+4636.84%)
Mutual labels:  i18n, time, formatter, internationalization, date
lit-date
Light-weight, faster datetime formatter for modern browsers.
Stars: ✭ 33 (+73.68%)
Mutual labels:  time, formatter, date, format
tr4n5l4te
Use Google Translate without an API key.
Stars: ✭ 32 (+68.42%)
Mutual labels:  i18n, internationalization, translate
Time Stamp
Get a formatted timestamp. Used in gulp, assemble, generate, and many others.
Stars: ✭ 104 (+447.37%)
Mutual labels:  time, date, format
Gostradamus
Gostradamus: Better DateTimes for Go 🕰️
Stars: ✭ 148 (+678.95%)
Mutual labels:  time, date, format
date-php
这是一个Javascript模仿PHP日期时间格式化函数,使用方法和PHP非常类似,有丰富的模板字符,并在原来的基础上增加了一些模板字符。 This is a date function that implement PHP in Javascript. It is very similar to PHP, has rich template characters, and enhances some template characters on the basis of the original.
Stars: ✭ 24 (+26.32%)
Mutual labels:  time, date, format
React Phone Input 2
📞 Highly customizable phone input component with auto formatting
Stars: ✭ 446 (+2247.37%)
Mutual labels:  i18n, format, number
Texterify
The localization management system.
Stars: ✭ 37 (+94.74%)
Mutual labels:  i18n, internationalization, translate
Flutter translate
Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.
Stars: ✭ 245 (+1189.47%)
Mutual labels:  i18n, internationalization, translate
React Translated
A dead simple way to add complex translations (i18n) in a React (DOM/Native) project 🌎🌍🌏
Stars: ✭ 176 (+826.32%)
Mutual labels:  i18n, internationalization, translate
jodaTime
Format and Parse date and time with joda layout
Stars: ✭ 67 (+252.63%)
Mutual labels:  time, date, format
Date And Time
A Minimalist DateTime utility for Node.js and the browser
Stars: ✭ 99 (+421.05%)
Mutual labels:  time, date, format
Tinydate
A tiny (349B) reusable date formatter. Extremely fast!
Stars: ✭ 990 (+5110.53%)
Mutual labels:  time, date, format
Sonataintlbundle
Symfony SonataIntlBundle
Stars: ✭ 212 (+1015.79%)
Mutual labels:  time, date, number
Awesome Falsehood
😱 Falsehoods Programmers Believe in
Stars: ✭ 16,614 (+87342.11%)
Mutual labels:  time, internationalization, date
Javascript Number Formatter
Lightweight & Fast JavaScript Number Formatter
Stars: ✭ 119 (+526.32%)
Mutual labels:  formatter, internationalization, number
React Intl Hooks
React hooks for internationalization without the hassle ⚛️🌍
Stars: ✭ 64 (+236.84%)
Mutual labels:  i18n, internationalization, translate
timelite
String date and time utilities 🕙
Stars: ✭ 17 (-10.53%)
Mutual labels:  time, date, format
format-date
📆 A small library (around 400 B when gziped & minified) to format JavaScript `Date` object using same tokens as moment.
Stars: ✭ 25 (+31.58%)
Mutual labels:  formatter, date, format

NPM Version Dependency Status

vue-translated

Internationalization (i18n) and localization (l10n) library for Vue.js v2.

This plugin integrates the translated.js library into your Vue.js application.

This is a light weight open source package for Vue.js. The source code is available on GitHub where you can also find our issue tracker.

Related Projects

  • translated.js: Internationalization and localization for JavaScript and Node.js

Installation

Run the command below to install the package.

$ npm install --save vue-translated translated

When used with a module system, you must explicitly install vue-translated via Vue.use().

import Vue from 'vue';
import VueTranslated from 'vue-translated';

Vue.use(VueTranslated);

Getting Started

Initialize translated.js and define a user model.

import {I18n} from 'translated';

const i18n = new I18n({
  locale: 'en-US',
  messages: {
    hello: 'Hello, {name}.'
  }
});

Attach the i18n instance to your Vue.js application.

const app = new Vue({
  i18n, // injecting i18n into child components
  ...
});

By passing the i18n instance to the root Vue instance as the i18n option, the $i18n property is injected into every child component.

Usage Example

This plugin registers i18n methods so you can use them directly.

<template>
  <div>
    <p>{{ $formatMessage('hello', {name: 'John'}) }}</p>
    <p>{{ $formatNumber(1000.13, {format: 'integer'}) }}</p>
    <p>{{ $formatDate(Date.now(), {format: 'long'}) }}</p>
    <p>{{ $formatTime(Date.now(), {format: 'medium'}) }}</p>
    <p>{{ $formatRelativeTime(Date.now() - 10000) }}</p>
  </div>
</template>

API

Please check translated.js API for details.

mv.$formatDate(value, options)

Converts a value into formatted date string.

Name Type Required Default Description
value Date, Integer Yes - Date object.
options Object No - Options which are passed directly into the Intl.DateTimeFormat constructor.
<p>{{ $formatDate(Date.now(), {month: 'numeric', year: 'numeric'}) }</p>

mv.$formatMessage(key, vars)

Compiles a message into a formatted string.

Name Type Required Default Description
key String Yes - ICU message (supports number, date, plural, and select).
vars Object No - Data object.

You can use a plural argument to select sub-messages based on a numeric value, together with the plural rules for the specified language.

<p>{{ $formatMessage(`Hey {name}!`, {name: 'John'}) }</p>

mv.$formatNumber(value, options)

Converts a value into formatted string.

Name Type Required Default Description
value Number Yes - Integer or decimal number.
options Object No - Options which are passed directly into the Intl.NumberFormat constructor.
<p>{{ $formatNumber(1234.56, {maximumFractionDigits: 0}) }</p>

mv.$formatRelativeTime(value, options)

Converts a value into relative time (e.g. 3 days ago).

Name Type Required Default Description
value Date, Integer Yes - Date object.
options Object No - Options for customizing the output (units and style).
<p>{{ $formatRelativeTime(Date.now()) }</p>

mv.$formatTime(value, options)

Converts a value into formatted time string.

Name Type Required Default Description
value Date, Integer Yes - Date object.
options Object No - Options which are passed directly into the Intl.DateTimeFormat constructor.
<p>{{ $formatTime(Date.now(), {hour: 'numeric'}) }</p>

License (MIT)

Copyright (c) 2016 Kristijan Sedlak <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].