Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nicolas Frandeboeuf
kresus
Commits
4bad6d65
Commit
4bad6d65
authored
Apr 14, 2017
by
Benjamin Bouvier
Browse files
Tweak !381;
parent
5ff26dff
Changes
1
Hide whitespace changes
Inline
Side-by-side
shared/helpers.js
View file @
4bad6d65
...
...
@@ -2,7 +2,7 @@
// Locales
// It is necessary to load the locale files statically,
// otherwise the files are not inclued in the client
// otherwise the files are not inclu
d
ed in the client
const
FR_LOCALE
=
require
(
'
./locales/fr
'
);
const
EN_LOCALE
=
require
(
'
./locales/en
'
);
...
...
@@ -54,12 +54,9 @@ let alertMissing = null;
export
function
setupTranslator
(
locale
)
{
let
p
=
new
Polyglot
({
allowMissing
:
true
});
// If no locale is defined, default to 'en';
let
language
=
locale
?
locale
:
'
en
'
;
let
found
=
true
;
switch
(
languag
e
)
{
let
checkedLocale
=
locale
;
switch
(
checkedLocal
e
)
{
case
'
fr
'
:
p
.
extend
(
FR_LOCALE
);
break
;
...
...
@@ -67,17 +64,18 @@ export function setupTranslator(locale) {
p
.
extend
(
EN_LOCALE
);
break
;
default
:
console
.
log
(
"
Didn't find locale
"
,
language
,
'
using en-us instead.
'
);
console
.
log
(
"
Didn't find locale
"
,
checkedLocale
,
'
using en-us instead.
'
);
checkedLocale
=
'
en
'
;
found
=
false
;
p
.
extend
(
EN_LOCALE
);
break
;
}
translator
=
p
.
t
.
bind
(
p
);
appLocale
=
languag
e
;
appLocale
=
checkedLocal
e
;
alertMissing
=
found
;
moment
.
locale
(
languag
e
);
moment
.
locale
(
checkedLocal
e
);
}
const
toShortString
=
date
=>
moment
(
date
).
format
(
'
L
'
);
...
...
Write
Preview
Supports
Markdown
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