Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
412571a4
Commit
412571a4
authored
Oct 04, 2017
by
Tim Zallmann
Committed by
Phil Hughes
Oct 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load only the currently needed JS locale file
parent
08678441
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
26 deletions
+19
-26
app/assets/javascripts/locale/index.js
app/assets/javascripts/locale/index.js
+1
-19
app/views/layouts/_head.html.haml
app/views/layouts/_head.html.haml
+1
-1
config/application.rb
config/application.rb
+1
-0
config/initializers/gettext_rails_i18n_patch.rb
config/initializers/gettext_rails_i18n_patch.rb
+14
-0
config/webpack.config.js
config/webpack.config.js
+1
-5
lib/tasks/gitlab/assets.rake
lib/tasks/gitlab/assets.rake
+1
-1
No files found.
app/assets/javascripts/locale/index.js
View file @
412571a4
import
Jed
from
'
jed
'
;
import
Jed
from
'
jed
'
;
import
sprintf
from
'
./sprintf
'
;
import
sprintf
from
'
./sprintf
'
;
/**
This is required to require all the translation folders in the current directory
this saves us having to do this manually & keep up to date with new languages
**/
function
requireAll
(
requireContext
)
{
return
requireContext
.
keys
().
map
(
requireContext
);
}
const
allLocales
=
requireAll
(
require
.
context
(
'
./
'
,
true
,
/^
(?!
.*
(?:
index.js$
))
.*
\.
js$/
));
const
locales
=
allLocales
.
reduce
((
d
,
obj
)
=>
{
const
data
=
d
;
const
localeKey
=
Object
.
keys
(
obj
)[
0
];
data
[
localeKey
]
=
obj
[
localeKey
];
return
data
;
},
{});
const
langAttribute
=
document
.
querySelector
(
'
html
'
).
getAttribute
(
'
lang
'
);
const
langAttribute
=
document
.
querySelector
(
'
html
'
).
getAttribute
(
'
lang
'
);
const
lang
=
(
langAttribute
||
'
en
'
).
replace
(
/-/g
,
'
_
'
);
const
lang
=
(
langAttribute
||
'
en
'
).
replace
(
/-/g
,
'
_
'
);
const
locale
=
new
Jed
(
locales
[
lang
]
);
const
locale
=
new
Jed
(
window
.
translations
||
{}
);
/**
/**
Translates `text`
Translates `text`
@param text The text to be translated
@param text The text to be translated
@returns {String} The translated text
@returns {String} The translated text
**/
**/
...
...
app/views/layouts/_head.html.haml
View file @
412571a4
...
@@ -37,9 +37,9 @@
...
@@ -37,9 +37,9 @@
-
if
content_for?
(
:library_javascripts
)
-
if
content_for?
(
:library_javascripts
)
=
yield
:library_javascripts
=
yield
:library_javascripts
=
javascript_include_tag
asset_path
(
"locale/
#{
I18n
.
locale
.
to_s
||
I18n
.
default_locale
.
to_s
}
/app.js"
)
=
webpack_bundle_tag
"webpack_runtime"
=
webpack_bundle_tag
"webpack_runtime"
=
webpack_bundle_tag
"common"
=
webpack_bundle_tag
"common"
=
webpack_bundle_tag
"locale"
=
webpack_bundle_tag
"main"
=
webpack_bundle_tag
"main"
=
webpack_bundle_tag
"raven"
if
current_application_settings
.
clientside_sentry_enabled
=
webpack_bundle_tag
"raven"
if
current_application_settings
.
clientside_sentry_enabled
=
webpack_bundle_tag
"test"
if
Rails
.
env
.
test?
=
webpack_bundle_tag
"test"
if
Rails
.
env
.
test?
...
...
config/application.rb
View file @
412571a4
...
@@ -105,6 +105,7 @@ module Gitlab
...
@@ -105,6 +105,7 @@ module Gitlab
config
.
assets
.
precompile
<<
"lib/ace.js"
config
.
assets
.
precompile
<<
"lib/ace.js"
config
.
assets
.
precompile
<<
"vendor/assets/fonts/*"
config
.
assets
.
precompile
<<
"vendor/assets/fonts/*"
config
.
assets
.
precompile
<<
"test.css"
config
.
assets
.
precompile
<<
"test.css"
config
.
assets
.
precompile
<<
"locale/**/app.js"
# Version of your assets, change this if you want to expire all your assets
# Version of your assets, change this if you want to expire all your assets
config
.
assets
.
version
=
'1.0'
config
.
assets
.
version
=
'1.0'
...
...
config/initializers/gettext_rails_i18n_patch.rb
View file @
412571a4
...
@@ -39,3 +39,17 @@ module GettextI18nRailsJs
...
@@ -39,3 +39,17 @@ module GettextI18nRailsJs
end
end
end
end
end
end
class
PoToJson
# This is required to modify the JS locale file output to our import needs
# Overwrites: https://github.com/webhippie/po_to_json/blob/master/lib/po_to_json.rb#L46
def
generate_for_jed
(
language
,
overwrite
=
{})
@options
=
parse_options
(
overwrite
.
merge
(
language:
language
))
@parsed
||=
inject_meta
(
parse_document
)
generated
=
build_json_for
(
build_jed_for
(
@parsed
))
[
"window.translations =
#{
generated
}
;"
].
join
(
" "
)
end
end
config/webpack.config.js
View file @
412571a4
...
@@ -122,10 +122,6 @@ var config = {
...
@@ -122,10 +122,6 @@ var config = {
name
:
'
[name].[hash].[ext]
'
,
name
:
'
[name].[hash].[ext]
'
,
}
}
},
},
{
test
:
/locale
\/\w
+
\/(
.*
)\.
js$/
,
loader
:
'
exports-loader?locales
'
,
},
{
{
test
:
/monaco-editor
\/\w
+
\/
vs
\/
loader
\.
js$/
,
test
:
/monaco-editor
\/\w
+
\/
vs
\/
loader
\.
js$/
,
use
:
[
use
:
[
...
@@ -224,7 +220,7 @@ var config = {
...
@@ -224,7 +220,7 @@ var config = {
// create cacheable common library bundles
// create cacheable common library bundles
new
webpack
.
optimize
.
CommonsChunkPlugin
({
new
webpack
.
optimize
.
CommonsChunkPlugin
({
names
:
[
'
main
'
,
'
locale
'
,
'
common
'
,
'
webpack_runtime
'
],
names
:
[
'
main
'
,
'
common
'
,
'
webpack_runtime
'
],
}),
}),
// enable scope hoisting
// enable scope hoisting
...
...
lib/tasks/gitlab/assets.rake
View file @
412571a4
...
@@ -3,8 +3,8 @@ namespace :gitlab do
...
@@ -3,8 +3,8 @@ namespace :gitlab do
desc
'GitLab | Assets | Compile all frontend assets'
desc
'GitLab | Assets | Compile all frontend assets'
task
compile:
[
task
compile:
[
'yarn:check'
,
'yarn:check'
,
'rake:assets:precompile'
,
'gettext:po_to_json'
,
'gettext:po_to_json'
,
'rake:assets:precompile'
,
'webpack:compile'
,
'webpack:compile'
,
'fix_urls'
'fix_urls'
]
]
...
...
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