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 | seo: {
|
18 | defaultCache: ["http://[url of something you know you need caching to"]
|
19 | }));
|
20 |
|
21 | app.get('/',function(req,res) {
|
22 | console.log('the current language for the user is',req.bablic.locale);
|
23 | res.render('index.ejs',{});
|
24 | });
|
25 |
|
26 | ```
|
27 |
|
28 | Typescript:
|
29 | ```sh
|
30 | import {create} from "bablic";
|
31 | app.use(create({
|
32 | siteId: '[your site id]',
|
33 | rootUrl: 'http://[root url of your site]',
|
34 | subDir: true, // if you want to use sub dir for languages like /es/ /fr/
|
35 | seo: {
|
36 | defaultCache: ["http://[url of something you know you need caching to"]
|
37 | }));
|
38 | ```
|
39 |
|
40 | In your layout template file you can add the snippet:
|
41 |
|
42 | ```
|
43 |
|
44 | <html>
|
45 | <head>
|
46 | <%- bablic.snippetTop %>
|
47 | </head>
|
48 | <body>
|
49 | <%- body %>
|
50 | </body>
|
51 | </html>
|
52 |
|
53 | ```
|
54 | And use!
|