Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
generateur-slogans
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LQDN Adminsys
generateur-slogans
Commits
195da958
Verified
Commit
195da958
authored
Oct 31, 2017
by
Thibaut Broggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move i18n class into another module
parent
b077396e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
19 deletions
+20
-19
i18n.js
i18n.js
+19
-0
srv.js
srv.js
+1
-19
No files found.
i18n.js
0 → 100644
View file @
195da958
const
enLocale
=
require
(
'
./locale/en.json
'
);
module
.
exports
=
function
(){
let
_locale
=
'
en
'
;
this
.
_
=
function
(
str
)
{
return
_locale
==
'
en
'
?
enLocale
[
str
]
||
str
:
str
;
}
this
.
setLocale
=
function
(
locale
)
{
_locale
=
locale
;
}
this
.
getLocale
=
function
()
{
return
_locale
;
}
return
this
;
};
srv.js
View file @
195da958
...
...
@@ -7,7 +7,7 @@ const Canvas = require('canvas');
const
Image
=
Canvas
.
Image
;
const
app
=
express
();
const
config
=
require
(
'
./config.json
'
);
const
enLocale
=
require
(
'
./locale/en.json
'
);
const
i18n
=
require
(
'
./i18n.js
'
)(
);
app
.
set
(
'
x-powered-by
'
,
false
);
app
.
set
(
'
view engine
'
,
'
pug
'
);
...
...
@@ -154,24 +154,6 @@ app.get('/generate.png', function (req, res) {
})
});
let
i18n
=
(
function
(){
let
_locale
=
'
en
'
;
this
.
_
=
function
(
str
)
{
return
_locale
==
'
en
'
?
enLocale
[
str
]
||
str
:
str
;
}
this
.
setLocale
=
function
(
locale
)
{
_locale
=
locale
;
}
this
.
getLocale
=
function
()
{
return
_locale
;
}
return
this
;
})();
app
.
get
(
'
/
'
,
function
(
req
,
res
)
{
let
locale
=
req
.
headers
[
'
accept-language
'
]
||
''
;
i18n
.
setLocale
(
locale
.
indexOf
(
'
en
'
)
!==
-
1
&&
locale
.
indexOf
(
'
en
'
)
<
locale
.
indexOf
(
'
fr
'
)
?
'
en
'
:
'
fr
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment