# qamoos

> qamoos is a small dictionnary to manage internationalization of an application.

Latest version **0.1.5** (published 2015-02-28) · GNU GPL v2 license · 0 weekly downloads

## Install

```sh
npm install qamoos
pnpm add qamoos
yarn add qamoos
bun add qamoos
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2015-02-28 |
| First published | 2015-02-28 |
| Weekly downloads | 0 |
| License | GNU GPL v2 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Samir ROUABHI |
| Maintainers | rouabhi |
| Keywords | i18n, internationalization, languages, translation |

## Links

- npm: https://www.npmjs.com/package/qamoos
- Repository: https://rouabhi@bitbucket.org/cloudestin/qamoos
- npm.io page: https://npm.io/package/qamoos

## Dependencies (1)

- [varsession](https://npm.io/package/varsession.md) *

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2015-02-28

## README

# qamoos #

**qamoos** is a multilingual index package for node.js.

**qamoos** is a small dictionnary to manage internationalization of an application. You can define indexes of messages in different languages and access to them with a code.

## How does it work ? ##
You should define different messages inside a **qamoos** defined by its name. Data is stored in a global variable so you can define it once in the project and use it while needed.

**First define a qamoos ** (run this once in the project)
```javascript
var Qamoos = require("qamoos")(req);

var myBook = Qamoos.define("myBook");

myBook.set('run', {"fr":"Serveur a l'ecoute du port " , en:"Server listening port " });
myBook.set('name', {"fr":"Nom de l'application" , en:"appName" });
myBook.set('def', {"fr":"defaut" , "en":"default"});
```

Now, somewhere in your project, when you need a translation:
```javascript
var Qamoos = require("qamoos")(req);
var myBook = Qamoos.define("myBook");

console.log(myBook.get('run'),81);
Qamoos.lang("fr"); // define french as default language (english is the default value)
console.log(myBook.get('run'),81);
```

## Data persistence ##
 - A '**qamoos**' dictionnary is stored in a server variable (global object) so that it can be accessible from any module.
 - Language information is stored as a session variable (cookie), so it could be changed for each session. So, you should use "express-session" middleware to store session information in coockies:

```javacript
var express = require('express');
var app = express();
var expressSession = require('express-session');

app.use( expressSession({secret:'mySecretKey', cookie: { maxAge: 60000 }, resave:false, saveUninitialized:true}) );
```

You can create a **qamoos** for each module or application. The data is grouped as ONE global object in the server and shared by users and sessions.

## Error messages ##
You can attribute a code to your messages and get the translation in the form of an error object:

```javascript
var Qamoos = require("qamoos")(req);
var myBook = Qamoos.define("myBook");

myBook.set('badLogin', {fr:"Login incorrect", en:"Bad login"},-101);
myBook.set('badPassword', {fr:"Mot de passe incorrect", en:"Bad password"},-102);


console.log(myBook.getErr('badLogin'),81);
```

Will give you:
```javascript
{ err:-101, msg:'Bad login'}
```

---
_Source: https://npm.io/package/qamoos · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
