0.5.2 • Published 6 months ago

i18nizeelement v0.5.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 months ago

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
0.5.2

6 months ago

0.5.1

6 months ago

0.5.0

1 year ago

0.4.0

4 years ago

0.3.0

5 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago