mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-06-30 18:54:49 +02: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",
|
"name": "svelte-i18n",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "dist/i18n.js",
|
"main": "dist/i18n.js",
|
||||||
|
"module": "dist/i18n.m.js",
|
||||||
"types": "src/index.d.ts",
|
"types": "src/index.d.ts",
|
||||||
"description": "",
|
"description": "Internationalization library for Svelte",
|
||||||
"author": "Christian Kaisermann <christian@kaisermann.me>",
|
"author": "Christian Kaisermann <christian@kaisermann.me>",
|
||||||
"repository": "https://github.com/kaisermann",
|
"repository": "https://github.com/kaisermann",
|
||||||
"keywords": [],
|
"keywords": [
|
||||||
|
"svelte",
|
||||||
|
"i18n",
|
||||||
|
"internationalization",
|
||||||
|
"localization",
|
||||||
|
"translation"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "microbundle --name='svelte-i18n'",
|
"build": "microbundle --format=cjs,es",
|
||||||
"start": "microbundle watch --name='svelte-i18n'",
|
"start": "microbundle watch --format=cjs,es",
|
||||||
"test": "jest --no-cache --verbose",
|
"test": "jest --no-cache --verbose",
|
||||||
"test:watch": "jest --no-cache --verbose --watchAll",
|
"test:watch": "jest --no-cache --verbose --watchAll",
|
||||||
"lint": "eslint \"src/**/*.js\"",
|
"lint": "eslint \"src/**/*.js\"",
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* istanbul ignore */
|
|
||||||
/**
|
/**
|
||||||
* Adapted from 'https://github.com/kazupon/vue-i18n/blob/dev/src/format.js'
|
* Adapted from 'https://github.com/kazupon/vue-i18n/blob/dev/src/format.js'
|
||||||
* Copyright (c) 2016 kazuya kawaguchi
|
* 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 { capital, title, upper, lower } from './utils'
|
||||||
import Formatter from './formatter'
|
import Formatter from './formatter'
|
||||||
|
|
||||||
|
export { capital, title, upper, lower }
|
||||||
|
|
||||||
export function i18n(store, { dictionary }) {
|
export function i18n(store, { dictionary }) {
|
||||||
const formatter = new Formatter()
|
const formatter = new Formatter()
|
||||||
let dictionaries = {}
|
let dictionaries = {}
|
||||||
|
@ -32,17 +34,17 @@ export function i18n(store, { dictionary }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const utilities = {
|
const utilities = {
|
||||||
capital(...args) {
|
capital(path, interpolations, locale) {
|
||||||
return capital(getLocalizedMessage(...args))
|
return capital(getLocalizedMessage(path, interpolations, locale))
|
||||||
},
|
},
|
||||||
title(...args) {
|
title(path, interpolations, locale) {
|
||||||
return title(getLocalizedMessage(...args))
|
return title(getLocalizedMessage(path, interpolations, locale))
|
||||||
},
|
},
|
||||||
upper(...args) {
|
upper(path, interpolations, locale) {
|
||||||
return upper(getLocalizedMessage(...args))
|
return upper(getLocalizedMessage(path, interpolations, locale))
|
||||||
},
|
},
|
||||||
lower(...args) {
|
lower(path, interpolations, locale) {
|
||||||
return lower(getLocalizedMessage(...args))
|
return lower(getLocalizedMessage(path, interpolations, locale))
|
||||||
},
|
},
|
||||||
plural(path, counter, interpolations, locale) {
|
plural(path, counter, interpolations, locale) {
|
||||||
return getLocalizedMessage(path, interpolations, locale, [
|
return getLocalizedMessage(path, interpolations, locale, [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user