FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
NotaBot/bot_localization.lua at master · DigitalPulseSoftware/NotaBot · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
DigitalPulseSoftware
/
NotaBot
Public
Notifications
You must be signed in to change notification settings
Fork
13
Star
25
Code
Issues
13
Pull requests
9
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
NotaBot
/
bot_localization.lua
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (52 loc) · 1.5 KB
Breadcrumbs
NotaBot
/
bot_localization.lua
Copy path
File metadata and controls
59 lines (52 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--
Copyright (C) 2018 Jérôme Leclercq
--
This file is part of the "Not a Bot" application
--
For conditions of distribution and use, see copyright notice in LICENSE
local
fs
=
require
(
"
fs
"
)
local
langtables
=
{}
Bot
.
LangTables
=
langtables
local
langFiles
=
fs
.
scandirSync
(
"
localization
"
)
for
filename
,
filetype
in
assert
(
langFiles
)
do
if
filetype
==
"
file
"
then
local
lang
=
filename
:
match
(
"
(%w+)%.lua
"
)
if
lang
then
local
data
,
err
=
dofile
(
"
localization/
"
..
filename
)
if
data
then
langtables
[
lang
]
=
data
else
print
(
"
failed to load language data from
"
..
filename
..
"
:
"
..
err
)
end
end
end
end
function
Bot
:
Format
(
guild
,
str
, ...)
local
serverconfig
=
self
:
GetModuleForGuild
(
guild
,
"
serverconfig
"
)
if
serverconfig
then
local
config
=
serverconfig
:
GetConfig
(
guild
)
if
config
then
local
langtable
=
langtables
[
config
.
Language
or
"
en
"
]
if
langtable
then
local
translation
=
langtable
.
Locs
[
str
]
if
translation
then
return
string.format
(
translation
,
...
)
end
end
end
end
return
string.format
(
str
,
...
)
end
function
Bot
:
FormatDuration
(
guild
,
seconds
,
depth
)
local
serverconfig
=
self
:
GetModuleForGuild
(
guild
,
"
serverconfig
"
)
if
serverconfig
then
local
config
=
serverconfig
:
GetConfig
(
guild
)
if
config
then
local
langtable
=
langtables
[
config
.
Language
or
"
en
"
]
if
langtable
then
local
formatTime
=
langtable
.
FormatTime
if
formatTime
then
return
formatTime
(
seconds
,
depth
)
end
end
end
end
return
util
.
FormatTime
(
seconds
,
depth
)
end
Back
|
FazBrowse Home
|
New Git URL