From a264c3a2826c8a4b6b742982d4bb7d42879ee402 Mon Sep 17 00:00:00 2001 From: Christian Kaisermann Date: Thu, 9 Aug 2018 11:23:01 -0300 Subject: [PATCH] Export named utilities --- package.json | 17 ++++++++++++----- src/formatter.js | 1 - src/index.js | 18 ++++++++++-------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 31aec5a..1207965 100644 --- a/package.json +++ b/package.json @@ -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 ", "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\"", diff --git a/src/formatter.js b/src/formatter.js index 5ae25e6..0ad02f3 100644 --- a/src/formatter.js +++ b/src/formatter.js @@ -1,4 +1,3 @@ -/* istanbul ignore */ /** * Adapted from 'https://github.com/kazupon/vue-i18n/blob/dev/src/format.js' * Copyright (c) 2016 kazuya kawaguchi diff --git a/src/index.js b/src/index.js index 45ca37b..de165d3 100644 --- a/src/index.js +++ b/src/index.js @@ -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, [