Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
Desktop Client
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
SpinShare
Desktop Client
Commits
caa532d0
Commit
caa532d0
authored
Apr 02, 2020
by
Andreas Heimann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added localization
parent
ad9202e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
src/assets/js/module.locale.js
src/assets/js/module.locale.js
+34
-0
No files found.
src/assets/js/module.locale.js
0 → 100644
View file @
caa532d0
const
electron
=
require
(
'
electron
'
);
const
path
=
require
(
'
path
'
);
const
fs
=
require
(
'
fs
'
);
class
Locale
{
constructor
(
localeToLoad
)
{
this
.
localePath
=
path
.
join
(
__dirname
,
"
..
"
,
"
..
"
,
"
locale
"
,
localeToLoad
+
'
.json
'
);
this
.
fallbackPath
=
path
.
join
(
__dirname
,
"
..
"
,
"
..
"
,
"
locale
"
,
'
en.json
'
);
// Fallback to "en" if language is not supported
if
(
fs
.
existsSync
(
this
.
localePath
))
{
this
.
path
=
this
.
localePath
;
}
else
{
this
.
path
=
this
.
fallbackPath
;
}
this
.
strings
=
parseDataFile
(
this
.
path
);
console
.
log
(
"
Loaded Locale
"
+
localeToLoad
);
}
get
(
key
)
{
return
this
.
strings
[
key
];
}
}
function
parseDataFile
(
filePath
)
{
try
{
return
JSON
.
parse
(
fs
.
readFileSync
(
filePath
));
}
catch
(
error
)
{
throw
error
;
}
}
module
.
exports
=
Locale
;
\ No newline at end of file
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