open-index/open-npm huggingface dataset:
npm package: @piclist/i18n
Description: i18n tool
Author: Kuingsmile
Latest version: 2.0.0

# i18n

i18n 工具

## 用法

i18n 默认提供 FileSyncAdapter、ObjectAdapter 两个适配器，适用的场景分别为:

- FileSyncAdapter: locales 信息保存在文件中, 该适配器**只适用于 Nodejs 平台**
- ObjectAdapter: locales 信息保存在对象中, 该适配器适用于 Web 平台、Nodejs 平台

### Nodejs

- 安装

  npm install @piclist/i18n

- 使用

  ```js
  import { I18n, FileSyncAdapter, ObjectAdapter } from '@piclist/i18n';

  // use FileSyncAdapter
  const fileSyncAdapter = new FileSyncAdapter({
    localesBaseDir: path.resolve(__dirname, './locales'), // locales文件目录
  });

  const i18n = new I18n({
    adapter: fileSyncAdapter,
    defaultLanguage: 'zh',
  });

  // use ObjectAdapter
  const objectAdapter = new ObjectAdapter({
    zh: {
      user: {
        name: 'PicList',
        country: '中国',
      },
      report: {
        singular: ' ${cnt}个报告',
        plural: '${cnt}个报告',
      },
    },
    en: {
      user: {
        name: 'PicList',
        country: 'China',
      },
      report: {
        singular: 'only ${cnt} report',
        plural: '${cnt} reports',
      },
    },
  });
  const i18n = new I18n({
    adapter: objectAdapter,
    defaultLanguage: 'zh',
  });
  ```

### 自定义 Adapter

```js
import { BaseAdapter } from '@piclist/i18n';
class CustomAdapter extends BaseAdapter {
  getLocale(language) {}
}
```

### API

#### I18n

- 构造函数 I18n

  - 参数: options

    ```json
    {
      "adater": BaseAdapter, // 适配器
      "defaultLanguage": string // 默认语言
    }
    ```

  - 返回值: I18n 实例

- i18n.setLanguage

  - 参数: language, 语言类型
  - 无返回值

- i18n.getLauguage

  - 无参数
  - 返回当前语言类型

- i18n.translate

  - 参数 phrase, args
  - 返回翻译后文本

  ```json
  // en.json
  {
    "report": {
      "singular": "only ${cnt} report",
      "plural": "${cnt} reports"
    }
  }
  ```

  ```js
  i18n.translate('report.singular', { cnt: 1 }); // only 1 report
  ```

#### FileSyncAdapter

- 构造函数 FileSyncAdapter

  - 参数: options

    ```json
    {
      "localesBaseDir": string, // locales 文件所在路径，绝对路径
      "localeFileName": { "language": 对应的locales文件名 } // localeFileName存储语言类型到locales文件的映射，该项可选，当不传入时，将自动扫描localesBaseDir目录下文件，并将各个locale文件名作为该文件对应的语言
    }
    ```

  - 返回 FileSyncAdapter 实例

- fileSyncAdapter.getLocale
  - 参数 languag, 语言类型
  - 返回 language 对应的 locale 数据

#### ObjectAdapter

- 构造函数 ObjectAdapter

  - 参数 locales, 保存 locales 信息的对象

  ```json
  {
    "zh": {
      "user": {
        "name": "PicList",
        "country": "China"
      },
      "report": {
        "singular": " ${cnt}个报告",
        "plural": "${cnt}个报告"
      }
    },
    "en": {
      "user": {
        "name": "PicList",
        "country": "China"
      },
      "report": {
        "singular": "only ${cnt} report",
        "plural": "${cnt} reports"
      }
    }
  }
  ```

  - 返回 ObjectAdapter 实例

- objectAdapter.getLocale
  - 参数 languag, 语言类型
  - 返回 language 对应的 locale 数据

- objectAdapter.setLocales 用于动态修改 objectAdapter 上的 locales 数据

  - 参数 locales, locales 数据
  - 无返回值

  ```js
  objectAdapter.setLocales({
    zh: {
      newData: 'this is new Data',
    },
  });
  ```

### License

[MIT](http://opensource.org/licenses/MIT)

Copyright (c) 2025 Kuingsmile
npm package: @picmo/popup-picker
Description: Popup emoji picker for PicMo
Author: Joe Attardi
Latest version: 5.8.5
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @picmo/popup-picker

Adds support to PicMo for showing a picker in a popup element.

Requires the [base PicMo package](../picmo) to be installed as a peer dependency.

## Installation

```
npm install @picmo/popup-picker
```

## Basic usage

To show a popup picker, you'll need a trigger element. This is often a button or other clickable element that can show the popup picker in response to a click event.

```javascript
import { createPopup } from '@picmo/popup-picker';

const triggerButton = document.querySelector('#emoji-button');

// Create the picker
const picker = createPopup({}, {
  // The element that triggers the popup
  triggerElement: triggerButton,

  // The element to position the picker relative to - often this is also the trigger element,
  referenceElement: triggerButton,

  // specify how to position the popup
  position: 'bottom-start'
});

// The picker emits an event when an emoji is selected. Do with it as you will!
picker.addEventListener('emoji:select', event => {
  console.log('Emoji selected:', event.emoji);
});
```
npm package: @picmo/renderer-twemoji
Description: Twemoji renderer for PicMo
Author: Joe Attardi
Latest version: 5.8.5
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @picmo/renderer-twemoji

Adds support to PicMo for rendering emojis from [Twemoji](https://twemoji.twitter.com) instead of native platform emojis.

Requires the [base PicMo package](../picmo) to be installed as a peer dependency.

<img width="390" alt="Twemoji renderer" src="https://user-images.githubusercontent.com/219285/167279294-6a5341cb-e211-46b0-a179-348293715bfa.png">


## Installation

```
npm install @picmo/renderer-twemoji
```

## Basic usage

```javascript
import { createPicker } from 'picmo';
import { TwemojiRenderer } from '@picmo/renderer-twemoji';

// The picker must have a root element to insert itself into
const rootElement = document.querySelector('#pickerContainer');

// Create the picker
const picker = createPicker({ 
  rootElement,
  renderer: new TwemojiRenderer()
});

// The picker emits an event when an emoji is selected. Do with it as you will!
picker.addEventListener('emoji:select', event => {
  console.log('Emoji selected:', event.emoji);
});
```