1.0.25 • Published 8 months ago

multi-lang-exa v1.0.25

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

multi-lang-exa

Features

  • Datas are saved in DB
  • Fetch and display required data from package

Tech

  • Node JS, MongoDB

Simple example

import {getMessage} from "multi-lang-exa"

async function main() {
    console.log(await getMessage("greeting", "en"))
    console.log(await getMessage("greeting", "ar"))
}

Mongo Database Settings

  • Log in to MongoDB Atlas: Go to the MongoDB Atlas website (https://www.mongodb.com/cloud/atlas) and log in with your account credentials.

  • Create a New Cluster (if not already created):

  • On the MongoDB Atlas dashboard, click the "Build a Cluster" button. Follow the guided setup to create a new cluster. You can choose the cloud provider, region, and other configuration options. You may also need to set up network access and configure other settings. Create a Database:

  • Once your cluster is created and running, click on the "Clusters" option in the left sidebar. Select the cluster you just created. Click the "Collections" tab. Click the "Add My Own Data" button. Create a Database:

  • In the "Create Database" dialog, specify a name for your database (e.g., Multilangs). Create a Collection:

  • Inside your database, click the "Add Collection" button. Specify a name for your collection (e.g., Langs). You can configure additional settings for your collection as needed, such as indexing or shard key, but for a simple setup, you can keep the default settings. Add Documents to the Collection:

  • With the collection created, you can add documents to it. Each document can represent a translation, with fields for the translation key and translations in different languages.

    Sample Collection

       {
       "_id": ObjectId("some-unique-id"), // Not required
       "translationKey": "greeting",
       "translations": {
         "en": "Hello!",
         "es": "¡Hola!",
         "fr": "Bonjour!",
         "de": "Hallo!"
       }
     }
### .env file
 create the env file and add the Mongo uri
 
>MONGODB_URI=mongodb+srv://Yourusername:Password@cluster0.abc.mongodb.net/?retryWrites=true&w=majority
1.0.19

8 months ago

1.0.18

8 months ago

1.0.17

8 months ago

1.0.16

8 months ago

1.0.22

8 months ago

1.0.21

8 months ago

1.0.20

8 months ago

1.0.25

8 months ago

1.0.24

8 months ago

1.0.23

8 months ago

1.0.15

8 months ago

1.0.14

8 months ago

1.0.13

8 months ago

1.0.12

8 months ago

1.0.11

8 months ago

1.0.10

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago