the-api-langs
v0.2.2
Published
Langs for the-api
Readme
the-api langs
Migrations and routings for multilingual text dictionaries in the-api.
Installation
npm i -S the-api-langsUsage
cat index.ts
import { langs } from 'the-api-langs';
const router = new Routings();
router.crud({ table: 'testNews' });
const theAPI = new TheAPI({ routings: [langs, router] });
export default theAPI.up();bun index.ts
curl 'http://localhost:7788/testNews?_lang=de'Migrations
The package registers migrations from src/migrations.
dict
The dict table stores translated text values. It replaces the previous
langs table name.
| Column | Type | Notes |
| --- | --- | --- |
| id | integer | Primary key |
| textKey | integer | Translation key |
| lang | string(2) | Language code |
| text | string(4096) | Translated text |
Indexes:
dict_text_idxontextdict_text_key_idxontextKeydict_lang_text_idxonlang, textdict_lang_text_key_idxunique onlang, textKey
languages
The languages table stores metadata for available languages.
| Column | Type | Notes |
| --- | --- | --- |
| id | integer | Primary key |
| timeCreated | timestamp with timezone | Defaults to current timestamp |
| timeUpdated | timestamp with timezone | Defaults to current timestamp |
| code | string(2) | Unique language code |
| nativeName | string(128) | Language name in the language itself |
| englishName | string(128) | Language name in English |
| textDirection | string(3) | Defaults to ltr; for example rtl for right-to-left languages |
| isActive | boolean | Defaults to true |
Indexes:
languages_code_idxunique oncodelanguages_native_name_idxonnativeNamelanguages_english_name_idxonenglishNamelanguages_is_active_idxonisActive
