Export named utilities

This commit is contained in:
Christian Kaisermann 2018-08-09 11:23:01 -03:00
parent f9b5745158
commit a264c3a282
3 changed files with 22 additions and 14 deletions

View File

@ -1,16 +1,23 @@
{
"name": "svelte-i18n",
"version": "0.0.1",
"version": "0.0.2",
"license": "MIT",
"main": "dist/i18n.js",
"module": "dist/i18n.m.js",
"types": "src/index.d.ts",
"description": "",
"description": "Internationalization library for Svelte",
"author": "Christian Kaisermann <christian@kaisermann.me>",
"repository": "https://github.com/kaisermann",
"keywords": [],
"keywords": [
"svelte",
"i18n",
"internationalization",
"localization",
"translation"
],
"scripts": {
"build": "microbundle --name='svelte-i18n'",
"start": "microbundle watch --name='svelte-i18n'",
"build": "microbundle --format=cjs,es",
"start": "microbundle watch --format=cjs,es",
"test": "jest --no-cache --verbose",
"test:watch": "jest --no-cache --verbose --watchAll",
"lint": "eslint \"src/**/*.js\"",

View File

@ -1,4 +1,3 @@
/* istanbul ignore */
/**
* Adapted from 'https://github.com/kazupon/vue-i18n/blob/dev/src/format.js'
* Copyright (c) 2016 kazuya kawaguchi

View File

@ -3,6 +3,8 @@ import resolvePath from 'object-resolve-path'
import { capital, title, upper, lower } from './utils'
import Formatter from './formatter'
export { capital, title, upper, lower }
export function i18n(store, { dictionary }) {
const formatter = new Formatter()
let dictionaries = {}
@ -32,17 +34,17 @@ export function i18n(store, { dictionary }) {
}
const utilities = {
capital(...args) {
return capital(getLocalizedMessage(...args))
capital(path, interpolations, locale) {
return capital(getLocalizedMessage(path, interpolations, locale))
},
title(...args) {
return title(getLocalizedMessage(...args))
title(path, interpolations, locale) {
return title(getLocalizedMessage(path, interpolations, locale))
},
upper(...args) {
return upper(getLocalizedMessage(...args))
upper(path, interpolations, locale) {
return upper(getLocalizedMessage(path, interpolations, locale))
},
lower(...args) {
return lower(getLocalizedMessage(...args))
lower(path, interpolations, locale) {
return lower(getLocalizedMessage(path, interpolations, locale))
},
plural(path, counter, interpolations, locale) {
return getLocalizedMessage(path, interpolations, locale, [