0.0.1-0.0.24 • Published 3 years ago

intery v0.0.1-0.0.24

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

About

A simple internationalization system for Svelte. The package was originally written for the software Maidy.

Installation

Using npm|yarn:

$ npm i --save intery
$ yarn add intery

In main.js:

import {Intery, getLocaleUser, LOCALE} from 'intery';

/* Place the folder with locales 
 * outside the code folder (usually public),
 * After compiling the code, he must have access to this folder.
 */
const intery = new Intery({
	directory: '../locales/',
	initial: 'en', // Or: LOCALE.USER, 'USER', getLocaleUser()
	fallback: 'en', // Or: LOCALE.USER, 'USER', getLocaleUser()
});

/* Without specifying a directory, 
 * use the following option. 
 * 
 * If the directory is specified, 
 * these imports will be ignored.
 */
intery.addLocale('en', import('maidy-translations/src/en'));

intery.addLocale('en');
intery.addLocale('es');

intery.addLocale(LOCALE.USER); // 'USER'
/* Or */
intery.addLocale(getLocaleUser());

/* Optional, if you want to change the initial language. */
intery.setLocale('es');

In App.svelte:

  • No imports are required, once initialized, you can use Intery right away.
<script>
	/* If you are using reactive store, 
	 * override the field so that Vite 
	 * does not send fake errors. 
	 */
	const Intery = globalThis.Intery;
</script>

<div>{$Intery?.["key"] ?? "Key not found!"}</div>

In en.js (../locales/en.js)

  • export default is the standard for this package.
export default {
	key: 'Hello world!'
}

For Developers

  • Before any commit, do the following steps.
$ npm run build:required
# Or use the automatic version
$ npm run publish:npm 

See the package source for more details.

0.0.1-0.0.24

3 years ago

0.0.1-0.0.23

3 years ago

0.0.1-0.0.22

3 years ago

0.0.1-0.0.21

3 years ago

0.0.1-0.0.20

3 years ago

0.0.1-0.0.19

3 years ago

0.0.1-0.0.18

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago