1 | # Bablic-Node-SDK
|
2 |
|
3 | To install simply use NPM:
|
4 | ```sh
|
5 | $ npm install --save bablic
|
6 | ```
|
7 |
|
8 | Config your app:
|
9 |
|
10 | Javascript:
|
11 | ```sh
|
12 | const {create} = require("bablic");
|
13 | app.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 |
|
19 | app.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 |
|
26 | Typescript:
|
27 | ```sh
|
28 | import {create} from "bablic";
|
29 | app.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 |
|
36 | In 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 | ```
|
50 | And use!
|