Skip to content

Commit

Permalink
index.js
Browse files Browse the repository at this point in the history
--> Default lang file wasnot be loaded. It is fixed.
  • Loading branch information
hkaraoglu committed Aug 21, 2019
1 parent f0e0922 commit 971b4b9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ When your app started, firstly the module creates **language** folder in root di
-> en
-> en.json // It creates for common texts
-> And your other language files...
-> mapping.json


--
Expand Down Expand Up @@ -116,8 +115,6 @@ When your app started, firstly the module creates **language** folder in root di
---


## mapping.json

Example:

**Your Application directory:**
Expand All @@ -134,7 +131,7 @@ Example:
-> home.json
-> about.json
-> users.json
-> mapping.json



Please **STAR** and **WATCH** the project! :)
Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ var init = function(_config)
{
res.cookie(config.cookieName, config.cookieLang);
}
res.locals.lt_config_cookieLang = config.cookieLang;
var lfl = new LangFileLoader(req, res);
res.locals[app.get('lt_config_instanceName')] = lfl;
res.locals.lt_config_cookieLang = config.cookieLang;
next();
};
}
Expand Down Expand Up @@ -272,12 +272,14 @@ class LangFileLoader
{
this.req = req;
this.res = res;
var fullPath = app.get("lt_config_langDir") + "/" + res.locals.lt_config_cookieLang + "/" + this.res.locals.lt_config_cookieLang + ".json";
this.data = JSON.parse(fs.readFileSync(fullPath, "utf8"));
}

load(filePath)
{
var fullPath = app.get("lt_config_langDir") + "/" + this.res.locals.lt_config_cookieLang + "/" + filePath + ".json";
this.data = JSON.parse(fs.readFileSync(fullPath, "utf8"));
this.data = Object.assign(this.data, JSON.parse(fs.readFileSync(fullPath, "utf8")));
}

get(key)
Expand Down
Binary file removed language-translator-1.2.3.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "language-translator",
"version": "1.2.5",
"version": "1.2.6",
"description": "Language localization and text translation module for NodeJS Express framework",
"preferGlobal": "true",
"main": "index.js",
Expand Down

0 comments on commit 971b4b9

Please sign in to comment.