Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Bob
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Bob
Commits
3b91ff9d
Verified
Commit
3b91ff9d
authored
2 months ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix: init data structures
parent
b6242b63
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/translate/main.go
+11
-14
11 additions, 14 deletions
source/translate/main.go
source/types/page-data.go
+5
-3
5 additions, 3 deletions
source/types/page-data.go
with
16 additions
and
17 deletions
source/translate/main.go
+
11
−
14
View file @
3b91ff9d
...
@@ -188,8 +188,8 @@ func applyTranslations(page, origin types.PageData, translations map[string]stri
...
@@ -188,8 +188,8 @@ func applyTranslations(page, origin types.PageData, translations map[string]stri
}
}
newPage
.
Meta
=
newMeta
newPage
.
Meta
=
newMeta
// Text
.Text
newPage
.
Text
=
make
([]
types
.
Text
,
len
(
origin
.
Text
))
for
i
,
t
:=
range
newPage
.
Text
{
for
i
,
t
:=
range
origin
.
Text
{
tt
:=
origin
.
Text
[
i
]
tt
:=
origin
.
Text
[
i
]
if
tr
,
ok
:=
translations
[
tt
.
Text
];
ok
{
if
tr
,
ok
:=
translations
[
tt
.
Text
];
ok
{
newPage
.
Text
[
i
]
.
Text
=
tr
newPage
.
Text
[
i
]
.
Text
=
tr
...
@@ -198,30 +198,26 @@ func applyTranslations(page, origin types.PageData, translations map[string]stri
...
@@ -198,30 +198,26 @@ func applyTranslations(page, origin types.PageData, translations map[string]stri
}
}
}
}
// Images: Alt und Title
newPage
.
Images
=
make
([]
types
.
Image
,
len
(
origin
.
Images
))
for
i
,
img
:=
range
newPage
.
Images
{
for
i
,
img
:=
range
origin
.
Images
{
imgOrigin
:=
origin
.
Images
[
i
]
if
tr
,
ok
:=
translations
[
img
.
Alt
];
ok
{
if
tr
,
ok
:=
translations
[
imgOrigin
.
Alt
];
ok
{
newPage
.
Images
[
i
]
.
Alt
=
tr
newPage
.
Images
[
i
]
.
Alt
=
tr
}
else
{
}
else
{
newPage
.
Images
[
i
]
.
Alt
=
img
.
Alt
newPage
.
Images
[
i
]
.
Alt
=
img
.
Alt
}
}
if
tr
,
ok
:=
translations
[
img
Origin
.
Title
];
ok
{
if
tr
,
ok
:=
translations
[
img
.
Title
];
ok
{
newPage
.
Images
[
i
]
.
Title
=
tr
newPage
.
Images
[
i
]
.
Title
=
tr
}
else
{
}
else
{
newPage
.
Images
[
i
]
.
Title
=
img
.
Title
newPage
.
Images
[
i
]
.
Title
=
img
.
Title
}
}
}
}
// Anchors: Title
newPage
.
Anchors
=
make
([]
types
.
Anchor
,
len
(
origin
.
Anchors
))
for
i
,
anc
:=
range
newPage
.
Anchors
{
for
i
,
anc
:=
range
origin
.
Anchors
{
ancOrigin
:=
origin
.
Anchors
[
i
]
if
tr
,
ok
:=
translations
[
anc
Origin
.
Title
];
ok
{
if
tr
,
ok
:=
translations
[
anc
.
Title
];
ok
{
newPage
.
Anchors
[
i
]
.
Title
=
tr
newPage
.
Anchors
[
i
]
.
Title
=
tr
}
else
{
}
else
{
newPage
.
Anchors
[
i
]
.
Title
=
anc
.
Title
newPage
.
Anchors
[
i
]
.
Title
=
anc
.
Title
...
@@ -229,7 +225,8 @@ func applyTranslations(page, origin types.PageData, translations map[string]stri
...
@@ -229,7 +225,8 @@ func applyTranslations(page, origin types.PageData, translations map[string]stri
}
}
// Translations: KeyValues (nur falls Value ein String ist)
// Translations: KeyValues (nur falls Value ein String ist)
for
i
,
t
:=
range
newPage
.
Translations
{
newPage
.
Translations
=
make
([]
types
.
Translations
,
len
(
origin
.
Translations
))
for
i
,
t
:=
range
origin
.
Translations
{
newKV
:=
make
(
map
[
string
]
interface
{})
newKV
:=
make
(
map
[
string
]
interface
{})
for
k
,
v
:=
range
t
.
KeyValues
{
for
k
,
v
:=
range
t
.
KeyValues
{
if
s
,
ok
:=
v
.
(
string
);
ok
{
if
s
,
ok
:=
v
.
(
string
);
ok
{
...
...
This diff is collapsed.
Click to expand it.
source/types/page-data.go
+
5
−
3
View file @
3b91ff9d
...
@@ -19,10 +19,12 @@ type Anchor struct {
...
@@ -19,10 +19,12 @@ type Anchor struct {
Title
string
`yaml:"title"`
Title
string
`yaml:"title"`
}
}
type
TranslationKeyValues
map
[
string
]
any
type
Translations
struct
{
type
Translations
struct
{
Id
string
`yaml:"id"`
Id
string
`yaml:"id"`
Type
string
`yaml:"type"`
Type
string
`yaml:"type"`
KeyValues
map
[
string
]
any
`yaml:"translations"`
KeyValues
TranslationKeyValues
`yaml:"translations"`
}
}
type
AddModification
struct
{
type
AddModification
struct
{
...
...
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