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
f5f2ebc0
Commit
f5f2ebc0
authored
3 years ago
by
Reiter, Christoph
Browse files
Options
Downloads
Patches
Plain Diff
typescript-example: one i18next instance per element
parent
83c59262
No related branches found
Branches containing commit
No related tags found
1 merge request
!67
Create a new i18next instance for every web component
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/typescript-example/src/i18n.ts
+4
-2
4 additions, 2 deletions
packages/typescript-example/src/i18n.ts
packages/typescript-example/src/typescript-example.ts
+12
-12
12 additions, 12 deletions
packages/typescript-example/src/typescript-example.ts
with
16 additions
and
14 deletions
packages/typescript-example/src/i18n.ts
+
4
−
2
View file @
f5f2ebc0
import
{
createInstance
}
from
'
@dbp-toolkit/common/i18next.js
'
;
import
{
createInstance
as
_createInstance
}
from
'
@dbp-toolkit/common/i18next.js
'
;
import
de
from
'
./i18n/de/translation.json
'
;
import
de
from
'
./i18n/de/translation.json
'
;
import
en
from
'
./i18n/en/translation.json
'
;
import
en
from
'
./i18n/en/translation.json
'
;
export
const
i18n
=
createInstance
({
en
:
en
,
de
:
de
},
'
de
'
,
'
en
'
);
export
function
createInstance
()
{
\ No newline at end of file
return
_createInstance
({
en
:
en
,
de
:
de
},
'
de
'
,
'
en
'
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
packages/typescript-example/src/typescript-example.ts
+
12
−
12
View file @
f5f2ebc0
import
{
html
,
LitElement
,
property
}
from
'
lit-element
'
;
import
{
html
,
LitElement
}
from
'
lit-element
'
;
import
{
i18n
}
from
'
./i18n
'
;
import
{
createInstance
}
from
'
./i18n
'
;
export
class
TypeScriptExample
extends
LitElement
{
export
class
TypeScriptExample
extends
LitElement
{
...
@@ -8,20 +8,20 @@ export class TypeScriptExample extends LitElement {
...
@@ -8,20 +8,20 @@ export class TypeScriptExample extends LitElement {
constructor
()
{
constructor
()
{
super
();
super
();
this
.
_i18n
=
i18n
.
cloneInstance
();
this
.
_i18n
=
createInstance
();
this
.
lang
=
this
.
_i18n
.
language
;
}
}
@
property
({
type
:
String
})
static
get
properties
()
{
lang
=
''
;
return
{
lang
:
{
type
:
String
}
};
}
update
(
changedProperties
)
{
update
(
changedProperties
)
{
changedProperties
.
forEach
((
oldValue
,
propName
)
=>
{
if
(
changedProperties
.
has
(
"
lang
"
))
{
switch
(
propName
)
{
this
.
_i18n
.
changeLanguage
(
this
.
lang
);
case
"
lang
"
:
}
this
.
_i18n
.
changeLanguage
(
this
.
lang
);
break
;
}
});
super
.
update
(
changedProperties
);
super
.
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