Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
4dbce52e
Commit
4dbce52e
authored
2 years ago
by
Kocher, Manuel
Browse files
Options
Downloads
Patches
Plain Diff
Enable namespaces for Translation component
parent
a104587c
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
packages/common/src/i18n.js
+7
-5
7 additions, 5 deletions
packages/common/src/i18n.js
packages/common/src/translation.js
+7
-1
7 additions, 1 deletion
packages/common/src/translation.js
with
14 additions
and
6 deletions
packages/common/src/i18n.js
+
7
−
5
View file @
4dbce52e
...
...
@@ -7,25 +7,27 @@ export function createInstance() {
return
_createInstance
({
en
:
en
,
de
:
de
},
'
de
'
,
'
en
'
);
}
export
async
function
createInstanceAsync
(
langFile
)
{
export
async
function
createInstanceAsync
(
langFile
,
namespace
)
{
if
(
namespace
==
undefined
)
namespace
=
'
translation
'
// check if a path to language files is given
if
(
langFile
)
{
// request german lang file asynchronously
let
result
=
await
fetch
(
langFile
+
'
de/
translation
.json
'
,
{
fetch
(
langFile
+
'
de/
'
+
namespace
+
'
.json
'
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
},
});
const
dynDe
=
await
result
.
json
();
// request english lang file asynchronously
result
=
await
fetch
(
langFile
+
'
en/
translation
.json
'
,
{
fetch
(
langFile
+
'
en/
'
+
namespace
+
'
.json
'
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
},
});
const
dynEn
=
await
result
.
json
();
return
_createInstance
({
en
:
dynEn
,
de
:
dynDe
},
'
de
'
,
'
en
'
);
return
_createInstance
({
en
:
dynEn
,
de
:
dynDe
},
'
de
'
,
'
en
'
,
namespace
);
}
return
_createInstance
({
en
:
en
,
de
:
de
},
'
de
'
,
'
en
'
);
return
_createInstance
({
en
:
en
,
de
:
de
},
'
de
'
,
'
en
'
,
namespace
);
}
This diff is collapsed.
Click to expand it.
packages/common/src/translation.js
+
7
−
1
View file @
4dbce52e
...
...
@@ -11,6 +11,7 @@ export class Translation extends DBPLitElement {
this
.
lang
=
''
;
this
.
langFiles
=
''
;
this
.
interpolation
=
''
;
this
.
namespace
=
''
;
}
static
get
properties
()
{
...
...
@@ -21,6 +22,7 @@ export class Translation extends DBPLitElement {
langFiles
:
{
type
:
String
,
attribute
:
'
lang-files
'
},
interpolation
:
{
type
:
Object
,
attribute
:
'
var
'
},
unsafe
:
{
type
:
Boolean
,
attribute
:
'
unsafe
'
},
namespace
:
{
type
:
String
,
attribute
:
'
ns
'
},
};
}
...
...
@@ -35,7 +37,11 @@ export class Translation extends DBPLitElement {
connectedCallback
()
{
super
.
connectedCallback
();
this
.
_i18n
=
createInstanceAsync
(
this
.
langFiles
);
if
(
this
.
namespace
==
''
)
this
.
_i18n
=
createInstanceAsync
(
this
.
langFiles
);
else
{
this
.
_i18n
=
createInstanceAsync
(
this
.
langFiles
,
this
.
namespace
);
}
}
update
(
changedProperties
)
{
...
...
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