Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vignette
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pascal Engélibert
vignette
Commits
583a3ff0
Commit
583a3ff0
authored
3 years ago
by
matograine
Browse files
Options
Downloads
Patches
Plain Diff
add ability to generate the homepage with a default lang
parent
930fc13d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
build.py
+19
-5
19 additions, 5 deletions
build.py
with
19 additions
and
5 deletions
build.py
+
19
−
5
View file @
583a3ff0
...
...
@@ -14,7 +14,6 @@ langs_dir = root_dir + "/i18n"
build_dir
=
root_dir
+
"
/build
"
base_files
=
[
'
index.html
'
,
'
licence.html
'
,
'
questions.html
'
]
SCRIPT_DEFAULT_LANG
=
"
FR
"
SCRIPT_DEFAULT_ORIENTATION
=
"
horizontal
"
...
...
@@ -47,9 +46,9 @@ def lang_menu(current_lang, langs):
def
sort_args
(
args
):
print
(
args
)
if
len
(
args
)
==
1
:
return
SCRIPT_DEFAULT_ORIENTATION
,
SCRIPT_DEFAULT_LANG
return
SCRIPT_DEFAULT_ORIENTATION
,
None
if
len
(
args
)
==
2
:
# orientation
return
get_orientation
(
args
[
1
]),
SCRIPT_DEFAULT_LANG
return
get_orientation
(
args
[
1
]),
None
if
len
(
args
)
==
3
:
# orientation
return
get_orientation
(
args
[
1
]),
get_default_lang
(
args
[
2
])
...
...
@@ -64,7 +63,7 @@ def get_orientation(user_orientation):
def
get_default_lang
(
user_def_lang
):
if
user_def_lang
==
""
:
return
SCRIPT_DEFAULT_LANG
return
None
else
:
return
user_def_lang
...
...
@@ -89,6 +88,7 @@ if __name__ == "__main__":
langs
.
append
(
lang
)
for
lang
in
langs
:
print
(
lang
)
langs
.
append
(
lang
)
source_lang_dir
=
langs_dir
+
'
/
'
+
lang
build_lang_dir
=
build_dir
+
'
/
'
+
lang
...
...
@@ -119,3 +119,17 @@ if __name__ == "__main__":
translate
(
target
,
file_trans
)
# build HTML homepage (?)
if
lang
==
default_lang
:
# copy default lang homepage to root dir
source
=
target
=
build_lang_dir
+
'
/index.html
'
target
=
build_dir
+
"
/index.html
"
shutil
.
copy
(
source
,
target
)
#replace ../ paths by ./
with
open
(
target
,
"
r
"
)
as
f
:
content
=
f
.
read
()
content
=
content
.
replace
(
"
../
"
,
"
./
"
)
content
=
content
.
replace
(
"
license.html
"
,
lang
+
"
/license.html
"
)
content
=
content
.
replace
(
"
questions.html
"
,
lang
+
"
/questions.html
"
)
# overwrite file
with
open
(
target
,
"
w
"
)
as
f
:
f
.
write
(
content
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment