Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/willin/hyperapp-i18n
I18n Plugin for Hyperapp
https://github.com/willin/hyperapp-i18n
hyperapp i18n
Last synced: 27 days ago
JSON representation
I18n Plugin for Hyperapp
- Host: GitHub
- URL: https://github.com/willin/hyperapp-i18n
- Owner: willin
- License: mit
- Created: 2018-01-20T07:27:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-10T18:02:15.000Z (over 6 years ago)
- Last Synced: 2024-05-22T13:22:52.061Z (6 months ago)
- Topics: hyperapp, i18n
- Language: JavaScript
- Size: 20.5 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hyperapp-i18n
[![Travis CI](https://img.shields.io/travis/willin/hyperapp-i18n/master.svg)](https://travis-ci.org/willin/hyperapp-i18n) [![Codecov](https://img.shields.io/codecov/c/github/willin/hyperapp-i18n/master.svg)](https://codecov.io/gh/willin/hyperapp-i18n) [![npm](https://img.shields.io/npm/v/hyperapp-i18n.svg)](https://www.npmjs.org/package/hyperapp-i18n) [![Slack](https://hyperappjs.herokuapp.com/badge.svg)](https://hyperappjs.herokuapp.com "Join us")
I18n Plugin for [Hyperapp](https://github.com/hyperapp/hyperapp).
## Installation
Install with npm or Yarn.
```
npm i hyperapp-i18n
```If you don't want to set up a build environment, you can download Hyperapp I18n from a CDN like [unpkg.com](https://unpkg.com/hyperapp-i18n) and it will be globally available through the window.i18n object. If your library is a high-order-app, export it as window.i18n.
```html
```
## Usage
```js
// i18n.js
import i18n from 'hyperapp-i18n';export const { state, actions } = i18n({
'zh-CN': {
hello: '你好'
},
'en-US': {
hello: 'Hello'
}
}, 'zh-CN');// app.js
import { app, h } from 'hyperapp';
import * as i18n from './i18n';const state = {
i18n: i18n.state
};
const actions = {
i18n: i18n.actions
};const view = ({ i18n: { messages, locale } }) => (
Current Lang: {locale}
Test1: {messages.hello}
);const main = app(state, actions, view, document.body);
main.i18n.set('en-US');
```See the Example folder for more detailed useage info.
## LICENSE
MIT