mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-11-16 18:10:43 +01:00
Export named utilities
This commit is contained in:
parent
f9b5745158
commit
a264c3a282
17
package.json
17
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 <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\"",
|
||||
|
@ -1,4 +1,3 @@
|
||||
/* istanbul ignore */
|
||||
/**
|
||||
* Adapted from 'https://github.com/kazupon/vue-i18n/blob/dev/src/format.js'
|
||||
* Copyright (c) 2016 kazuya kawaguchi
|
||||
|
18
src/index.js
18
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, [
|
||||
|
Loading…
Reference in New Issue
Block a user