i18nizeelement

0.5.2 • Public • Published

npm Dependencies devDependencies

Actions Status Actions Status

Known Vulnerabilities Total Alerts Code Quality: Javascript

License

i18nizeElement

Internationalize an element with lang, dir, and style.writingMode as indicated by the supplied language and settings.

Installation

npm install i18nizeelement

Usage

import i18nizeElement from 'i18nizeelement';

i18nizeElement(document.querySelector('html'), {
  language: 'en-US',
  // Optional (Defaults shown below)
  avoidLangIfSet: true,
  avoidDirIfSet: true,
  avoidLTRByDefault: true
});

Usage (as a jamilih plugin)

import {jml, body} from 'jamilih';
import i18nizeElement from
  'i18nizeelement/dist/i18nizeelement-jamilih-plugin.js';

const options = {$plugins: [i18nizeElement]};
const j = jml.bind(null, options);

j('div', {id: 'myDiv', $_language: {
  language: 'en-US',
  // Optional (Defaults shown below)
  avoidLangIfSet: true,
  avoidDirIfSet: true,
  avoidLTRByDefault: true
}}, body);

// An alternative API is:
j('div', {id: 'myDiv', $_language: [
  'en-US' /* , optionalOptionsObjectHere */
]});

// If options are not needed you can use this format:
j('div', {id: 'myDiv', $_language: 'en-US'}, body);

Please note that this plugin suffers from one limitation: The $_language settings will only be visible on the element (e.g., lang and dir) after a Promise microtask. This is because Jamilih at present processes attributes and properties on elements before appending them to their parent, and i18nizeElement defines settings which depend on the element's intended ancestors being present.

See also

License

  • MIT

Readme

Keywords

Package Sidebar

Install

npm i i18nizeelement

Weekly Downloads

3

Version

0.5.2

License

MIT

Unpacked Size

111 kB

Total Files

18

Last publish

Collaborators

  • brettz9