UNPKG

946 BMarkdownView Raw
1# Bablic-Node-SDK
2
3To install simply use NPM:
4```sh
5$ npm install --save bablic
6```
7
8Config your app:
9
10Javascript:
11```sh
12const {create} = require("bablic");
13app.use(create({
14 siteId: '[your site id]',
15 rootUrl: 'http://[root url of your site]',
16 subDir: true, // if you want to use sub dir for languages like /es/ /fr/
17 }));
18
19app.get('/',function(req,res) {
20 console.log('the current language for the user is',req.bablic.locale);
21 res.render('index.ejs',{});
22});
23
24```
25
26Typescript:
27```sh
28import {create} from "bablic";
29app.use(create({
30 siteId: '[your site id]',
31 rootUrl: 'http://[root url of your site]',
32 subDir: true, // if you want to use sub dir for languages like /es/ /fr/
33 }));
34```
35
36In your layout template file you can add the snippet:
37
38```
39
40<html>
41 <head>
42 <%- bablic.snippetTop %>
43 </head>
44 <body>
45 <%- body %>
46 </body>
47</html>
48
49```
50And use!