p15n.js

1.0.3 • Public • Published

p15n.js

p15nとはPrefectureization(都道府県化)のことで、簡単に『方言』が使えるライブラリです。

Installation

ブラウザから:
<script src="p15n.js"></script>
npmを使う:
$ npm install p15n.js

Usage

コールバック関数を渡す方法:
import p15n from 'p15n';

p15n.init({
  pref: '鳥取県',
  resources: {
    '鳥取県': {
      'title': 'p15nライブラリを作ってみたにぃ! すごいだらぁ!?',
      'description': 'p15n.jsは簡単に『方言』が使えるライブラリだにぃ。'
    }
  }
}, function(t) {
  // initialized and ready to go!
  document.getElementById('title').textContent = p15n.t('title');
  document.getElementById('description').textContent = p15n.t('description');
});
Promiseを使う方法:
import p15n from 'p15n';

p15n.init({
  pref: '鳥取県',
  resources: {
    '鳥取県': {
      'title': 'p15nライブラリを作ってみたにぃ! すごいだらぁ!?',
      'description': 'p15n.jsは簡単に『方言』が使えるライブラリだにぃ。'
    }
  }
}).then(() => {
  // initialized and ready to go!
  document.getElementById('title').textContent = p15n.t('title');
  document.getElementById('description').textContent = p15n.t('description');
});

License

p15n.js is created under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i p15n.js

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

7.66 kB

Total Files

6

Last publish

Collaborators

  • azukisiromochi